From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?=C3=93scar?= Fuentes Newsgroups: gmane.emacs.bugs Subject: bug#22549: 25.0.50; Tooltips placed outside of screen limits Date: Sat, 06 Feb 2016 00:52:10 +0100 Message-ID: <8760y21zrp.fsf@wanadoo.es> References: <87zivh2k98.fsf@telefonica.net> <56B3747B.1000303@gmx.at> <87r3gs30rk.fsf@wanadoo.es> <56B384F4.8040208@gmx.at> <87d1sc2smy.fsf@wanadoo.es> <56B4DF82.8040106@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1454716403 19275 80.91.229.3 (5 Feb 2016 23:53:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Feb 2016 23:53:23 +0000 (UTC) Cc: 22549@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 06 00:53:10 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aRqBa-0006hA-48 for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Feb 2016 00:53:10 +0100 Original-Received: from localhost ([::1]:50919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqBZ-0003jq-IJ for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Feb 2016 18:53:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqBV-0003ij-7j for bug-gnu-emacs@gnu.org; Fri, 05 Feb 2016 18:53:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRqBS-0003fK-2Q for bug-gnu-emacs@gnu.org; Fri, 05 Feb 2016 18:53:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqBR-0003fG-UQ for bug-gnu-emacs@gnu.org; Fri, 05 Feb 2016 18:53:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aRqBR-000395-I4 for bug-gnu-emacs@gnu.org; Fri, 05 Feb 2016 18:53:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C3=93scar?= Fuentes Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Feb 2016 23:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22549 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22549-submit@debbugs.gnu.org id=B22549.145471634212043 (code B ref 22549); Fri, 05 Feb 2016 23:53:01 +0000 Original-Received: (at 22549) by debbugs.gnu.org; 5 Feb 2016 23:52:22 +0000 Original-Received: from localhost ([127.0.0.1]:34929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aRqAn-00038B-SW for submit@debbugs.gnu.org; Fri, 05 Feb 2016 18:52:22 -0500 Original-Received: from relaycp03.dominioabsoluto.net ([217.116.26.84]:38081) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aRqAl-00037t-LG for 22549@debbugs.gnu.org; Fri, 05 Feb 2016 18:52:21 -0500 Original-Received: from smtp.movistar.es (smtp09.acens.net [86.109.99.133]) by relaycp03.dominioabsoluto.net (Postfix) with ESMTP id 368EBBFA19E; Sat, 6 Feb 2016 00:52:12 +0100 (CET) X-CTCH-RefID: str=0001.0A0B0205.56B535AC.0036, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown Original-Received: from qcore (83.38.42.1) by smtp.movistar.es (8.6.122.03) (authenticated as 981711563$telefonica.net) id 56A37EDC010B7F16; Fri, 5 Feb 2016 23:52:12 +0000 In-Reply-To: <56B4DF82.8040106@gmx.at> (martin rudalics's message of "Fri, 05 Feb 2016 18:44:34 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:112536 Archived-At: --=-=-= Content-Type: text/plain We can use the coordinates to determine the monitor. The patch below works. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=tooltip_pos.diff diff --git a/src/xfns.c b/src/xfns.c index 9624ac5..a0182cd 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5683,6 +5683,7 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object int win_x, win_y; Window root, child; unsigned pmask; + int min_x, min_y, max_x, max_y; /* User-specified position? */ left = Fcdr (Fassq (Qleft, parms)); @@ -5695,45 +5696,74 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object if ((!INTEGERP (left) && !INTEGERP (right)) || (!INTEGERP (top) && !INTEGERP (bottom))) { + Lisp_Object frame, attributes, monitor, geometry; + + /* Default min and max values. */ + min_x = 0; + min_y = 0; + max_x = x_display_pixel_width (FRAME_DISPLAY_INFO (f)); + max_y = x_display_pixel_height (FRAME_DISPLAY_INFO (f)); + block_input (); XQueryPointer (FRAME_X_DISPLAY (f), FRAME_DISPLAY_INFO (f)->root_window, &root, &child, root_x, root_y, &win_x, &win_y, &pmask); unblock_input (); + + XSETFRAME(frame, f); + attributes = Fx_display_monitor_attributes_list (frame); + + while (CONSP (attributes)) + { + monitor = XCAR (attributes); + geometry = Fassq (Qgeometry, monitor); + if (CONSP (geometry)) + { + min_x = XINT (Fnth (make_number (1), geometry)); + min_y = XINT (Fnth (make_number (2), geometry)); + max_x = min_x + XINT (Fnth (make_number (3), geometry)); + max_y = min_y + XINT (Fnth (make_number (4), geometry)); + if (min_x <= *root_x && *root_x < max_x + && min_y <= *root_y && *root_y < max_y) + { + break; + } + } + + attributes = XCDR (attributes); + } } if (INTEGERP (top)) *root_y = XINT (top); else if (INTEGERP (bottom)) *root_y = XINT (bottom) - height; - else if (*root_y + XINT (dy) <= 0) - *root_y = 0; /* Can happen for negative dy */ - else if (*root_y + XINT (dy) + height - <= x_display_pixel_height (FRAME_DISPLAY_INFO (f))) + else if (*root_y + XINT (dy) <= min_y) + *root_y = min_y; /* Can happen for negative dy */ + else if (*root_y + XINT (dy) + height <= max_y) /* It fits below the pointer */ *root_y += XINT (dy); - else if (height + XINT (dy) <= *root_y) + else if (height + XINT (dy) + min_y <= *root_y) /* It fits above the pointer. */ *root_y -= height + XINT (dy); else /* Put it on the top. */ - *root_y = 0; + *root_y = min_y; if (INTEGERP (left)) *root_x = XINT (left); else if (INTEGERP (right)) *root_x = XINT (right) - width; - else if (*root_x + XINT (dx) <= 0) + else if (*root_x + XINT (dx) <= min_x) *root_x = 0; /* Can happen for negative dx */ - else if (*root_x + XINT (dx) + width - <= x_display_pixel_width (FRAME_DISPLAY_INFO (f))) + else if (*root_x + XINT (dx) + width <= max_x) /* It fits to the right of the pointer. */ *root_x += XINT (dx); - else if (width + XINT (dx) <= *root_x) + else if (width + XINT (dx) + min_x <= *root_x) /* It fits to the left of the pointer. */ *root_x -= width + XINT (dx); else - /* Put it left-justified on the screen--it ought to fit that way. */ - *root_x = 0; + /* Put it left justified on the screen -- it ought to fit that way. */ + *root_x = min_x; } --=-=-=--