unresponsive with "_gtk_widget_captured_event: assertion 'WIDGET_REALIZED_FOR_EVENT (widget, event)' failed"
Submitted by Hin-Tak Leung
Link to original bug (#786683)
Description
See downstream bug report with analysis and backtrace:
https://bugzilla.redhat.com/show_bug.cgi?id=1435911
Once in a while, cut and paste into a terminal via right-click-paste results in the whole screen freezing and unresponsive. (mouse cursor still moves), until one does ctrl-alt-fN and kill the gnome-terminal-server in a vt.
The problem is traced down to gdk doing a gdk_seat_grab on null. Details below copied from https://bugzilla.redhat.com/show_bug.cgi?id=1435911#c9 and https://bugzilla.redhat.com/show_bug.cgi?id=1435911#c10
=== ...
#2 0x00007f068ac0a459 in gdk_seat_grab (seat=0x561764497280 [GdkSeatDefault], window=0x0, capabilities=GDK_SEAT_CAPABILITY_ALL, owner_events=1
, cursor=0x0, event=0x0, prepare_func=0x0, prepare_func_data=0x0) at gdkseat.c:302
#3 0x00007f068b0f634b in popup_grab_on_window (window=0x0, pointer=pointer@entry=0x5617644a9810 [GdkX11DeviceXI2]) at gtkmenu.c:1771
...
====
Around frame 4 also seems to be spectaculaly wrong:
====
#4 0x00007f068b0fa7df in gtk_menu_popup_internal (menu=0x5617647bc2b0 [GtkMenu], device=<optimized out>, parent_menu_shell=<optimized out>, pa
rent_menu_item=<optimized out>, func=<optimized out>, data=<optimized out>, destroy=<optimized out>, button=<optimized out>, activate_time=<opt
imized out>) at gtkmenu.c:1992
====
popup_grab_on_window() is doing a blind gdk_seat_grab() with window=0 without checking;
and in gtk_menu_popup_internal(), near line 1992:
=== if (xgrab_shell == widget) popup_grab_on_window (gtk_widget_get_window (widget), pointer); /* Should always succeed */
gtk_grab_add (GTK_WIDGET (menu));
I think that gtk_grab_add() is what causes the pile of assertions later.
shouldn't it do this instead?
if (gtk_widget_get_realized (memu)) gtk_grab_add (GTK_WIDGET (menu));
Version: 3.22.x