Gtk4 menus focus behavior and GDB debugging

Hello world,
still migrating my app from GTK3 to GTK4, I have an issue with the menus (Popover, PopoverMeunbar) in the new GTK4 API, and that is that I do not find a way to loose the focus (and exit the menu) by clicking outside the menu, in order to exit the menu it is mandatory to either:

  • Press ‘Esc’
  • Click on the top element of the menu to close it
  • Click on any other part of the Gtk window the menu belong to

And as long as I did not do one theses actions, the mouse focus will remains stuck in the menu, no way to even focus on another GTK window of the same program, or, and that is more the issue here, any other program running on the computer.
I must confess this was slightly annoying at first, but I got used to it until I needed to use debugging tools for menus action, hence the GDB in the title of my post … the result is that debugging menu action is, for me at that time, impossible because the focus remains locked on the menu and the debugger remains inaccessible … any way around this ?

Thanks in advance for your ideas :wink:

S.

I can’t observe this behaviour in my own program with a simple GtkMenuButton, no popover handling on my own. GTK has a demo with an example of a “traditional” menu: Is your app behaving different than “Application Class” in gtk4-demo?

I can’t reproduce either when using GNOME. It might help to provide:

  • Operating system, with version
  • Desktop environment or window manager, with version
  • Display protocol (X or Wayland)

Thank you all for your answers.
Here are few more informations:

  • The menus in my app behave exactly like in the gtk4-demo.
  • My OS: Fedora 34
  • Gnome: 40.5
  • Display: X11

By the way when I try to debug any menu action (try to put a breakpoint immediately after a menu callback,
something like:

G_MODULE_EXPORT void menu_callback (GSimpleAction * action, GVariant * parameter, gpointer data)
{
// Put a breakpoint here
}

Then the computer freezes, I think the menu behaviour I described above is the reason for that, and I need to go in text mode to kill the debugger and get my computer back.

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