unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: 21173@debbugs.gnu.org
Subject: bug#21173: 25.0.50; New frames positioned off screen with multiple monitors
Date: Tue, 27 Oct 2015 21:53:23 +0000	[thread overview]
Message-ID: <86h9lcou5o.fsf@gmail.com> (raw)
In-Reply-To: <874mkjadqx.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

On Thu 22 Oct 2015, martin rudalics wrote:

>> This patch fixes the problem for me under Windows.  Many thanks to Andy
>> Moreton!  Since Andy reports that negative X offsets also happen under
>> the X Window system, should this also be fixed in function
>> x_calc_absolute_position in src/term.c?
>
> Thanks for testing, Francis.  AFAICT nobody reported a similar problem
> on X so far.  So Andy please resend us your patch as attachment and
> provide some suitable ChangeLog entry and I will install it (unless you
> can already do that yourself).
>
> Thanks, martin

Hopefully this reply includes a suiteably formatted patch.

    AndyM


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: multimon patch --]
[-- Type: text/x-patch, Size: 2273 bytes --]

From 7aa74f58b14061493dda5a23256eaf4e4af405c4 Mon Sep 17 00:00:00 2001
From: Andy Moreton <andrewjmoreton@gmail.com>
Date: Tue, 27 Oct 2015 21:47:06 +0000
Subject: [PATCH] Fix frame position with multiple monitors (Bug#21173)

* src/w32term.c (x_calc_absolute_position): Find display origin to
allow for negative coordinates.
---
 src/w32term.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/w32term.c b/src/w32term.c
index 831786726792..fb4135830708 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 (FRAME_X_DISPLAY (f));
+      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));
-- 
2.5.3


  reply	other threads:[~2015-10-27 21:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-01  3:28 bug#21173: 25.0.50; New frames positioned off screen with multiple monitors Francis Litterio
2015-08-01 10:51 ` martin rudalics
2015-08-01 15:03   ` Francis Litterio
2015-08-01 15:49     ` martin rudalics
2015-08-01 16:59       ` Francis Litterio
2015-08-03  6:47         ` martin rudalics
2015-08-03 20:35           ` Andy Moreton
2015-08-03 21:12           ` Glenn Morris
2015-08-04 16:31             ` Fran Litterio
2015-09-08 22:26               ` Andy Moreton
2015-10-06  7:57                 ` martin rudalics
2015-10-07 16:50                   ` Fran
2015-10-21 18:57                   ` Francis Litterio
2015-10-21 23:37                     ` Andy Moreton
2015-10-22  6:39                     ` martin rudalics
2015-10-27 21:53                       ` Andy Moreton [this message]
2015-10-28  9:55                         ` martin rudalics
2015-10-28 14:13                           ` Andy Moreton
2015-10-28 15:52                             ` Eli Zaretskii
2015-10-28 17:25                               ` Andy Moreton
2015-10-28 18:08                                 ` Eli Zaretskii
2015-10-28 19:21                             ` martin rudalics
2015-10-28 19:39                               ` Andy Moreton
2015-10-29  7:57                                 ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86h9lcou5o.fsf@gmail.com \
    --to=andrewjmoreton@gmail.com \
    --cc=21173@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).