Commit dc95cb8c authored by Andy Moreton's avatar Andy Moreton Committed by Martin Rudalics
Browse files

Handle negative coordinates in ‘x_calc_absolute_position’

* src/w32term.c (x_calc_absolute_position): Find display origin to
allow for negative coordinates.
parent d7a67c5a
......@@ -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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment