frame-selected-window

frame-selected-window is a built-in function in `C source code'.

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

Return the selected window of 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 selected
window of that window's frame. If FRAME-OR-WINDOW denotes a live frame,
return the selected window of that frame.