Gtk4 and `set_keep_above` and other similar APIs that used to be tied to X11

I’ve been looking for a simple “how-to” make a widget always on top and also “transparent” to events. The idea is to make a video game “hud” like experience on the desktop. But I could not find anything useful. The closest I’ve got was this question that was replied with a simplistic “You can use platform-specific API, if you want to access that functionality.”

I want to do just that, but I was under the impression that “gnome” was a platform, and as such there should be some API, maybe in a different library, that supports the “window_keep_above” and requirements. My question is what API should I use?

The “keep above” API assumes the toolkit (and thus the application) have access to the window stacking order, which is the purview of the window manager. The window manager is responsible for presenting the user the choice of changing the stacking order, interactively. Having programmatic access to that would allow things like applications positioning transparent windows on top of everything and intercepting pointer events or key focus.

On X11, where you have access to the whole window stack, you can use Xlib and the EWMH. On Wayland, you simply don’t have access to that behaviour.

Well there exist a button that permits the window to be “always on top” on gnome. There must be a way to communicate to the window manager that this is my intention. And by the way I do want the window to be “transparent to events also”, letting all mouse and keyboard through.

By the way, thanks for the quick reply. :slight_smile:

The menu is managed by GNOME Shell, not by GTK. The toolkit isn’t involved at all.

That’s just something that can’t be done with Wayland without some sort of private protocol to talk to the compositor.