musjj
(Musjj)
December 12, 2025, 9:58pm
1
Is there a way to create a callback that will be called every time the active window changes, passing in information like class, title, etc.? I can find the current active window like this:
global.get_window_actors().find(x => x.get_meta_window().has_focus())
But I would like an event-based API to avoid having to call this repeatedly in a hot loop. Does such API exists?
fmuellner
(Florian Müllner)
December 13, 2025, 2:05am
2
That’s unnecessarily complicated. MetaDisplay has a focus-window property that you can use directly. You can use the notify signal to monitor changes:
global.display.connect('notify::focus-window',
() => console.log(`Focus changed to ${global.display.focus_window}`));
1 Like
musjj
(Musjj)
December 13, 2025, 11:41am
3
fmuellner:
MetaDisplay
Thank you! Where can I find documentation about this? I can’t find them anywhere.
jrahmatzadeh
(Javad Rahmatzadeh)
December 13, 2025, 12:05pm
4
1 Like