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: Tue, 08 Sep 2015 23:26:41 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (windows-nt)

On Tue 04 Aug 2015, Fran Litterio wrote:

> Glenn Morris <rgm <at> gnu.org> writes:
>
>> BTW, if it's just the lack of two physical monitors that's stopping
>> anyone working on such things, note that you can simulate such a setup
>> in software. Eg something like
>> 
>> Xephyr +xinerama -screen 800x600 -origin 800,0 -screen 800x600 :1 &
>> DISPLAY=:1.0 gnome-session            # or whatever you prefer
>
> Interesting, thanks.  If frame 'left parameters are always
> non-negative under X, then this problem only happens on Windows,
> because the root cause is a failure to account for negative
> 'left values in certain monitor arrangements.
>
> Does anyone with multiple monitors and X see negative 'left
> parameters for frames on the leftmost monitor?

Yes. Arranging the monitors like this, so the desktop extends to both
monitors:

  +----------+
  |          |
  | DISPLAY2 |
  |          |+----------+
  +----------+|          |
              | DISPLAY1 |
              | (primary)|
              +----------+

  (display-monitor-attributes-list)
  ;; ==>
  '(((geometry 0 0 1920 1080)
     (workarea 0 0 1920 1050)
     (mm-size 677 381)
     (name . "\\\\.\\DISPLAY1")
     (frames ...))
    ((geometry -1680 -1050 1680 1050)
     (workarea -1680 -1050 1680 1050)
     (mm-size 593 370)
     (name . "\\\\.\\DISPLAY2")
     (frames ...)))

  ;; For a frame on DISPLAY2:
  (frame-parameter (window-frame) 'left) ;; ==>  (+ -1668)
  (frame-parameter (window-frame) 'top)  ;; ==>  (+ -1046)

The patch below fixes the problem for me on a Mingw64 build, and creates
frames at the correct position.  Please try it and report the results.

(Copyright papers are not yet on file, but I mailed them today).

diff --git a/src/w32term.c b/src/w32term.c
index 82b05bffffec..ac55c6f73d32 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -5931,16 +5931,48 @@ x_calc_absolute_position (struct frame *f)
       top_bottom_borders_height = 32;
     }
 
+  /* If the desktop extends to multiple monitors then monitors to
+     the left of (or above) the primary monitor may use negative
+     coordinates.  Find the X and Y offsets of the display origin.  */
+  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));








reply via email to

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