From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.bugs Subject: bug#21173: 25.0.50; New frames positioned off screen with multiple monitors Date: Wed, 28 Oct 2015 19:39:28 +0000 Message-ID: References: <874mkjadqx.fsf@gmail.com> <55BCA4B1.8030103@gmx.at> <55BCEAA5.9020406@gmx.at> <55BF0E7D.1070007@gmx.at> <86k2s0v97i.fsf@gmail.com> <56137EDB.1020801@gmx.at> <56288487.9020202@gmx.at> <86h9lcou5o.fsf@gmail.com> <56309B7D.5090207@gmx.at> <56312020.90004@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446061285 8425 80.91.229.3 (28 Oct 2015 19:41:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Oct 2015 19:41:25 +0000 (UTC) To: 21173@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 28 20:41:13 2015 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 1ZrWau-0008Ct-Ll for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 Oct 2015 20:41:12 +0100 Original-Received: from localhost ([::1]:40453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrWat-0005ma-TE for geb-bug-gnu-emacs@m.gmane.org; Wed, 28 Oct 2015 15:41:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrWap-0005mO-52 for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 15:41:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrWal-0005Vy-UZ for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 15:41:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52179) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrWal-0005Vu-R7 for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 15:41:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZrWal-00049q-2y for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 15:41:03 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <874mkjadqx.fsf@gmail.com> Resent-From: Andy Moreton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Oct 2015 19:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21173 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.144606121015907 (code B ref -1); Wed, 28 Oct 2015 19:41:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Oct 2015 19:40:10 +0000 Original-Received: from localhost ([127.0.0.1]:42887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZrWZt-00048T-Dz for submit@debbugs.gnu.org; Wed, 28 Oct 2015 15:40:10 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50601) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZrWZX-00047h-9D for submit@debbugs.gnu.org; Wed, 28 Oct 2015 15:40:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrWZV-00052Q-Qf for submit@debbugs.gnu.org; Wed, 28 Oct 2015 15:39:46 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:47957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrWZV-00052F-N2 for submit@debbugs.gnu.org; Wed, 28 Oct 2015 15:39:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrWZR-0005ii-LV for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 15:39:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrWZO-000507-Ee for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 15:39:41 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:46608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrWZO-0004zm-7s for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 15:39:38 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZrWZM-0006nJ-Ep for bug-gnu-emacs@gnu.org; Wed, 28 Oct 2015 20:39:36 +0100 Original-Received: from uk.solarflare.com ([193.34.186.16]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Oct 2015 20:39:36 +0100 Original-Received: from andrewjmoreton by uk.solarflare.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Oct 2015 20:39:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 98 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: uk.solarflare.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt) Cancel-Lock: sha1:VBqmEKOmwy3KayeTTU2DrCluCJk= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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:108122 Archived-At: On Wed 28 Oct 2015, martin rudalics wrote: >> What non-default build options are you using to see this error ? >> I've built this without warnings on: >> mingw32 32bit >> mingw32 32bit wide-int >> mingw64 64bit >> cygwin 64bit > > I use --enable-checking=yes and --enable-check-lisp-object-type=yes. > >>> I suppose you meant writing something like >>> >>> Lisp_Object frame, list; >>> >>> XSETFRAME (frame, f); >>> list = Fw32_display_monitor_attributes_list (frame); >>> >>> Please have a look. >> >> I'm sure you know more about it than me - I don't know enough about the >> internals to judge which is correct. Feel free to adjust the patch to >> fix this. >> >> The patch as shown was tested with multiple monitors on Win7 64bit for both >> mingw64 and cygwin w32 builds, and worked correctly with the testcase >> from the original reporter. >> >> I've retested this briefly with your fix, which still works for the >> simple testcase shows by Fran Litterio. > > Then please simply write > > list = Fw32_display_monitor_attributes_list (Qnil); > > I can't safely change it because I can't test this. If, as Eli says, > the value doesn't matter, then Qnil should be safe. I've tested with this change on mingw64 64bit and cygwin 64bit w32 builds, and both create frames at the correct position. Tested patch with your change is below: diff --git a/src/w32term.c b/src/w32term.c index 831786726792..f764e250aa81 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -5913,16 +5913,49 @@ x_calc_absolute_position (struct frame *f) top_bottom_borders_height = 32; } + /* With multiple monitors, we can legitimately get negative + coordinates (for monitors above or to the left of the primary + monitor). Find the display origin to ensure negative positions + are computed correctly (Bug#21173). */ + int display_left = 0; + int display_top = 0; + if (flags & (XNegative | YNegative)) + { + Lisp_Object list; + + list = Fw32_display_monitor_attributes_list (Qnil); + while (CONSP (list)) + { + Lisp_Object attributes = CAR(list); + Lisp_Object geometry; + Lisp_Object monitor_left, monitor_top; + + list = CDR(list); + + geometry = Fassoc (Qgeometry, attributes); + if (!NILP (geometry)) + { + monitor_left = Fnth (make_number (1), geometry); + monitor_top = Fnth (make_number (2), geometry); + + display_left = min (display_left, XINT (monitor_left)); + display_top = min (display_top, XINT (monitor_top)); + } + } + } + /* Treat negative positions as relative to the rightmost bottommost position that fits on the screen. */ if (flags & XNegative) f->left_pos = (x_display_pixel_width (FRAME_DISPLAY_INFO (f)) + + display_left - FRAME_PIXEL_WIDTH (f) + f->left_pos - (left_right_borders_width - 1)); if (flags & YNegative) f->top_pos = (x_display_pixel_height (FRAME_DISPLAY_INFO (f)) + + display_top - FRAME_PIXEL_HEIGHT (f) + f->top_pos - (top_bottom_borders_height - 1));