From: Andy Moreton Date: Thu, 29 Oct 2015 07:46:43 +0000 (+0100) Subject: Handle negative coordinates in ‘x_calc_absolute_position’ X-Git-Tag: emacs-25.0.90~983 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dc95cb8c2d646468186c5b379bd6d138c1ec1d1c;p=emacs.git Handle negative coordinates in ‘x_calc_absolute_position’ * src/w32term.c (x_calc_absolute_position): Find display origin to allow for negative coordinates. --- diff --git a/src/w32term.c b/src/w32term.c index 83178672679..f764e250aa8 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));