Change the focus of Gtk windows

I have two overlapping Gtk-windows open. How can I change the focus via button clicking to get the hidden Gtk-window on top?
Any advice would be very welcome.

Carsten

Focus is decided by the window manager → Just click on the window?

Of course I can change the focus e.g. via +Tab (Windows10) or it is possible to get information from the statusbar and then select the wanted window.
However I want to change the active Gtk window via button action. Especially when the second window is hidden by a larger one.
Nevertheless thank you for your quick reply

There are some functions in Gtk to interact with the WM, but it’s tricky. I never used it, but you could look into:

For gtk_window_present you have to do:

present(win::GtkWindow) 

There’s also grab_focus(w::GtkWidget) but that might be only for widgets inside windows.

1 Like

Thank you for reply. This was what I am looking for.

For grab_focus(w::GtkWidget) I did not found any information. What’s the use of it?

:+1:

Hi Carsten,
Have you managed to change the code programmatically?
None of the solutions work for me.

Is it possible to display a Gtk window without changing the current focus from where it is (say the input terminal/REPL) to the new window? Thanks.

Related: