Function: window-at

window-at is a function defined in window.c.

Signature

(window-at X Y &optional FRAME)

Documentation

Return window containing coordinates X and Y on FRAME.

FRAME must be a live frame and defaults to the selected one. X and Y are measured in units of canonical columns and rows. The top left corner of the frame is considered to be column 0, row 0. Tool-bar and tab-bar pseudo-windows are ignored by this function: if the specified coordinates are in any of these two windows, this function returns nil.

View in manual

Source Code

// Defined in /usr/src/emacs/src/window.c
{
  struct frame *f = decode_live_frame (frame);

  CHECK_INTEGER (x);
  CHECK_INTEGER (y);

  if (XFIXNUM (x) < 0 || XFIXNUM (x) > FRAME_PIXEL_WIDTH (f)
      || XFIXNUM (y) < 0 || XFIXNUM (y) > FRAME_PIXEL_HEIGHT (f))
    return Qnil;

  CHECK_NUMBER (x);
  CHECK_NUMBER (y);

  return window_from_coordinates (f,
				  (FRAME_PIXEL_X_FROM_CANON_X (f, x)
				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
				  (FRAME_PIXEL_Y_FROM_CANON_Y (f, y)
				   + FRAME_INTERNAL_BORDER_WIDTH (f)),
				  0, false, false, false);
}