Skip to content

popover: fix focus when inside an unfocused window

Nelson Ben requested to merge BUG_popover_focus_from_another_window_GTK4 into master

Fix popovers to properly gain focus when clicked inside an unfocused window.

We use the GTK_PHASE_CAPTURE of the 'pressed' event to early detect that the popover is being clicked inside an inactive window, this allow us to present the window (and be focused) before the normal signal handlers for the popover click/pressed events are run which would ultimately give focus to popover widget.

This fix works for both modal and 'non modal' popovers, although for GTK4 we only benefit from the 'non modal' case, as GTK4 (contrary to GTK3) hides the modal popovers when the focus is changed to another application's window, so it's only possible for a 'non modal' popover to be clicked inside an unfocused window.

Fixes issue #1871

Merge request reports