Any way to set window always on top programmatically?

hi,

disclaimer: I have no prior Gtk or Gnome development experience

I try to create (gtk4 rust bindings) app running on Gnome Wayland (targeting Ubuntu).

I know that currently there is currently no Wayland api supporting always on top (nor any gtk api supports it), however I see this option available even on my app’s toolbar to be set manually.

Is there any** (even hacky)** way to set it programmatically ?

No: there isn’t a programmatic way to manipulate the window stack, by design.

1 Like

Ok. Maybe there is any other api to make transparent overlay displaying text/image ?

What exact text/image would you put in this overlay if it was possible? Chances are that there are other solutions to your problem. Apps can’t put arbitrary content wherever they wish on the screen for security reasons.

however I see this option available even on my app’s toolbar

Either your app is using outdated APIs, or you’re referring to the header bar context menu, which is provided by the shell (not the app).

yeah I meant app’s header bar not toolbar and used wrong name - my mistake.
As I mentioned originally I am not into gnome/shell development at all.

My idea is to build app displaying pressed keys (something like showkey app). Looking for ideas how to display always on top semi-transparent overlay.

You’ll find more issues like this when building an app like that, because what you’re making is a keylogger. All I can really recommend is getting into GNOME Shell extension development.

I have no issues with reading keyboard events - just with painting overlay which is not supported by GNOME in any way as far as I can understand.

I feel a bit lost in my understanding what would be the correct way to handle it.

Is it that GNOME doesn’t allow certain types of apps by design ? Or it’s something GNOME community is still working on how to handle ? Any guidelines ?

I’ve done some research on GNOME Shell extension and found perfect example extension for my needs here: Kyle Robbertze / shortcuts-gnome-extension · GitLab

Thank you @monster for the tip!

Basically all I need is to display transparent overlay - I plan to feed it with pressed keys via DBus.
I am wondering what would be the best way to distribute such a hybrid solution (external app plus extension) ? Are there any existing examples of similar solution ? Or maybe it’s forbidden and extension should be self contained ?

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