From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#26905: [PATCH] Show tooltip on correct screen (bug#26905) Date: Tue, 16 May 2017 22:56:28 +0100 Message-ID: <20170516215628.GA49365@breton.holly.idiocy.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1494971838 15869 195.159.176.226 (16 May 2017 21:57:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 16 May 2017 21:57:18 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: 26905@debbugs.gnu.org To: "Charles A. Roelli" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 16 23:57:11 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 1dAkSs-0003xj-LM for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 May 2017 23:57:10 +0200 Original-Received: from localhost ([::1]:44308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAkSy-0007Va-Aq for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 May 2017 17:57:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAkSo-0007Sc-An for bug-gnu-emacs@gnu.org; Tue, 16 May 2017 17:57:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAkSl-00022g-1C for bug-gnu-emacs@gnu.org; Tue, 16 May 2017 17:57:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46579) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dAkSk-00022a-SX for bug-gnu-emacs@gnu.org; Tue, 16 May 2017 17:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dAkSk-0003Vd-FX for bug-gnu-emacs@gnu.org; Tue, 16 May 2017 17:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 May 2017 21:57: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.149497179913458 (code B ref 26905); Tue, 16 May 2017 21:57:02 +0000 Original-Received: (at 26905) by debbugs.gnu.org; 16 May 2017 21:56:39 +0000 Original-Received: from localhost ([127.0.0.1]:49256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dAkSN-0003V0-B9 for submit@debbugs.gnu.org; Tue, 16 May 2017 17:56:39 -0400 Original-Received: from mail-wr0-f169.google.com ([209.85.128.169]:36379) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dAkSL-0003Uo-Sa for 26905@debbugs.gnu.org; Tue, 16 May 2017 17:56:38 -0400 Original-Received: by mail-wr0-f169.google.com with SMTP id l50so84115228wrc.3 for <26905@debbugs.gnu.org>; Tue, 16 May 2017 14:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=lbeSFHp+QRREAetup7HIvhiwMHeC3gfGnd+I6m8HPAU=; b=c/7RqROlzxHDxHaphW8Q4jFLRHT+DzEMCICPH/FKRlInLSI0jnxkczOvaT2xqwa8v1 9+jxR+iNuJY3BHMTMKO/BNlEByizWRfdK4Lvxu0fTFALTwYlNAANmhGOfTUj7oygelqu rVvYnqAT9YiL5+ZjnZ3QJhniEeDMIZ+HaJEfODZ91AoCTJRXrjPvgNl6D6rwEQkrjCLC Hpqfq2AozcDjnbKo8FzAmh0gCgkPjgxFGT3j2MToeIwEEryYAEHVtn/7EbBZlNcCf3aW zQxIxVNVaFJP1UkbgAIuK1iJk0l4UNbucQLq+1t++YH5S/j2pYqfbaiBcv8aoBTJfF3H 3zJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=lbeSFHp+QRREAetup7HIvhiwMHeC3gfGnd+I6m8HPAU=; b=CWarjaMT8cJ1gmRA657ZJWk14V/ErO/X55+u+aawpXPsZAjUJOOa0SJFEWTshe68qj 8JGbxvCSS/QUjkGtHMkFRXDGNRO/YsNxouOEdE/hC29NVeVsk8on8x+qxPTCoXAm2dQm pnZ/TMyU8iTyNbuGZhcDAXpwD6sROHoTkqniEc8p+U5aOrJqtGk9OdvNu9d7FD3XFilr 3AsVYIxCFWNBKuA1TQKUUhBr4WizlANxFSsaeY03s9AbqO9sidrYLGyL1Ge81U1ZCaQw wd+QlnGqt8+Cf+qxe0ZJzwfCT75nPDJUepMQzby9LCXMvy00dx3otMI25xcUwKwaupEf 2Amw== X-Gm-Message-State: AODbwcCCUQtXynDek1ZKnyM6Mm5SFLsrcPsAtmwAs6EDfu2iwljfCjoP 5dbkK594TmWKe5xf61s= X-Received: by 10.223.139.146 with SMTP id o18mr64127wra.146.1494971791984; Tue, 16 May 2017 14:56:31 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-e9b1-3358-0f3c-df92.holly.idiocy.org. [2001:8b0:3f8:8129:e9b1:3358:f3c:df92]) by smtp.gmail.com with ESMTPSA id p5sm11374689wma.17.2017.05.16.14.56.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 May 2017 14:56:31 -0700 (PDT) Content-Disposition: inline In-Reply-To: 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:132549 Archived-At: * 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(-) 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 release EmacsView *view = FRAME_NS_VIEW (f); struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); NSPoint pt; + NSScreen *screen; /* Start with user-specified or mouse position. */ left = Fcdr (Fassq (Qleft, parms)); @@ -2794,13 +2795,25 @@ and GNUstep implementations ("distributor-specific release - height); } + /* 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 >= screen.frame.origin.x + && pt.x < screen.frame.origin.x + screen.frame.size.width + && pt.y >= screen.frame.origin.y + && pt.y < screen.frame.origin.y + screen.frame.size.height) +#endif + break; + /* Ensure in bounds. (Note, screen origin = lower left.) */ if (INTEGERP (left) || INTEGERP (right)) *root_x = pt.x; - else if (pt.x + XINT (dx) <= 0) - *root_x = 0; /* Can happen for negative dx */ + else if (pt.x + XINT (dx) <= screen.frame.origin.x) + *root_x = screen.frame.origin.x; /* Can happen for negative dx */ else if (pt.x + XINT (dx) + width - <= x_display_pixel_width (FRAME_DISPLAY_INFO (f))) + <= screen.frame.origin.x + screen.frame.size.width) /* It fits to the right of the pointer. */ *root_x = pt.x + XINT (dx); else if (width + XINT (dx) <= pt.x) @@ -2808,20 +2821,20 @@ and GNUstep implementations ("distributor-specific release *root_x = pt.x - width - XINT (dx); else /* Put it left justified on the screen -- it ought to fit that way. */ - *root_x = 0; + *root_x = screen.frame.origin.x; if (INTEGERP (top) || INTEGERP (bottom)) *root_y = pt.y; - else if (pt.y - XINT (dy) - height >= 0) + else if (pt.y - XINT (dy) - height >= screen.frame.origin.y) /* It fits below the pointer. */ *root_y = pt.y - height - XINT (dy); else if (pt.y + XINT (dy) + height - <= x_display_pixel_height (FRAME_DISPLAY_INFO (f))) + <= screen.frame.origin.y + screen.frame.size.height) /* It fits above the pointer */ *root_y = pt.y + XINT (dy); else /* Put it on the top. */ - *root_y = x_display_pixel_height (FRAME_DISPLAY_INFO (f)) - height; + *root_y = screen.frame.origin.y + screen.frame.size.height - height; } -- Here’s my go at this. It seems to work OK on single and multi‐monitor setups in macOS, and in GNUstep in single monitor (I can’t test it multi‐monitor). -- Alan Third