Receiving clicks without focus

Question: Is it possible in GTK to respond to click events on buttons without moving focus onto the application window?

Context: I am working on a generic on-screen keyboard for Wayland based window managers in Linux. It is easily to register a virtual input device using Linux’s /dev/uinput interface, but the problem is that clicking on a button in the UI moves focus onto the keyboard application’s window. This means the key event is routed to the keyboard application instead of the application I am trying to type into.

Thank you!

This is the GNOME Discourse; I assume you copied-and-pasted “Qt” in there, when you wanted to ask about GTK.

In any case, the answer is: “it depends”.

Pointer events are different from key focus; window managers can deliver pointer events to windows without necessarily giving them focus—the “focus on click” model, as opposed to the “focus follows mouse” one. For instance, if you have two windows side by side, you can scroll on the unfocused window without focusing it; of course, if you click, the window manager will move focus to the window.

On X11 you can ask the window manager never to focus your top level window—though you’ll likely need to use an override-redirect surface, and manage it yourself. I’m not sure Wayland has the same concept.

In general, though, this is a question better asked on a Wayland user/development support forum.

Haha, yes, I was also asking the same question of a Qt group since I’m playing with both.

Thank you! This gives me enough direction to pour through the Wayland/GTK documentation a bit more to find a solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.