GNOME Bugzilla – Bug 759623
Gnome-Builder: Doesn't show suggestions when running with wayland backend
Last modified: 2016-03-15 10:22:27 UTC
Steps to reproduce: 1. open gnome-builder in a gnome+wayland session (Gdk's backend must be wayland) 2. open any file in a format with suggestions enabled 3. write code or file content What should happen: Show a small window (more like a menu) that displays suggestions for code. This works fine with X11 backend but doesn't work fine with wayland backend. What happens: Screen loses focus for some frames, then has focus again. No suggestions are displayed. Affected versions: gnome-builder-3.18.1-2.fc23.x86_64 gtk3-3.18.6-1.fc23.x86_64 glib2-2.46.2-1.fc23.x86_64 Aditional info: * Works fine with X11 backend. * Since gtk is throwing some warnings/criticals at the time suggestions should be displayed I guess this is not an issue in gtk (and its wayland-specific code) but in gnome-builder. See this output: $ GDK_BACKEND=x11 gnome-builder 13:50:26.0787 Gtk[5631]: CRITICAL: gtk_widget_get_preferred_width_for_height: assertion 'height >= 0' failed 13:50:26.0787 Gtk[5631]: WARNING: gtk_widget_size_allocate(): attempt to allocate widget with width 13 and height -24 $ gnome-builder xkbcommon: ERROR: Key "<LFSH>" added to modifier map for multiple modifiers; Using Lock, ignoring Shift 13:50:48.0519 Gtk[5664]: CRITICAL: gtk_widget_get_preferred_width_for_height: assertion 'height >= 0' failed 13:50:48.0519 Gtk[5664]: WARNING: gtk_widget_size_allocate(): attempt to allocate widget with width 13 and height -24 13:50:48.0521 Gdk[5664]: WARNING: Couldn't map as window 0x55dda28915c0 as popup because it doesn't have a parent Traceback (most recent call last):
+ Trace 235824
parts.append(', '.join(get_param_description(p) for p in params))
return param.name
13:50:50.0454 Gdk[5664]: WARNING: Couldn't map as window 0x55dda28915c0 as popup because it doesn't have a parent 13:50:50.0613 Gdk[5664]: WARNING: Couldn't map as window 0x55dda28915c0 as popup because it doesn't have a parent 13:50:51.0127 Gdk[5664]: WARNING: Couldn't map as window 0x55dda28915c0 as popup because it doesn't have a parent Traceback (most recent call last):
This sounds like typical of the use of a popup window in Wayland. Simplest fix is to set the type hint to "tooltip" and specify the toplevel window as transient as shows in the pseudo code below: gtk_window_set_type_hint (GTK_WINDOW (popup), GDK_WINDOW_TYPE_HINT_TOOLTIP); gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (toplevel)); I can prepare a patch if that helps.
Isn't the need to set a type hint of a popup menu to "TOOLTIP" a design bug in Gtk+? A popup is clearly not a tooltip but a POPUP_MENU?
We can discuss as much as we want whether or not this is design issue in gtk+, fact is Wayland is a different windowing system, with a different design than X11. There is no 1-to-1 matching between X11 and Wayland. As you know well, GTK+ was designed originally after X11 as this was pretty much the only windowing system available on Linux and popup in GTK+ are actually override redirect (OR) windows in X11. In Wayland, the closest equivalent to an OR window in X11 is either an xdg-popup or a subsurface. xdg-popup in Wayland are designed primarily for menu, where there is a requirement for a keyboard grab (which is otherwise something not achievable in Wayland either), not really something you would use for the general popup window that those GTK+ applications use. So what's remaining are subsurfaces, which are designed for things like tooltips, do not require a grab but require a parent window (xdg-shell method set_parent()) which translates in gtk+/gdk as "transient_for" (again here, gtk+ cannot hide that it's been modelled after X11). Because of this requirement for a parent window for a subsurface, you cannot translate all "popup" (in GTK+ terminologiy) into subsurfaces. That's why to make this work in Wayland, the simplest and best solution is to set the gdk hint to tooltip and set the transient to the toplevel window (ie comment 1).
Although an API addition in GTK+ to avoid using such a workaround would prove useful for this kind of use case...
Moving to gtksourceview, the popup window is implemented in gtksourceviewcompletioninfo (not in gnome-builder). We'd need to make that popup window (the completion info window) transient for the toplevel window (which is what'd we want for subsurface to work in Wayland).
Created attachment 318891 [details] [review] [PATCH] CompletionInfo: fix popup window under Wayland Wayland requires popup windows to be attached to another toplevel window so that it can be translated either as an xdg-popup or a subsurface depending if there is a grab associated with the popup or not. GtkCompletionInfo uses gtk popup windows type but doesn't set the transient relationship with the toplevel window, causing the CompletionInfo window to fail to map under Wayland. Reuse the attached_to widget to determine the toplevel window and set the transient relationship prior to map the CompletionInfo window so that it can work under Wayland as well. NOTE: You need gtk+ 3.19.6 for this patch to work.
Review of attachment 318891 [details] [review]: See the indentation comment. Also bump the gtk version in configure.ac ::: gtksourceview/gtksourcecompletioninfo.c @@ +304,3 @@ + info = GTK_SOURCE_COMPLETION_INFO (widget); + if (info->priv->attached_to && !info->priv->transient_set) + { the indentation is wrong, you should use the linux like indentation
(In reply to Ignacio Casal Quinteiro (nacho) from comment #7) > Review of attachment 318891 [details] [review] [review]: > Also bump the gtk version in configure.ac The configure.ac already requires 3.19.6 apparently: # Dependencies glib_req=2.47.0 gtk_req=3.19.6 libxml_req=2.6.0 gladeui_req=3.9
Created attachment 318896 [details] [review] [PATCH v2] CompletionInfo: fix popup window under Wayland Update indentation, gtk+ requirement is already up-to-date in configure.ac.
Review of attachment 318896 [details] [review]: Fix the minor nitpick and feel free to push it. Thanks ::: gtksourceview/gtksourcecompletioninfo.c @@ +303,3 @@ + info = GTK_SOURCE_COMPLETION_INFO (widget); + if (info->priv->attached_to && !info->priv->transient_set) be explicit here about != NULL for consistency with the rest of the code
Comment on attachment 318896 [details] [review] [PATCH v2] CompletionInfo: fix popup window under Wayland attachment 318896 [details] [review] updated as per comment 10 and pushed as commit bb45b30 CompletionInfo: fix popup window under Wayland
Closing, thanks!
*** Bug 758527 has been marked as a duplicate of this bug. ***
*** Bug 759550 has been marked as a duplicate of this bug. ***