I’m trying to understand the terminology around window focus and activation.
Is it possible for the window under the mouse pointer to be different from the window that currently has keyboard focus? I’m trying to understand the terminology around window focus and activation.
What is the exact difference between a window being focused and being active?
Also, is it possible for the window under the mouse pointer to be different from the window that currently has keyboard focus?
If this situation is possible, how can I determine:
Which window currently has keyboard focus?
The goal is to visually distinguish between:
the window that currently receives keyboard input
the window that currently has the mouse/pointer
potentially a window that is considered active by GNOME Shell
What is the exact difference between a window being focused and being active?
A window is focused if it has the keyboard focus.
“active” isn’t really a term that is used in the mutter/gnome-shell code bases, however “activate” is the action of requesting a window to become the new focus window.
Also, is it possible for the window under the mouse pointer to be different from the window that currently has keyboard focus?
Yes. There is a (hidden) setting to have the keyboard focus follow the mouse, but by default the focus is only moved when clicking inside a window (or explicitly moving the focus with alt+tab etc.).
how can I determine:
?
Which window currently has keyboard focus?
It is exposed as property on the display: global.display.focus_window.
There isn’t anything similar for the hovered window, you’d have to implement that yourself.
(There is no need for the display server to track it, because mouse events have an associated position. They are simply delivered to the top-most window at that location. There is no such things for key events, therefore the need for “focus window”)