Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions lib/extension/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -2375,30 +2375,26 @@ export class WindowManager extends GObject.Object {
}

/**
* Get the Meta.Window at the pointer coordinates
* Get the Meta.Window that receives the pointer at the given coordinates
*
* Picks the stage instead of comparing frame rects, so that hidden windows and input regions
* are honoured: a click-through overlay, such as the full-screen override-redirect window of
* Gromit-MPX, no longer hides the window under it (which made focus on hover stop working for
* as long as the overlay existed).
*
* @param {[number, number]} pointer x and y coordinates
* @returns null if no window is found, otherwise the Meta.Window
*/
_getMetaWindowAtPointer(pointer) {
const windows = global.get_window_actors();
const [x, y] = pointer;

// Iterate through the windows in reverse order to get the top-most window
for (let i = windows.length - 1; i >= 0; i--) {
let window = windows[i];
let metaWindow = window.meta_window;

let { x: wx, y: wy, width, height } = metaWindow.get_frame_rect();

// Check if the position is within the window bounds
if (x >= wx && x <= wx + width && y >= wy && y <= wy + height) {
return metaWindow;
}
}

// No window found at the pointer
return null;
let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
while (actor && !(actor instanceof Meta.WindowActor)) actor = actor.get_parent();

const metaWindow = actor?.meta_window;
// Override-redirect windows (menus, tooltips, a drawing overlay) can't take focus; keep the
// current focus while the pointer is over one, as over the shell's own UI
if (!metaWindow || metaWindow.is_override_redirect()) return null;
return metaWindow;
}

/**
Expand Down