Function: coordinates-in-window-p
coordinates-in-window-p is a function defined in window.c.
Signature
(coordinates-in-window-p COORDINATES WINDOW)
Documentation
Return non-nil if COORDINATES are in WINDOW.
WINDOW must be a live window and defaults to the selected one.
COORDINATES is a cons of the form (X . Y), X and Y being distances
measured in characters from the upper-left corner of the frame.
(0 . 0) denotes the character in the upper left corner of the
frame.
If COORDINATES are in the text portion of WINDOW,
the coordinates relative to the window are returned.
If they are in the bottom divider of WINDOW, bottom-divider is returned.
If they are in the right divider of WINDOW, right-divider is returned.
If they are in the mode line of WINDOW, mode-line is returned.
If they are in the header line of WINDOW, header-line is returned.
If they are in the tab line of WINDOW, tab-line is returned.
If they are in the left fringe of WINDOW, left-fringe is returned.
If they are in the right fringe of WINDOW, right-fringe is returned.
If they are on the border between WINDOW and its right sibling,
vertical-line is returned.
If they are in the windows's left or right marginal areas, left-margin
or right-margin is returned.
Probably introduced at or before Emacs version 21.1.
Source Code
// Defined in /usr/src/emacs/src/window.c
{
struct window *w;
struct frame *f;
int x, y;
Lisp_Object lx, ly;
w = decode_live_window (window);
f = XFRAME (w->frame);
CHECK_CONS (coordinates);
lx = Fcar (coordinates);
ly = Fcdr (coordinates);
CHECK_NUMBER (lx);
CHECK_NUMBER (ly);
x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f);
y = FRAME_PIXEL_Y_FROM_CANON_Y (f, ly) + FRAME_INTERNAL_BORDER_WIDTH (f);
switch (coordinates_in_window (w, x, y))
{
case ON_NOTHING:
return Qnil;
case ON_TEXT:
/* Convert X and Y to window relative pixel coordinates, and
return the canonical char units. */
x -= window_box_left (w, TEXT_AREA);
y -= WINDOW_TOP_EDGE_Y (w);
return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f, x),
FRAME_CANON_Y_FROM_PIXEL_Y (f, y));
case ON_MODE_LINE:
return Qmode_line;
case ON_VERTICAL_BORDER:
return Qvertical_line;
case ON_HEADER_LINE:
return Qheader_line;
case ON_TAB_LINE:
return Qtab_line;
case ON_LEFT_FRINGE:
return Qleft_fringe;
case ON_RIGHT_FRINGE:
return Qright_fringe;
case ON_LEFT_MARGIN:
return Qleft_margin;
case ON_RIGHT_MARGIN:
return Qright_margin;
case ON_VERTICAL_SCROLL_BAR:
/* Historically we are supposed to return nil in this case. */
return Qnil;
case ON_HORIZONTAL_SCROLL_BAR:
return Qnil;
case ON_RIGHT_DIVIDER:
return Qright_divider;
case ON_BOTTOM_DIVIDER:
return Qbottom_divider;
default:
emacs_abort ();
}
}