>From 7aa74f58b14061493dda5a23256eaf4e4af405c4 Mon Sep 17 00:00:00 2001 From: Andy Moreton 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