Gtk4: close popovers


I’m facing weird issues with gtk4: popovers don’t automatically close when the keyboard focus moves out of the popup or its parents, like it did in gtk3.

Is there a way to force closing all popovers programmatically?

Also, one more technical question: in gtk4 we must subclass Gtk.Widget and call popover.present() in size_allocate by ourselves to display popovers.
Wouldn’t it have been better to have a generic management in GtkWidget directly, letting it maintain a list of attached popovers we could add with e.g. gtk_widget_attach_popover(), so GtkWidget could automatically present them and also close them on focus change?

GtkWidget cannot do this automatically, otherwise we would have done it already.

Widgets have to explicitly add a popover to their list of children, and have to ensure that the geometry of the popover gets updated at the right time; otherwise you’d be able to add random popovers to random widgets, which is not something that is expected to happen.

Makes sense, thanks!
People would do horrific things it it was allowed…

About the problem of Popovers not closing, is there a technical limitation in gtk4 that explains why it doesn’t work like gtk3?
For context, I see that issue on X11 and Win32 (could not test on Wayland…)