bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21173: 25.0.50; New frames positioned off screen with multiple monit


From: Andy Moreton
Subject: bug#21173: 25.0.50; New frames positioned off screen with multiple monitors
Date: Wed, 28 Oct 2015 19:39:28 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt)

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));








reply via email to

[Prev in Thread] Current Thread [Next in Thread]