From: Martin Rudalics Date: Thu, 27 Feb 2014 19:22:10 +0000 (+0100) Subject: More fixes for mouse glyph calculations (Bug#16647). X-Git-Tag: emacs-24.3.90~357^2~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=653b6ea317969d0e78f13e7e84e970c4032a298a;p=emacs.git More fixes for mouse glyph calculations (Bug#16647). More fixes for mouse glyph calculations (Bug#16647). * window.c (coordinates_in_window): In intersection of horizontal and vertical window dividers prefer the horizontal one. Add some extra parens to last fix. (window_relative_x_coord): Return x-coordinate for header and mode line too. * xdisp.c (remember_mouse_glyph): In text area don't extend glyph into mode line to show the vertical drag cursor there immediately. Subdivide mouse glyphs in right fringes to show a horizontal drag cursor as soon as we enter the "grabbable width" portion. Handle vertical border case separately. Do not subdivide window divider areas. (note_mouse_highlight): On bottom divider of bottommost windows show vertical drag cursor only when the minibuffer window can be resized. --- diff --git a/src/ChangeLog b/src/ChangeLog index 5850431cf93..9ec638374f5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2014-02-27 Martin Rudalics + + More fixes for mouse glyph calculations (Bug#16647). + * window.c (coordinates_in_window): In intersection of + horizontal and vertical window dividers prefer the horizontal + one. Add some extra parens to last fix. + (window_relative_x_coord): Return x-coordinate for header and + mode line too. + * xdisp.c (remember_mouse_glyph): In text area don't extend + glyph into mode line to show the vertical drag cursor there + immediately. Subdivide mouse glyphs in right fringes to show a + horizontal drag cursor as soon as we enter the "grabbable width" + portion. Handle vertical border case separately. Do not + subdivide window divider areas. + (note_mouse_highlight): On bottom divider of bottommost windows + show vertical drag cursor only when the minibuffer window can be + resized. + 2014-02-27 Eli Zaretskii * xdisp.c (pop_it): Restore the it->face_box_p flag which could be diff --git a/src/window.c b/src/window.c index 2fb0dcaadaa..b2a6ff4ff2d 100644 --- a/src/window.c +++ b/src/window.c @@ -1266,18 +1266,18 @@ coordinates_in_window (register struct window *w, int x, int y) if (y < top_y || y >= bottom_y || x < left_x || x >= right_x) return ON_NOTHING; - /* On vertical window divider (which prevails horizontal - dividers)? */ - if (!WINDOW_RIGHTMOST_P (w) - && WINDOW_RIGHT_DIVIDER_WIDTH (w) > 0 - && x >= right_x - WINDOW_RIGHT_DIVIDER_WIDTH (w) - && x <= right_x) - return ON_RIGHT_DIVIDER; - /* On the horizontal window divider? */ - else if (WINDOW_BOTTOM_DIVIDER_WIDTH (w) > 0 - && y >= (bottom_y - WINDOW_BOTTOM_DIVIDER_WIDTH (w)) - && y <= bottom_y) + /* On the horizontal window divider (which prevails the vertical + divider)? */ + if (WINDOW_BOTTOM_DIVIDER_WIDTH (w) > 0 + && y >= (bottom_y - WINDOW_BOTTOM_DIVIDER_WIDTH (w)) + && y <= bottom_y) return ON_BOTTOM_DIVIDER; + /* On vertical window divider? */ + else if (!WINDOW_RIGHTMOST_P (w) + && WINDOW_RIGHT_DIVIDER_WIDTH (w) > 0 + && x >= right_x - WINDOW_RIGHT_DIVIDER_WIDTH (w) + && x <= right_x) + return ON_RIGHT_DIVIDER; /* On the mode or header line? */ else if ((WINDOW_WANTS_MODELINE_P (w) && y >= (bottom_y @@ -1295,12 +1295,12 @@ coordinates_in_window (register struct window *w, int x, int y) bars. Note: If scrollbars are on the left, the window that must be eventually resized is that on the left of WINDOW. */ if ((WINDOW_RIGHT_DIVIDER_WIDTH (w) == 0) - && (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) - && !WINDOW_LEFTMOST_P (w) - && eabs (x - left_x) < grabbable_width) - || (!WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) - && !WINDOW_RIGHTMOST_P (w) - && eabs (x - right_x) < grabbable_width)) + && ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) + && !WINDOW_LEFTMOST_P (w) + && eabs (x - left_x) < grabbable_width) + || (!WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) + && !WINDOW_RIGHTMOST_P (w) + && eabs (x - right_x) < grabbable_width))) return ON_VERTICAL_BORDER; else return part; @@ -1386,6 +1386,8 @@ window_relative_x_coord (struct window *w, enum window_part part, int x) case ON_TEXT: return x - window_box_left (w, TEXT_AREA); + case ON_HEADER_LINE: + case ON_MODE_LINE: case ON_LEFT_FRINGE: return x - left_x; diff --git a/src/xdisp.c b/src/xdisp.c index 203fd303c4a..33c99cd596b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -2419,7 +2419,13 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) } if (part != ON_MODE_LINE && part != ON_HEADER_LINE) - gx += window_box_left_offset (w, area); + { + gx += window_box_left_offset (w, area); + /* Don't expand over the modeline to make sure the vertical + drag cursor is shown early enough. */ + height = min (height, + max (0, WINDOW_BOX_HEIGHT_NO_MODE_LINE (w) - gy)); + } } else { @@ -2427,6 +2433,10 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) gx = (x / width) * width; y -= gy; gy += (y / height) * height; + if (part != ON_MODE_LINE && part != ON_HEADER_LINE) + /* See comment above. */ + height = min (height, + max (0, WINDOW_BOX_HEIGHT_NO_MODE_LINE (w) - gy)); } break; @@ -2441,7 +2451,22 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) gx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) ? window_box_right_offset (w, RIGHT_MARGIN_AREA) : window_box_right_offset (w, TEXT_AREA)); - width = WINDOW_RIGHT_FRINGE_WIDTH (w); + if (WINDOW_RIGHT_DIVIDER_WIDTH (w) == 0 + && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w) + && !WINDOW_RIGHTMOST_P (w)) + if (gx < WINDOW_PIXEL_WIDTH (w) - width) + /* Make sure the vertical border can get her own glyph to the + right of the one we build here. */ + width = WINDOW_RIGHT_FRINGE_WIDTH (w) - width; + else + width = WINDOW_PIXEL_WIDTH (w) - gx; + else + width = WINDOW_RIGHT_FRINGE_WIDTH (w); + + goto row_glyph; + + case ON_VERTICAL_BORDER: + gx = WINDOW_PIXEL_WIDTH (w) - width; goto row_glyph; case ON_SCROLL_BAR: @@ -2452,16 +2477,6 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) ? WINDOW_RIGHT_FRINGE_WIDTH (w) : 0))); width = WINDOW_SCROLL_BAR_AREA_WIDTH (w); - goto row_glyph; - - case ON_RIGHT_DIVIDER: - gx = WINDOW_RIGHT_PIXEL_EDGE (w) - WINDOW_RIGHT_DIVIDER_WIDTH (w); - width = WINDOW_RIGHT_DIVIDER_WIDTH (w); - goto row_glyph; - - case ON_BOTTOM_DIVIDER: - gx = 0; - width = WINDOW_RIGHT_PIXEL_EDGE (w) - WINDOW_RIGHT_DIVIDER_WIDTH (w); row_glyph: gr = 0, gy = 0; @@ -2482,6 +2497,21 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) } break; + case ON_RIGHT_DIVIDER: + gx = WINDOW_PIXEL_WIDTH (w) - WINDOW_RIGHT_DIVIDER_WIDTH (w); + width = WINDOW_RIGHT_DIVIDER_WIDTH (w); + gy = 0; + /* The bottom divider prevails. */ + height = WINDOW_PIXEL_HEIGHT (w) - WINDOW_BOTTOM_DIVIDER_WIDTH (w); + goto add_edge;; + + case ON_BOTTOM_DIVIDER: + gx = 0; + width = WINDOW_PIXEL_WIDTH (w); + gy = WINDOW_PIXEL_HEIGHT (w) - WINDOW_BOTTOM_DIVIDER_WIDTH (w); + height = WINDOW_BOTTOM_DIVIDER_WIDTH (w); + goto add_edge; + default: ; virtual_glyph: @@ -2502,6 +2532,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) goto store_rect; } + add_edge: gx += WINDOW_LEFT_EDGE_X (w); gy += WINDOW_TOP_EDGE_Y (w); @@ -28682,10 +28713,15 @@ note_mouse_highlight (struct frame *f, int x, int y) help_echo_string = build_string ("drag-mouse-1: resize"); } else if (part == ON_BOTTOM_DIVIDER) - { - cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor; - help_echo_string = build_string ("drag-mouse-1: resize"); - } + if (! WINDOW_BOTTOMMOST_P (w) + || minibuf_level + || NILP (Vresize_mini_windows)) + { + cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor; + help_echo_string = build_string ("drag-mouse-1: resize"); + } + else + cursor = FRAME_X_OUTPUT (f)->nontext_cursor; else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE || part == ON_SCROLL_BAR) cursor = FRAME_X_OUTPUT (f)->nontext_cursor;