Skip to content

Commit ebfdc5d

Browse files
committed
xapp-status-icon.c (wayland): Unrealize the menu before each
layer-shell popup. GtkMenu normally re-uses its toplevel GdkWindow. But using gtk-layer-shell this leaves a stale grab state, so subsequent attempts to show the menu immediately get dismissed. Unrealizing menu each time forces it to set up a clean state each time.
1 parent f2cd3c2 commit ebfdc5d

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎libxapp/xapp-status-icon.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,17 @@ popup_menu (XAppStatusIcon *self,
473473
* the menu's internal toplevel is realized below. */
474474
use_layer_shell = should_use_layer_shell ();
475475
DEBUG ("Using gtk-layer-shell for popup: %s", use_layer_shell ? "Yes" : "No");
476+
477+
/* Under gtk-layer-shell the menu's xdg_popup is parented to a throwaway
478+
* layer-shell host surface that we rebuild for each popup. Reusing the
479+
* menu's already-realized toplevel across popups leaves stale grab state
480+
* behind. Unrealizing first forces a fresh toplevel every time which
481+
* sidesteps the stale state. */
482+
if (use_layer_shell && gtk_widget_get_realized (GTK_WIDGET (menu)))
483+
{
484+
gtk_widget_unrealize (gtk_widget_get_toplevel (GTK_WIDGET (menu)));
485+
gtk_widget_unrealize (GTK_WIDGET (menu));
486+
}
476487
#endif
477488

478489
if (!gtk_widget_get_realized (GTK_WIDGET (menu)))

0 commit comments

Comments
 (0)