Change the focus of Gtk windows

package

#1

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


#2

Focus is decided by the window manager -> Just click on the window?


#3

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


#4

There are some functions in Gtk to interact with the WM, but it’s tricky. I never used it, but you could look into:
https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-present


#5

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.


#6

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?


#7

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-grab-focus


#8

:+1: