From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Charles A. Roelli" Newsgroups: gmane.emacs.bugs Subject: bug#26905: [PATCH] Show tooltip on correct screen (bug#26905) Date: Fri, 19 May 2017 18:30:30 +0200 Message-ID: <03F7D972-4113-4CEE-94EB-410A5AD25CE1@aurox.ch> References: <20170516215628.GA49365@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1495211472 6320 195.159.176.226 (19 May 2017 16:31:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 19 May 2017 16:31:12 +0000 (UTC) Cc: 26905@debbugs.gnu.org To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 19 18:31:07 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBkny-0001V4-Rz for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 May 2017 18:31:07 +0200 Original-Received: from localhost ([::1]:59570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBko4-00081T-9e for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 May 2017 12:31:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBkny-00081N-Lr for bug-gnu-emacs@gnu.org; Fri, 19 May 2017 12:31:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBknv-0008Ma-H1 for bug-gnu-emacs@gnu.org; Fri, 19 May 2017 12:31:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dBknu-0008MO-Rw for bug-gnu-emacs@gnu.org; Fri, 19 May 2017 12:31:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dBknu-0007xs-G6 for bug-gnu-emacs@gnu.org; Fri, 19 May 2017 12:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Charles A. Roelli" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 May 2017 16:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26905 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26905-submit@debbugs.gnu.org id=B26905.149521144530592 (code B ref 26905); Fri, 19 May 2017 16:31:02 +0000 Original-Received: (at 26905) by debbugs.gnu.org; 19 May 2017 16:30:45 +0000 Original-Received: from localhost ([127.0.0.1]:55561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBknc-0007xM-OD for submit@debbugs.gnu.org; Fri, 19 May 2017 12:30:44 -0400 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:50874) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBkna-0007x9-Ht for 26905@debbugs.gnu.org; Fri, 19 May 2017 12:30:43 -0400 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id 966BD22437 for <26905@debbugs.gnu.org>; Fri, 19 May 2017 16:26:11 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h=to :references:message-id:content-transfer-encoding:date:date :in-reply-to:x-mailer:from:from:subject:subject:mime-version :content-type:content-type; s=dkim; t=1495211169; x=1496075170; bh=G89We6Ite5/6iCtAedbM2RQsmVZSRrCg+rKjbFAglUI=; b=E5l44coq931r Iv/fsZSf0lebVkrNSqoo9w/gHY0LFpRPQnbmHjjhRYi05C2JC0AJ1tiXXWGwZ4bQ qmkYOlV2Le6KC8bd6Z/3d1YstSKaFSThrJXusseEm1dUWbnpOnTr0uYvv9Z9t/Lp D6OhJT2JluZNvt7iWlwW8nC7v9J1hQI= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Original-Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id OEnSBVOs3j-G for <26905@debbugs.gnu.org>; Fri, 19 May 2017 16:26:09 +0000 (UTC) Original-Received: from [192.168.1.110] (179.133.105.92.dynamic.wline.res.cust.swisscom.ch [92.105.133.179]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id 9032322427; Fri, 19 May 2017 16:26:09 +0000 (UTC) X-Mailer: iPhone Mail (14E304) In-Reply-To: <20170516215628.GA49365@breton.holly.idiocy.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:132651 Archived-At: Works fine for me too! Thanks for coming up with this fix. > On 16 May 2017, at 23:56, Alan Third wrote: >=20 > * src/nsfns.m (compute_tip_xy): Find the correct screen for the > tooltip and constrain it to that screen. > --- > src/nsfns.m | 27 ++++++++++++++++++++------- > 1 file changed, 20 insertions(+), 7 deletions(-) >=20 > diff --git a/src/nsfns.m b/src/nsfns.m > index cbe0ffb858..04565a99bb 100644 > --- a/src/nsfns.m > +++ b/src/nsfns.m > @@ -2760,6 +2760,7 @@ and GNUstep implementations ("distributor-specific r= elease > EmacsView *view =3D FRAME_NS_VIEW (f); > struct ns_display_info *dpyinfo =3D FRAME_DISPLAY_INFO (f); > NSPoint pt; > + NSScreen *screen; >=20 > /* Start with user-specified or mouse position. */ > left =3D Fcdr (Fassq (Qleft, parms)); > @@ -2794,13 +2795,25 @@ and GNUstep implementations ("distributor-specific= release > - height); > } >=20 > + /* Find the screen that pt is on. */ > + for (screen in [NSScreen screens]) > +#ifdef NS_IMPL_COCOA > + if (CGRectContainsPoint ([screen frame], pt)) > +#else > + if (pt.x >=3D screen.frame.origin.x > + && pt.x < screen.frame.origin.x + screen.frame.size.width > + && pt.y >=3D screen.frame.origin.y > + && pt.y < screen.frame.origin.y + screen.frame.size.height) > +#endif > + break; > + > /* Ensure in bounds. (Note, screen origin =3D lower left.) */ > if (INTEGERP (left) || INTEGERP (right)) > *root_x =3D pt.x; > - else if (pt.x + XINT (dx) <=3D 0) > - *root_x =3D 0; /* Can happen for negative dx */ > + else if (pt.x + XINT (dx) <=3D screen.frame.origin.x) > + *root_x =3D screen.frame.origin.x; /* Can happen for negative dx */ > else if (pt.x + XINT (dx) + width > - <=3D x_display_pixel_width (FRAME_DISPLAY_INFO (f))) > + <=3D screen.frame.origin.x + screen.frame.size.width) > /* It fits to the right of the pointer. */ > *root_x =3D pt.x + XINT (dx); > else if (width + XINT (dx) <=3D pt.x) > @@ -2808,20 +2821,20 @@ and GNUstep implementations ("distributor-specific= release > *root_x =3D pt.x - width - XINT (dx); > else > /* Put it left justified on the screen -- it ought to fit that way. *= / > - *root_x =3D 0; > + *root_x =3D screen.frame.origin.x; >=20 > if (INTEGERP (top) || INTEGERP (bottom)) > *root_y =3D pt.y; > - else if (pt.y - XINT (dy) - height >=3D 0) > + else if (pt.y - XINT (dy) - height >=3D screen.frame.origin.y) > /* It fits below the pointer. */ > *root_y =3D pt.y - height - XINT (dy); > else if (pt.y + XINT (dy) + height > - <=3D x_display_pixel_height (FRAME_DISPLAY_INFO (f))) > + <=3D screen.frame.origin.y + screen.frame.size.height) > /* It fits above the pointer */ > *root_y =3D pt.y + XINT (dy); > else > /* Put it on the top. */ > - *root_y =3D x_display_pixel_height (FRAME_DISPLAY_INFO (f)) - height;= > + *root_y =3D screen.frame.origin.y + screen.frame.size.height - height= ; > } >=20 >=20 > --=20 >=20 > Here=E2=80=99s my go at this. It seems to work OK on single and multi=E2=80= =90monitor > setups in macOS, and in GNUstep in single monitor (I can=E2=80=99t test it= > multi=E2=80=90monitor). >=20 > --=20 > Alan Third