From unknown Thu Jun 19 14:18:13 2025 X-Loop: don@donarmstrong.com Subject: bug#24: Broken tooltips with dual-head on MS Windows Reply-To: Neil Roberts , 24@debbugs.gnu.org Resent-From: Neil Roberts Original-Sender: bug-gnu-emacs-bounces+jasonr=gnu.org@gnu.org Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 29 Feb 2008 09:10:05 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 24 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12042758208348 (code B ref -1); Fri, 29 Feb 2008 09:10:05 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: * X-Spam-Status: No, score=1.1 required=4.0 tests=FOURLA,MURPHY_DRUGS_REL8, SPF_HELO_PASS,UNPARSEABLE_RELAY autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 29 Feb 2008 09:03:40 +0000 Received: from mk-outboundfilter-3.mail.uk.tiscali.com (mk-outboundfilter-3.mail.uk.tiscali.com [212.74.114.23]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m1T93NX0008341 for ; Fri, 29 Feb 2008 01:03:26 -0800 X-Trace: 51303162/mk-outboundfilter-1.mail.uk.tiscali.com/F2S/$ACCEPTED/freedom2Surf-customers/83.67.23.108 X-SBRS: None X-RemoteIP: 83.67.23.108 X-IP-MAIL-FROM: jasonr@f2s.com X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AswMAJtYx0dTQxds/2dsb2JhbACRawubdA X-IP-Direction: OUT Received: from i-83-67-23-108.freedom2surf.net (HELO [127.0.0.1]) ([83.67.23.108]) by smtp.f2s.tiscali.co.uk with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Feb 2008 09:03:11 +0000 Resent-From: Jason Rumney Resent-To: submit@debbugs.gnu.org Resent-Date: Fri, 29 Feb 2008 09:03:08 +0000 Resent-Message-Id: <47C7CA4C.5080203@f2s.com> Resent-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 X-Original-To: jasonr@localhost Received: from wanchan.jasonr.f2s.com (localhost [127.0.0.1]) by wanchan.jasonrumney.net (Postfix) with ESMTP id 53F52C78 for ; Sat, 21 Jul 2007 15:32:43 +0100 (BST) Received: from imap.freedom2surf.net [195.224.192.52] by wanchan.jasonr.f2s.com with POP3 (fetchmail-6.3.8) for (single-drop); Sat, 21 Jul 2007 15:32:43 +0100 (BST) Received: from murder ([unix socket]) by imap2.freedom2surf.net (Cyrus v2.2.12-Invoca-RPM-2.2.12-3.RHEL4.1) with LMTPA; Sat, 21 Jul 2007 15:28:20 +0100 X-Sieve: CMU Sieve 2.2 Received: from avs04.freedom2surf.net (avs04.freedom2surf.net [195.224.224.197]) by imap2.freedom2surf.net (Postfix) with ESMTP id 1A853467FE8 for ; Sat, 21 Jul 2007 15:28:18 +0100 (BST) Received: from localhost ([127.0.0.1] helo=avs04.freedom2surf.net) by avs04.freedom2surf.net with esmtp (Exim 4.43) id 1ICFwQ-0000i4-Ib for jasonr@f2s.com; Sat, 21 Jul 2007 15:28:18 +0100 Received: from mx3.freedom2surf.net ([194.106.35.254]) by avs04.freedom2surf.net with esmtp (Exim 4.43) id 1ICFwQ-0000hx-HP for jasonr@f2s.com; Sat, 21 Jul 2007 15:28:18 +0100 Received: from fencepost.gnu.org ([140.186.70.10]) by mx3.freedom2surf.net with esmtp (Exim 4.62) (envelope-from ) id 1ICFwQ-000303-1U for jasonr@f2s.com; Sat, 21 Jul 2007 15:28:18 +0100 Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ICFxi-0006Z6-50 for jasonr@gnu.org; Sat, 21 Jul 2007 10:29:38 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1ICFwO-0007Ds-Ei for jasonr@gnu.org; Sat, 21 Jul 2007 10:28:16 -0400 Received: from lists.gnu.org ([199.232.76.165]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ICFwN-0007Do-Uk for jasonr@gnu.org; Sat, 21 Jul 2007 10:28:16 -0400 Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ICFwN-0006FA-MF for jasonr@gnu.org; Sat, 21 Jul 2007 10:28:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ICD4x-00041y-7L for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ICD4w-00041m-M4 for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:54 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ICD4w-00041j-Ix for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:54 -0400 Received: from mra05.ch.as12513.net ([82.153.254.73]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ICD4v-0006PO-Na for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:54 -0400 Received: from localhost (localhost [127.0.0.1]) by mra05.ch.as12513.net (Postfix) with ESMTP id 4A20FC45D3 for ; Sat, 21 Jul 2007 12:24:52 +0100 (BST) Received: from mra05.ch.as12513.net ([127.0.0.1]) by localhost (mra05.ch.as12513.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 18907-01-34 for ; Sat, 21 Jul 2007 12:24:51 +0100 (BST) Received: from localhost (unknown [91.84.60.59]) by mra05.ch.as12513.net (Postfix) with ESMTP id 76C27C45B0 for ; Sat, 21 Jul 2007 12:24:51 +0100 (BST) Date: Sat, 21 Jul 2007 12:24:51 +0100 From: Neil Roberts To: bug-gnu-emacs@gnu.org Message-ID: <20070721112451.GA8553@janet> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zYM0uCDKw75PZbzx" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: by Eclipse VIRUSshield at eclipse.net.uk X-detected-kernel: Linux 2.4-2.6 X-Mailman-Approved-At: Sat, 21 Jul 2007 10:28:09 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: bug-gnu-emacs-bounces+jasonr=gnu.org@gnu.org Errors-To: bug-gnu-emacs-bounces+jasonr=gnu.org@gnu.org X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-F2S-Spam-Score: 0 --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I found a few problems with the positioning of tooltips when more than one monitor is used under Windows. The current code seems to only take into account the dimensions of the primary display so that for example if the cursor is to the right of the primary display then it will always think the tooltip doesn't fit and it will always move it to the left of the cursor. Also, if there is a display to the left of the primary display then all of the coordinates on that display are negative but Emacs won't let the tooltip be positioned at a co-ordinate less than zero so the tooltip is placed in the wrong display. I've made a little patch to the compute_tip_xy function to make it use the multi-monitor API so that it can correctly position the tooltip within the display containing the cursor. The API is checked for dynamically using GetProcAddress so that it can still work under Windows 95 where it isn't available. I'm not sure if the rest of Emacs still supports Win95 so it could be tidied up if this isn't necessary. Regards, - Neil --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="wintooltip.patch" Index: src/w32fns.c =================================================================== RCS file: /sources/emacs/emacs/src/w32fns.c,v retrieving revision 1.290 diff -c -r1.290 w32fns.c *** src/w32fns.c 15 Jul 2007 01:50:54 -0000 1.290 --- src/w32fns.c 21 Jul 2007 10:02:15 -0000 *************** *** 7458,7463 **** --- 7458,7464 ---- int *root_x, *root_y; { Lisp_Object left, top; + RECT monitor_rect; /* User-specified position? */ left = Fcdr (Fassq (Qleft, parms)); *************** *** 7468,7508 **** if (!INTEGERP (left) || !INTEGERP (top)) { POINT pt; BLOCK_INPUT; GetCursorPos (&pt); *root_x = pt.x; *root_y = pt.y; UNBLOCK_INPUT; } if (INTEGERP (top)) *root_y = XINT (top); ! else if (*root_y + XINT (dy) <= 0) ! *root_y = 0; /* Can happen for negative dy */ ! else if (*root_y + XINT (dy) + height <= FRAME_W32_DISPLAY_INFO (f)->height) /* It fits below the pointer */ ! *root_y += XINT (dy); ! else if (height + XINT (dy) <= *root_y) /* It fits above the pointer. */ *root_y -= height + XINT (dy); else /* Put it on the top. */ ! *root_y = 0; if (INTEGERP (left)) *root_x = XINT (left); ! else if (*root_x + XINT (dx) <= 0) ! *root_x = 0; /* Can happen for negative dx */ ! else if (*root_x + XINT (dx) + width <= FRAME_W32_DISPLAY_INFO (f)->width) /* It fits to the right of the pointer. */ *root_x += XINT (dx); ! else if (width + XINT (dx) <= *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; } --- 7469,7538 ---- if (!INTEGERP (left) || !INTEGERP (top)) { POINT pt; + HMODULE user32; + void *(WINAPI * monitor_from_point) (POINT, DWORD); + BOOL (WINAPI * get_monitor_info) (void *, void *); BLOCK_INPUT; GetCursorPos (&pt); *root_x = pt.x; *root_y = pt.y; + + /* Try to get the rectangle for the monitor around the point. If + the monitor API is not available (eg, on Windows 95) then + just assume there is only one monitor */ + monitor_rect.left = 0; + monitor_rect.right = FRAME_W32_DISPLAY_INFO (f)->width; + monitor_rect.top = 0; + monitor_rect.bottom = FRAME_W32_DISPLAY_INFO (f)->height; + if ((user32 = LoadLibrary ("user32"))) + { + if ((monitor_from_point = (void *(WINAPI *) (POINT, DWORD)) + GetProcAddress (user32, "MonitorFromPoint")) + && (get_monitor_info = (BOOL (WINAPI *) (void *, void*)) + GetProcAddress (user32, "GetMonitorInfoA"))) + { + void *monitor; + char buf[40 /* sizeof (MONITORINFO) */]; + *(DWORD *) buf = 40; /* set cbSize */ + monitor = (* monitor_from_point) (pt, 2 /* MONITOR_DEFAULTTONEAREST */); + if ((* get_monitor_info) (monitor, buf)) + monitor_rect = *(RECT *) (buf + sizeof (DWORD)); + } + + FreeLibrary (user32); + } + UNBLOCK_INPUT; } if (INTEGERP (top)) *root_y = XINT (top); ! else if (*root_y + XINT (dy) <= monitor_rect.top) ! *root_y = monitor_rect.top; /* Can happen for negative dy */ ! else if (*root_y + XINT (dy) + height <= monitor_rect.bottom) /* It fits below the pointer */ ! *root_y += XINT (dy); ! else if (*root_y - XINT (dy) - height >= monitor_rect.top) /* It fits above the pointer. */ *root_y -= height + XINT (dy); else /* Put it on the top. */ ! *root_y = monitor_rect.top; if (INTEGERP (left)) *root_x = XINT (left); ! else if (*root_x + XINT (dx) <= monitor_rect.left) ! *root_x = monitor_rect.left; /* Can happen for negative dx */ ! else if (*root_x + XINT (dx) + width <= monitor_rect.right) /* It fits to the right of the pointer. */ *root_x += XINT (dx); ! else if (*root_x - width - XINT (dx) >= monitor_rect.left) /* 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 = monitor_rect.left; } --zYM0uCDKw75PZbzx Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ bug-gnu-emacs mailing list bug-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs --zYM0uCDKw75PZbzx-- From unknown Thu Jun 19 14:18:13 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.420 (Entity 5.420) X-Loop: don@donarmstrong.com From: help-debbugs@gnu.org (Emacs bug Tracking System) To: Neil Roberts Subject: bug#24 closed by Jason Rumney (Re: Broken tooltips with dual-head on MS Windows) Message-ID: References: <47DAA39B.2080309@gnu.org> <20070721112451.GA8553@janet> X-Emacs-PR-Message: they-closed 24 X-Emacs-PR-Package: emacs Reply-To: 24@debbugs.gnu.org Content-Type: multipart/mixed; boundary="----------=_1205511604-6608-1" This is a multi-part message in MIME format... ------------=_1205511604-6608-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is an automatic notification regarding your bug report which was filed against the emacs package: #24: Broken tooltips with dual-head on MS Windows It has been closed by Jason Rumney . Their explanation is attached below along with your original report. If this explanation is unsatisfactory and you have not received a better one in a separate message then please contact Jason Rumney by replying to this email. --=20 24: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D24 Emacs Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1205511604-6608-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit >From jasonr@gnu.org Fri Mar 14 09:11:43 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=0.1 required=4.0 tests=AWL,MURPHY_DRUGS_REL8, SPF_HELO_PASS autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 24-done) by emacsbugs.donarmstrong.com; 14 Mar 2008 16:11:43 +0000 Received: from mk-outboundfilter-3.mail.uk.tiscali.com (mk-outboundfilter-3.mail.uk.tiscali.com [212.74.114.23]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m2EGBc7u005942 for <24-done@emacsbugs.donarmstrong.com>; Fri, 14 Mar 2008 09:11:40 -0700 X-Trace: 63419376/mk-outboundfilter-1.mail.uk.tiscali.com/F2S/$ACCEPTED/freedom2Surf-customers/83.67.23.108 X-SBRS: None X-RemoteIP: 83.67.23.108 X-IP-MAIL-FROM: jasonr@gnu.org X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgABAA5A2kdTQxds/2dsb2JhbAAIqVc X-IP-Direction: OUT Received: from i-83-67-23-108.freedom2surf.net (HELO [192.168.249.28]) ([83.67.23.108]) by smtp.f2s.tiscali.co.uk with ESMTP/TLS/DHE-RSA-AES256-SHA; 14 Mar 2008 16:11:09 +0000 Message-ID: <47DAA39B.2080309@gnu.org> Date: Fri, 14 Mar 2008 16:11:07 +0000 From: Jason Rumney User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: 24-done@debbugs.gnu.org Subject: Re: Broken tooltips with dual-head on MS Windows Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I've applied a similar patch to Emacs 23 (trunk). ------------=_1205511604-6608-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit >From jasonr@f2s.com Fri Feb 29 01:03:40 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: * X-Spam-Status: No, score=1.1 required=4.0 tests=FOURLA,MURPHY_DRUGS_REL8, SPF_HELO_PASS,UNPARSEABLE_RELAY autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 29 Feb 2008 09:03:40 +0000 Received: from mk-outboundfilter-3.mail.uk.tiscali.com (mk-outboundfilter-3.mail.uk.tiscali.com [212.74.114.23]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m1T93NX0008341 for ; Fri, 29 Feb 2008 01:03:26 -0800 X-Trace: 51303162/mk-outboundfilter-1.mail.uk.tiscali.com/F2S/$ACCEPTED/freedom2Surf-customers/83.67.23.108 X-SBRS: None X-RemoteIP: 83.67.23.108 X-IP-MAIL-FROM: jasonr@f2s.com X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AswMAJtYx0dTQxds/2dsb2JhbACRawubdA X-IP-Direction: OUT Received: from i-83-67-23-108.freedom2surf.net (HELO [127.0.0.1]) ([83.67.23.108]) by smtp.f2s.tiscali.co.uk with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Feb 2008 09:03:11 +0000 Resent-From: Jason Rumney Resent-To: submit@debbugs.gnu.org Resent-Date: Fri, 29 Feb 2008 09:03:08 +0000 Resent-Message-Id: <47C7CA4C.5080203@f2s.com> Resent-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 X-Original-To: jasonr@localhost Received: from wanchan.jasonr.f2s.com (localhost [127.0.0.1]) by wanchan.jasonrumney.net (Postfix) with ESMTP id 53F52C78 for ; Sat, 21 Jul 2007 15:32:43 +0100 (BST) Received: from imap.freedom2surf.net [195.224.192.52] by wanchan.jasonr.f2s.com with POP3 (fetchmail-6.3.8) for (single-drop); Sat, 21 Jul 2007 15:32:43 +0100 (BST) Received: from murder ([unix socket]) by imap2.freedom2surf.net (Cyrus v2.2.12-Invoca-RPM-2.2.12-3.RHEL4.1) with LMTPA; Sat, 21 Jul 2007 15:28:20 +0100 X-Sieve: CMU Sieve 2.2 Received: from avs04.freedom2surf.net (avs04.freedom2surf.net [195.224.224.197]) by imap2.freedom2surf.net (Postfix) with ESMTP id 1A853467FE8 for ; Sat, 21 Jul 2007 15:28:18 +0100 (BST) Received: from localhost ([127.0.0.1] helo=avs04.freedom2surf.net) by avs04.freedom2surf.net with esmtp (Exim 4.43) id 1ICFwQ-0000i4-Ib for jasonr@f2s.com; Sat, 21 Jul 2007 15:28:18 +0100 Received: from mx3.freedom2surf.net ([194.106.35.254]) by avs04.freedom2surf.net with esmtp (Exim 4.43) id 1ICFwQ-0000hx-HP for jasonr@f2s.com; Sat, 21 Jul 2007 15:28:18 +0100 Received: from fencepost.gnu.org ([140.186.70.10]) by mx3.freedom2surf.net with esmtp (Exim 4.62) (envelope-from ) id 1ICFwQ-000303-1U for jasonr@f2s.com; Sat, 21 Jul 2007 15:28:18 +0100 Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ICFxi-0006Z6-50 for jasonr@gnu.org; Sat, 21 Jul 2007 10:29:38 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1ICFwO-0007Ds-Ei for jasonr@gnu.org; Sat, 21 Jul 2007 10:28:16 -0400 Received: from lists.gnu.org ([199.232.76.165]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ICFwN-0007Do-Uk for jasonr@gnu.org; Sat, 21 Jul 2007 10:28:16 -0400 Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ICFwN-0006FA-MF for jasonr@gnu.org; Sat, 21 Jul 2007 10:28:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ICD4x-00041y-7L for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ICD4w-00041m-M4 for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:54 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ICD4w-00041j-Ix for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:54 -0400 Received: from mra05.ch.as12513.net ([82.153.254.73]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ICD4v-0006PO-Na for bug-gnu-emacs@gnu.org; Sat, 21 Jul 2007 07:24:54 -0400 Received: from localhost (localhost [127.0.0.1]) by mra05.ch.as12513.net (Postfix) with ESMTP id 4A20FC45D3 for ; Sat, 21 Jul 2007 12:24:52 +0100 (BST) Received: from mra05.ch.as12513.net ([127.0.0.1]) by localhost (mra05.ch.as12513.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 18907-01-34 for ; Sat, 21 Jul 2007 12:24:51 +0100 (BST) Received: from localhost (unknown [91.84.60.59]) by mra05.ch.as12513.net (Postfix) with ESMTP id 76C27C45B0 for ; Sat, 21 Jul 2007 12:24:51 +0100 (BST) Date: Sat, 21 Jul 2007 12:24:51 +0100 From: Neil Roberts To: bug-gnu-emacs@gnu.org Message-ID: <20070721112451.GA8553@janet> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zYM0uCDKw75PZbzx" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: by Eclipse VIRUSshield at eclipse.net.uk X-detected-kernel: Linux 2.4-2.6 X-Mailman-Approved-At: Sat, 21 Jul 2007 10:28:09 -0400 Subject: Broken tooltips with dual-head on MS Windows X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: bug-gnu-emacs-bounces+jasonr=gnu.org@gnu.org Errors-To: bug-gnu-emacs-bounces+jasonr=gnu.org@gnu.org X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-F2S-Spam-Score: 0 --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I found a few problems with the positioning of tooltips when more than one monitor is used under Windows. The current code seems to only take into account the dimensions of the primary display so that for example if the cursor is to the right of the primary display then it will always think the tooltip doesn't fit and it will always move it to the left of the cursor. Also, if there is a display to the left of the primary display then all of the coordinates on that display are negative but Emacs won't let the tooltip be positioned at a co-ordinate less than zero so the tooltip is placed in the wrong display. I've made a little patch to the compute_tip_xy function to make it use the multi-monitor API so that it can correctly position the tooltip within the display containing the cursor. The API is checked for dynamically using GetProcAddress so that it can still work under Windows 95 where it isn't available. I'm not sure if the rest of Emacs still supports Win95 so it could be tidied up if this isn't necessary. Regards, - Neil --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="wintooltip.patch" Index: src/w32fns.c =================================================================== RCS file: /sources/emacs/emacs/src/w32fns.c,v retrieving revision 1.290 diff -c -r1.290 w32fns.c *** src/w32fns.c 15 Jul 2007 01:50:54 -0000 1.290 --- src/w32fns.c 21 Jul 2007 10:02:15 -0000 *************** *** 7458,7463 **** --- 7458,7464 ---- int *root_x, *root_y; { Lisp_Object left, top; + RECT monitor_rect; /* User-specified position? */ left = Fcdr (Fassq (Qleft, parms)); *************** *** 7468,7508 **** if (!INTEGERP (left) || !INTEGERP (top)) { POINT pt; BLOCK_INPUT; GetCursorPos (&pt); *root_x = pt.x; *root_y = pt.y; UNBLOCK_INPUT; } if (INTEGERP (top)) *root_y = XINT (top); ! else if (*root_y + XINT (dy) <= 0) ! *root_y = 0; /* Can happen for negative dy */ ! else if (*root_y + XINT (dy) + height <= FRAME_W32_DISPLAY_INFO (f)->height) /* It fits below the pointer */ ! *root_y += XINT (dy); ! else if (height + XINT (dy) <= *root_y) /* It fits above the pointer. */ *root_y -= height + XINT (dy); else /* Put it on the top. */ ! *root_y = 0; if (INTEGERP (left)) *root_x = XINT (left); ! else if (*root_x + XINT (dx) <= 0) ! *root_x = 0; /* Can happen for negative dx */ ! else if (*root_x + XINT (dx) + width <= FRAME_W32_DISPLAY_INFO (f)->width) /* It fits to the right of the pointer. */ *root_x += XINT (dx); ! else if (width + XINT (dx) <= *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; } --- 7469,7538 ---- if (!INTEGERP (left) || !INTEGERP (top)) { POINT pt; + HMODULE user32; + void *(WINAPI * monitor_from_point) (POINT, DWORD); + BOOL (WINAPI * get_monitor_info) (void *, void *); BLOCK_INPUT; GetCursorPos (&pt); *root_x = pt.x; *root_y = pt.y; + + /* Try to get the rectangle for the monitor around the point. If + the monitor API is not available (eg, on Windows 95) then + just assume there is only one monitor */ + monitor_rect.left = 0; + monitor_rect.right = FRAME_W32_DISPLAY_INFO (f)->width; + monitor_rect.top = 0; + monitor_rect.bottom = FRAME_W32_DISPLAY_INFO (f)->height; + if ((user32 = LoadLibrary ("user32"))) + { + if ((monitor_from_point = (void *(WINAPI *) (POINT, DWORD)) + GetProcAddress (user32, "MonitorFromPoint")) + && (get_monitor_info = (BOOL (WINAPI *) (void *, void*)) + GetProcAddress (user32, "GetMonitorInfoA"))) + { + void *monitor; + char buf[40 /* sizeof (MONITORINFO) */]; + *(DWORD *) buf = 40; /* set cbSize */ + monitor = (* monitor_from_point) (pt, 2 /* MONITOR_DEFAULTTONEAREST */); + if ((* get_monitor_info) (monitor, buf)) + monitor_rect = *(RECT *) (buf + sizeof (DWORD)); + } + + FreeLibrary (user32); + } + UNBLOCK_INPUT; } if (INTEGERP (top)) *root_y = XINT (top); ! else if (*root_y + XINT (dy) <= monitor_rect.top) ! *root_y = monitor_rect.top; /* Can happen for negative dy */ ! else if (*root_y + XINT (dy) + height <= monitor_rect.bottom) /* It fits below the pointer */ ! *root_y += XINT (dy); ! else if (*root_y - XINT (dy) - height >= monitor_rect.top) /* It fits above the pointer. */ *root_y -= height + XINT (dy); else /* Put it on the top. */ ! *root_y = monitor_rect.top; if (INTEGERP (left)) *root_x = XINT (left); ! else if (*root_x + XINT (dx) <= monitor_rect.left) ! *root_x = monitor_rect.left; /* Can happen for negative dx */ ! else if (*root_x + XINT (dx) + width <= monitor_rect.right) /* It fits to the right of the pointer. */ *root_x += XINT (dx); ! else if (*root_x - width - XINT (dx) >= monitor_rect.left) /* 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 = monitor_rect.left; } --zYM0uCDKw75PZbzx Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ bug-gnu-emacs mailing list bug-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs --zYM0uCDKw75PZbzx-- ------------=_1205511604-6608-1--