Commit 7442878f authored by Gerd Moellmann's avatar Gerd Moellmann
Browse files

(enum window_part): New enumeration.

(Qleft_fringe, Qright_fringe): Replace Qleft_bitmap_area and
Qright_bitmap_area.
(coordinates_in_window): Return an enumerator from enum
window_part.  Fix handling of right scroll bar.
(Fcoordinates_in_window_p): Doc fix.  Return `left-fringe' and
`right-fringe' instead of `left-bitmap-area' and
`right-bitmap-area'.  Use enumerators from enum window_part
instead of hard-coded integers.
(check_window_containing, window_from_coordinates): Use
enumerators from enum window_part instead of hard-coded integers.
(syms_of_window): Replace Qleft_bitmap_area and
Qright_bitmap_area.with Qleft_fringe and Qright_fringe.
parent 1f922834
2001-01-31 Gerd Moellmann <gerd@gnu.org>
* frame.h (FRAME_RIGHT_SCROLL_BAR_WIDTH): New define.
* window.c (enum window_part): New enumeration.
(Qleft_fringe, Qright_fringe): Replace Qleft_bitmap_area and
Qright_bitmap_area.
(coordinates_in_window): Return an enumerator from enum
window_part. Fix handling of right scroll bar.
(Fcoordinates_in_window_p): Doc fix. Return `left-fringe' and
`right-fringe' instead of `left-bitmap-area' and
`right-bitmap-area'. Use enumerators from enum window_part
instead of hard-coded integers.
(check_window_containing, window_from_coordinates): Use
enumerators from enum window_part instead of hard-coded integers.
(syms_of_window): Replace Qleft_bitmap_area and
Qright_bitmap_area.with Qleft_fringe and Qright_fringe.
2001-01-31 Eli Zaretskii <eliz@is.elta.co.il> 2001-01-31 Eli Zaretskii <eliz@is.elta.co.il>
* editfns.c (Fformat_time_string): Doc fix. * editfns.c (Fformat_time_string): Doc fix.
......
...@@ -51,9 +51,22 @@ Boston, MA 02111-1307, USA. */ ...@@ -51,9 +51,22 @@ Boston, MA 02111-1307, USA. */
#define max(a, b) ((a) < (b) ? (b) : (a)) #define max(a, b) ((a) < (b) ? (b) : (a))
#endif #endif
/* Values returned from coordinates_in_window. */
enum window_part
{
ON_NOTHING,
ON_TEXT,
ON_MODE_LINE,
ON_VERTICAL_BORDER,
ON_HEADER_LINE,
ON_LEFT_FRINGE,
ON_RIGHT_FRINGE
};
Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
Lisp_Object Qwindow_size_fixed, Qleft_bitmap_area, Qright_bitmap_area; Lisp_Object Qwindow_size_fixed, Qleft_fringe, Qright_fringe;
extern Lisp_Object Qheight, Qwidth; extern Lisp_Object Qheight, Qwidth;
static struct window *decode_window P_ ((Lisp_Object)); static struct window *decode_window P_ ((Lisp_Object));
...@@ -499,20 +512,17 @@ and BOTTOM is one more than the bottommost row used by WINDOW\n\ ...@@ -499,20 +512,17 @@ and BOTTOM is one more than the bottommost row used by WINDOW\n\
X and Y are frame relative pixel coordinates. */ X and Y are frame relative pixel coordinates. */
static int static enum window_part
coordinates_in_window (w, x, y) coordinates_in_window (w, x, y)
register struct window *w; register struct window *w;
register int *x, *y; register int *x, *y;
{ {
/* 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,
ON_HEADER_LINE, ON_LEFT_FRINGE, ON_RIGHT_FRINGE};
struct frame *f = XFRAME (WINDOW_FRAME (w)); struct frame *f = XFRAME (WINDOW_FRAME (w));
int left_x, right_x, top_y, bottom_y; int left_x, right_x, top_y, bottom_y;
int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f); int flags_area_width = FRAME_LEFT_FLAGS_AREA_WIDTH (f);
int part; enum window_part part;
int ux = CANON_X_UNIT (f), uy = CANON_Y_UNIT (f); int ux = CANON_X_UNIT (f), uy = CANON_Y_UNIT (f);
int x0 = XFASTINT (w->left) * ux; int x0 = XFASTINT (w->left) * ux;
int x1 = x0 + XFASTINT (w->width) * ux; int x1 = x0 + XFASTINT (w->width) * ux;
...@@ -583,7 +593,9 @@ coordinates_in_window (w, x, y) ...@@ -583,7 +593,9 @@ coordinates_in_window (w, x, 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) * ux)
|| *x > right_x + flags_area_width) || *x > (right_x
+ flags_area_width
+ FRAME_RIGHT_SCROLL_BAR_WIDTH (f) * ux))
{ {
part = ON_NOTHING; part = ON_NOTHING;
} }
...@@ -654,15 +666,15 @@ DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, ...@@ -654,15 +666,15 @@ DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
"Return non-nil if COORDINATES are in WINDOW.\n\ "Return non-nil if COORDINATES are in WINDOW.\n\
COORDINATES is a cons of the form (X . Y), X and Y being distances\n\ COORDINATES is a cons of the form (X . Y), X and Y being distances\n\
measured in characters from the upper-left corner of the frame.\n\ measured in characters from the upper-left corner of the frame.\n\
(0 . 0) denotes the character in the upper left corner of the\n\ \(0 . 0) denotes the character in the upper left corner of the\n\
frame.\n\ frame.\n\
If COORDINATES are in the text portion of WINDOW,\n\ If COORDINATES are in the text portion of WINDOW,\n\
the coordinates relative to the window are returned.\n\ the coordinates relative to the window are returned.\n\
If they are in the mode line of WINDOW, `mode-line' is returned.\n\ If they are in the mode line of WINDOW, `mode-line' is returned.\n\
If they are in the top mode line of WINDOW, `header-line' is returned.\n\ If they are in the top mode line of WINDOW, `header-line' is returned.\n\
If they are in the bitmap-area to the left of the window,\n\ If they are in the fringe to the left of the window,\n\
`left-bitmap-area' is returned, if they are in the area on the right of\n\ `left-fringe' is returned, if they are in the area on the right of\n\
the window, `right-bitmap-area' is returned.\n\ the window, `right-fringe' is returned.\n\
If they are on the border between WINDOW and its right sibling,\n\ If they are on the border between WINDOW and its right sibling,\n\
`vertical-line' is returned.") `vertical-line' is returned.")
(coordinates, window) (coordinates, window)
...@@ -686,30 +698,29 @@ If they are on the border between WINDOW and its right sibling,\n\ ...@@ -686,30 +698,29 @@ If they are on the border between WINDOW and its right sibling,\n\
switch (coordinates_in_window (w, &x, &y)) switch (coordinates_in_window (w, &x, &y))
{ {
case 0: /* NOT in window at all. */ case ON_NOTHING:
return Qnil; return Qnil;
case 1: /* In text part of window. */ case ON_TEXT:
/* X and Y are now window relative pixel coordinates. /* X and Y are now window relative pixel coordinates. Convert
Convert them to canonical char units before returning them to canonical char units before returning them. */
them. */
return Fcons (CANON_X_FROM_PIXEL_X (f, x), return Fcons (CANON_X_FROM_PIXEL_X (f, x),
CANON_Y_FROM_PIXEL_Y (f, y)); CANON_Y_FROM_PIXEL_Y (f, y));
case 2: /* In mode line of window. */ case ON_MODE_LINE:
return Qmode_line; return Qmode_line;
case 3: /* On right border of window. */ case ON_VERTICAL_BORDER:
return Qvertical_line; return Qvertical_line;
case 4: case ON_HEADER_LINE:
return Qheader_line; return Qheader_line;
case 5: case ON_LEFT_FRINGE:
return Qleft_bitmap_area; return Qleft_fringe;
case 6: case ON_RIGHT_FRINGE:
return Qright_bitmap_area; return Qright_fringe;
default: default:
abort (); abort ();
...@@ -738,16 +749,18 @@ check_window_containing (w, user_data) ...@@ -738,16 +749,18 @@ check_window_containing (w, user_data)
void *user_data; void *user_data;
{ {
struct check_window_data *cw = (struct check_window_data *) user_data; struct check_window_data *cw = (struct check_window_data *) user_data;
int found; enum window_part found;
int continue_p = 1;
found = coordinates_in_window (w, cw->x, cw->y); found = coordinates_in_window (w, cw->x, cw->y);
if (found) if (found != ON_NOTHING)
{ {
*cw->part = found - 1; *cw->part = found - 1;
XSETWINDOW (*cw->window, w); XSETWINDOW (*cw->window, w);
continue_p = 0;
} }
return !found; return continue_p;
} }
...@@ -787,7 +800,8 @@ window_from_coordinates (f, x, y, part, tool_bar_p) ...@@ -787,7 +800,8 @@ window_from_coordinates (f, x, y, part, tool_bar_p)
&& tool_bar_p && tool_bar_p
&& WINDOWP (f->tool_bar_window) && WINDOWP (f->tool_bar_window)
&& XINT (XWINDOW (f->tool_bar_window)->height) > 0 && XINT (XWINDOW (f->tool_bar_window)->height) > 0
&& coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y)) && (coordinates_in_window (XWINDOW (f->tool_bar_window), &x, &y)
!= ON_NOTHING))
{ {
*part = 0; *part = 0;
window = f->tool_bar_window; window = f->tool_bar_window;
...@@ -5631,10 +5645,10 @@ init_window () ...@@ -5631,10 +5645,10 @@ init_window ()
void void
syms_of_window () syms_of_window ()
{ {
Qleft_bitmap_area = intern ("left-bitmap-area"); Qleft_fringe = intern ("left-fringe");
staticpro (&Qleft_bitmap_area); staticpro (&Qleft_fringe);
Qright_bitmap_area = intern ("right-bitmap-area"); Qright_fringe = intern ("right-fringe");
staticpro (&Qright_bitmap_area); staticpro (&Qright_fringe);
Qwindow_size_fixed = intern ("window-size-fixed"); Qwindow_size_fixed = intern ("window-size-fixed");
staticpro (&Qwindow_size_fixed); staticpro (&Qwindow_size_fixed);
......
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