Commit b0228ace authored by Gerd Moellmann's avatar Gerd Moellmann

(coordinates_in_window): Fix computation for

position on vertical line between mode lines.
parent c844a81a
2000-12-17 Gerd Moellmann <gerd@gnu.org> 2000-12-17 Gerd Moellmann <gerd@gnu.org>
* window.c (coordinates_in_window): Fix computation for
position on vertical line between mode lines.
* xfns.c (unwind_create_frame): Return t if frame was deleted. * xfns.c (unwind_create_frame): Return t if frame was deleted.
Don't alter tip_frame or tip_window. Don't alter tip_frame or tip_window.
(unwind_create_tip_frame): Set tip_frame to nil only if frame (unwind_create_tip_frame): Set tip_frame to nil only if frame
......
...@@ -497,21 +497,28 @@ coordinates_in_window (w, x, y) ...@@ -497,21 +497,28 @@ coordinates_in_window (w, x, y)
register struct window *w; register struct window *w;
register int *x, *y; register int *x, *y;
{ {
struct frame *f = XFRAME (WINDOW_FRAME (w));
int left_x, right_x, top_y, bottom_y;
int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f);
/* Let's make this a global enum later, instead of using numbers /* Let's make this a global enum later, instead of using numbers
everywhere. */ everywhere. */
enum {ON_NOTHING, ON_TEXT, ON_MODE_LINE, ON_VERTICAL_BORDER, enum {ON_NOTHING, ON_TEXT, ON_MODE_LINE, ON_VERTICAL_BORDER,
ON_HEADER_LINE, ON_LEFT_FRINGE, ON_RIGHT_FRINGE}; ON_HEADER_LINE, ON_LEFT_FRINGE, ON_RIGHT_FRINGE};
struct frame *f = XFRAME (WINDOW_FRAME (w));
int left_x, right_x, top_y, bottom_y;
int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f);
int part;
int ux = CANON_X_UNIT (f), uy = CANON_Y_UNIT (f);
int x0 = XFASTINT (w->left) * ux;
int x1 = x0 + XFASTINT (w->width) * ux;
if (*x < x0 || *x >= x1)
return ON_NOTHING;
/* In what's below, we subtract 1 when computing right_x because we /* In what's below, we subtract 1 when computing right_x because we
want the rightmost pixel, which is given by left_pixel+width-1. */ want the rightmost pixel, which is given by left_pixel+width-1. */
if (w->pseudo_window_p) if (w->pseudo_window_p)
{ {
left_x = 0; left_x = 0;
right_x = XFASTINT (w->width) * CANON_Y_UNIT (f) - 1; right_x = XFASTINT (w->width) * CANON_X_UNIT (f) - 1;
top_y = WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w); top_y = WINDOW_DISPLAY_TOP_EDGE_PIXEL_Y (w);
bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w); bottom_y = WINDOW_DISPLAY_BOTTOM_EDGE_PIXEL_Y (w);
} }
...@@ -530,50 +537,59 @@ coordinates_in_window (w, x, y) ...@@ -530,50 +537,59 @@ coordinates_in_window (w, x, y)
sibling, say it's on the vertical line. That's to be able sibling, say it's on the vertical line. That's to be able
to resize windows horizontally in case we're using toolkit to resize windows horizontally in case we're using toolkit
scroll bars. */ scroll bars. */
if (WINDOW_WANTS_MODELINE_P (w) if (WINDOW_WANTS_MODELINE_P (w)
&& *y < bottom_y && *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)
&& *y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)) && *y < bottom_y)
{ {
if (!WINDOW_RIGHTMOST_P (w) /* We're somewhere on the mode line. We consider the place
&& (abs (*x - ((XFASTINT (w->left) + XFASTINT (w->width)) between mode lines of horizontally adjacent mode lines
* CANON_X_UNIT (f))) as the vertical border. If scroll bars on the left,
< CANON_X_UNIT (f) / 2)) return the right window. */
return ON_VERTICAL_BORDER; part = ON_MODE_LINE;
return ON_MODE_LINE;
if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
{
if (abs (*x - x0) < ux / 2)
part = ON_VERTICAL_BORDER;
}
else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < ux / 2)
part = ON_VERTICAL_BORDER;
} }
else if (WINDOW_WANTS_HEADER_LINE_P (w)
if (WINDOW_WANTS_HEADER_LINE_P (w) && *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)
&& *y >= top_y && *y >= top_y)
&& *y < top_y + CURRENT_HEADER_LINE_HEIGHT (w))
{ {
if (!WINDOW_RIGHTMOST_P (w) part = ON_HEADER_LINE;
&& (abs (*x - ((XFASTINT (w->left) + XFASTINT (w->width))
* CANON_X_UNIT (f))) if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
< CANON_X_UNIT (f) / 2)) {
return ON_VERTICAL_BORDER; if (abs (*x - x0) < ux / 2)
return ON_HEADER_LINE; part = ON_VERTICAL_BORDER;
}
else if (!WINDOW_RIGHTMOST_P (w) && abs (*x - x1) < ux / 2)
part = ON_VERTICAL_BORDER;
} }
/* Outside anything interesting? */
/* Completely outside anything interesting? */ else if (*y < top_y
if (*y < top_y || *y >= bottom_y
|| *y >= bottom_y || *x < (left_x
|| *x < (left_x - flags_area_width
- flags_area_width - FRAME_LEFT_SCROLL_BAR_WIDTH (f) * ux)
- (FRAME_LEFT_SCROLL_BAR_WIDTH (f) || *x > right_x + flags_area_width)
* CANON_X_UNIT (f))) {
|| *x > right_x + flags_area_width) part = ON_NOTHING;
return ON_NOTHING; }
else if (FRAME_WINDOW_P (f))
if (FRAME_WINDOW_P (f))
{ {
if (!w->pseudo_window_p if (!w->pseudo_window_p
&& !FRAME_HAS_VERTICAL_SCROLL_BARS (f) && !FRAME_HAS_VERTICAL_SCROLL_BARS (f)
&& !WINDOW_RIGHTMOST_P (w) && !WINDOW_RIGHTMOST_P (w)
&& (abs (*x - right_x - flags_area_width) < CANON_X_UNIT (f) / 2)) && (abs (*x - right_x - flags_area_width) < ux / 2))
return ON_VERTICAL_BORDER; {
part = ON_VERTICAL_BORDER;
if (*x < left_x || *x > right_x) }
else if (*x < left_x || *x > right_x)
{ {
/* Other lines than the mode line don't include flags areas and /* Other lines than the mode line don't include flags areas and
scroll bars on the left. */ scroll bars on the left. */
...@@ -581,7 +597,13 @@ coordinates_in_window (w, x, y) ...@@ -581,7 +597,13 @@ coordinates_in_window (w, x, y)
/* Convert X and Y to window-relative pixel coordinates. */ /* Convert X and Y to window-relative pixel coordinates. */
*x -= left_x; *x -= left_x;
*y -= top_y; *y -= top_y;
return *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE; part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE;
}
else
{
*x -= left_x;
*y -= top_y;
part = ON_TEXT;
} }
} }
else else
...@@ -596,24 +618,30 @@ coordinates_in_window (w, x, y) ...@@ -596,24 +618,30 @@ coordinates_in_window (w, x, y)
/* Convert X and Y to window-relative pixel coordinates. */ /* Convert X and Y to window-relative pixel coordinates. */
*x -= left_x; *x -= left_x;
*y -= top_y; *y -= top_y;
return *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE; part = *x < left_x ? ON_LEFT_FRINGE : ON_RIGHT_FRINGE;
} }
/* Here, too, "*x > right_x" is because of character terminals. */ /* Here, too, "*x > right_x" is because of character terminals. */
if (!w->pseudo_window_p else if (!w->pseudo_window_p
&& !WINDOW_RIGHTMOST_P (w) && !WINDOW_RIGHTMOST_P (w)
&& *x > right_x - CANON_X_UNIT (f)) && *x > right_x - ux)
/* On the border on the right side of the window? Assume that {
this area begins at RIGHT_X minus a canonical char width. */ /* On the border on the right side of the window? Assume that
return ON_VERTICAL_BORDER; this area begins at RIGHT_X minus a canonical char width. */
part = ON_VERTICAL_BORDER;
}
else
{
/* Convert X and Y to window-relative pixel coordinates. */
*x -= left_x;
*y -= top_y;
part = ON_TEXT;
}
} }
/* Convert X and Y to window-relative pixel coordinates. */ return part;
*x -= left_x;
*y -= top_y;
return ON_TEXT;
} }
DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
Scoordinates_in_window_p, 2, 2, 0, Scoordinates_in_window_p, 2, 2, 0,
"Return non-nil if COORDINATES are in WINDOW.\n\ "Return non-nil if COORDINATES are in WINDOW.\n\
......
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