Function: frame-first-window

frame-first-window is a function defined in window.c.

Signature

(frame-first-window &optional FRAME-OR-WINDOW)

Documentation

Return the topmost, leftmost live window on FRAME-OR-WINDOW.

If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. Else if FRAME-OR-WINDOW denotes a valid window, return the first window of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return the first window of that frame.

View in manual

Probably introduced at or before Emacs version 19.23.

Source Code

// Defined in /usr/src/emacs/src/window.c
{
  Lisp_Object window;

  if (NILP (frame_or_window))
    window = SELECTED_FRAME ()->root_window;
  else if (WINDOW_VALID_P (frame_or_window))
    window = XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window)))->root_window;
  else
    {
      CHECK_LIVE_FRAME (frame_or_window);
      window = XFRAME (frame_or_window)->root_window;
    }

  while (WINDOWP (XWINDOW (window)->contents))
    window = XWINDOW (window)->contents;

  return window;
}