Offscreen window fixes for GIMP3
This MR contains fixes for GtkEntry
in GtkOffscreenWindow
.
The first commit fixes a crash when right-clicking on a GtkEntry
to open the context menu. GtkEntry
has an input-only
child window which gets window_type GTK_WINDOW_CHILD
, but the impl is still a GdkOffscreenWindow
. As such gdk_window_set_transient_for
doesn't recognize it as offscreen, and the backend-specific set_transient_for
makes an invalid cast.
(gdb) bt
#0 0x00007ffff6de4435 in g_logv () at /usr/lib/libglib-2.0.so.0
#1 0x00007ffff6de46d4 in g_log () at /usr/lib/libglib-2.0.so.0
#2 0x00007ffff737f272 in g_type_check_instance_cast () at /usr/lib/libgobject-2.0.so.0
#3 0x00007ffff7f5febc in gdk_x11_window_set_transient_for (window=0x5555596f4aa0, parent=0x5555595aefd0) at ../gtk3/gdk/x11/gdkwindow-x11.c:2949
#4 0x00007ffff7eeeb2a in gdk_window_set_transient_for (window=0x5555596f4aa0, parent=0x5555595aefd0) at ../gtk3/gdk/gdkwindow.c:10554
#5 0x00007ffff76d66b9 in gtk_menu_position (menu=0x555559828f50, set_scroll_offset=1) at ../gtk3/gtk/gtkmenu.c:5316
#6 0x00007ffff76ce10a in gtk_menu_popup_internal
(menu=0x555559828f50, device=0x5555560db0f0, parent_menu_shell=0x0, parent_menu_item=0x0, func=0x0, data=0x0, destroy=0x0, button=3, activate_time=19579888)
at ../gtk3/gtk/gtkmenu.c:1992
#7 0x00007ffff76ce826 in gtk_menu_popup_at_rect
(menu=0x555559828f50, rect_window=0x5555595aefd0, rect=0x7fffffffce30, rect_anchor=GDK_GRAVITY_SOUTH_EAST, menu_anchor=GDK_GRAVITY_NORTH_WEST, trigger_event=0x55555986b6d0) at ../gtk3/gtk/gtkmenu.c:2269
#8 0x00007ffff76cee6c in gtk_menu_popup_at_pointer (menu=0x555559828f50, trigger_event=0x55555986b6d0) at ../gtk3/gtk/gtkmenu.c:2430
...
(gdb) frame 4
#4 0x00007ffff7eeeb2a in gdk_window_set_transient_for (window=0x5555596f4aa0, parent=0x5555595aefd0) at ../gtk3/gdk/gdkwindow.c:10554
10554 GDK_WINDOW_IMPL_GET_CLASS (window->impl)->set_transient_for (window, parent);
(gdb) p (GdkWindowType)parent->window_type
$1 = GDK_WINDOW_CHILD
(gdb) p (int)g_type_check_instance_is_a (parent->impl, gdk_offscreen_window_get_type ())
$3 = 1
NOTE: the above stacktrace was retrieved on X11 because Wayland has no native child windows, but on Wayland we crash sometime later anyway.
The first commit changes gdk_window_set_transient_for
to check for the GdkWindowImpl
rather than the window_type.
The second commit fixes an analogous invalid cast (from GdkOffscreenWindow
to GdkWindowImplWayland
) when showing a GtkEntryCompletion contained within a GtkOffscreenWindow
(gdb) bt
#0 0x00007ffff6de4435 in g_logv () at /usr/lib/libglib-2.0.so.0
#1 0x00007ffff6de46d4 in g_log () at /usr/lib/libglib-2.0.so.0
#2 0x00007ffff737f272 in g_type_check_instance_cast () at /usr/lib/libgobject-2.0.so.0
#3 0x00007ffff7f22862 in gdk_wayland_window_get_wl_output (window=0x555559a5c720) at ../gtk3/gdk/wayland/gdkwindow-wayland.c:5107
#4 0x00007ffff7f0790e in gdk_wayland_display_get_monitor_at_window (display=0x55555607eff0, window=0x555559a5c720) at ../gtk3/gdk/wayland/gdkdisplay-wayland.c:1041
#5 0x00007ffff7ec6381 in gdk_display_get_monitor_at_window (display=0x55555607eff0, window=0x555559a5c720) at ../gtk3/gdk/gdkdisplay.c:2716
#6 0x00007ffff75f5e4a in _gtk_entry_completion_resize_popup (completion=0x55555939cc50) at ../gtk3/gtk/gtkentrycompletion.c:1656
#7 0x00007ffff75dfc6c in gtk_entry_allocate (gadget=0x555558f4b730, allocation=0x7fffffff8f60, baseline=-1, out_clip=0x7fffffff8f80, data=0x0)
at ../gtk3/gtk/gtkentry.c:3931
#8 0x00007ffff757155b in gtk_css_custom_gadget_allocate (gadget=0x555558f4b730, allocation=0x7fffffff8f60, baseline=-1, out_clip=0x7fffffff8f80)
at ../gtk3/gtk/gtkcsscustomgadget.c:143
#9 0x00007ffff7578dee in gtk_css_gadget_allocate (gadget=0x555558f4b730, allocation=0x7fffffff95c0, baseline=-1, out_clip=0x7fffffff8fd0)
at ../gtk3/gtk/gtkcssgadget.c:790
#10 0x00007ffff75df722 in gtk_entry_size_allocate (widget=0x55555961d060, allocation=0x7fffffff95c0) at ../gtk3/gtk/gtkentry.c:3799
gdk_display_get_monitor_at_window
should filter offscreen windows out before calling the backend-specific implementation
Finally, the third commit fixes the positioning of context menus on GtkOffscreenWindow
hierarchies
Closes gimp#10141 (closed)