personal, technical, gnustep, gsoc
16:05 -0400
Recent window managers have a feature called “focus stealing prevention”, which
is wonderful in theory. But in practice… well, do a Google search, and see
how many people don’t like it. The problem is that it’s a whole bunch of
guesswork, and so it may cause problems when it guesses wrong.
Take, for example, GNUstep applications. GNUstep applications have their menu
in a separate window (like on MacOS X), and the menu disappears when the
application is inactive. If the application has no other windows, then it
tries to give focus to the menu. But then focus stealing prevention kicks in
and takes away the focus. The application then detects that it lost focus,
deactivates itself, and hides the main menu, making it hard to interact further
with the application.
That was the cause for one of the
window focusing issues that I
was looking at for my GSoC project.
So how do you steal focus and get away with it? Simple: ask nicely first,
before you steal. The EWMH spec has an atom called
_NET_ACTIVE_WINDOW,
which allows windows to request focus. It turns out, if I use that, then steal
focus, then the window manager will let me.
However, KWin/KDE (or at least some versions of it)
needs a bit more coercing, and we need to set
_NET_USER_TIME.
The final solution: