After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 759623 - Gnome-Builder: Doesn't show suggestions when running with wayland backend
Gnome-Builder: Doesn't show suggestions when running with wayland backend
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
git master
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
: 758527 759550 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-12-18 12:59 UTC by Christian Stadelmann
Modified: 2016-03-15 10:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] CompletionInfo: fix popup window under Wayland (2.27 KB, patch)
2016-01-12 16:04 UTC, Olivier Fourdan
none Details | Review
[PATCH v2] CompletionInfo: fix popup window under Wayland (2.26 KB, patch)
2016-01-12 16:19 UTC, Olivier Fourdan
committed Details | Review

Description Christian Stadelmann 2015-12-18 12:59:01 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):
  • File "/usr/lib64/gnome-builder/plugins/jedi_plugin.py", line 419 in do_get_markup
    parts.append(', '.join(get_param_description(p) for p in params))
  • File "/usr/lib64/gnome-builder/plugins/jedi_plugin.py", line 419 in <genexpr>
    parts.append(', '.join(get_param_description(p) for p in params))
  • File "/usr/lib64/gnome-builder/plugins/jedi_plugin.py", line 456 in get_param_description
    return param.name
AttributeError: 'NoneType' object has no attribute '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):
  • File "/usr/lib64/gnome-builder/plugins/jedi_plugin.py", line 419 in do_get_markup
    parts.append(', '.join(get_param_description(p) for p in params))
  • File "/usr/lib64/gnome-builder/plugins/jedi_plugin.py", line 419 in <genexpr>
    parts.append(', '.join(get_param_description(p) for p in params))
  • File "/usr/lib64/gnome-builder/plugins/jedi_plugin.py", line 456 in get_param_description
    return param.name
AttributeError: 'NoneType' object has no attribute 'name'

Comment 1 Olivier Fourdan 2015-12-18 13:04:31 UTC
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.
Comment 2 Christian Stadelmann 2015-12-18 15:50:58 UTC
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?
Comment 3 Olivier Fourdan 2015-12-18 16:21:50 UTC
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).
Comment 4 Olivier Fourdan 2015-12-18 17:31:26 UTC
Although an API addition in GTK+ to avoid using such a workaround would prove useful for this kind of use case...
Comment 5 Olivier Fourdan 2016-01-08 16:20:54 UTC
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).
Comment 6 Olivier Fourdan 2016-01-12 16:04:16 UTC
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.
Comment 7 Ignacio Casal Quinteiro (nacho) 2016-01-12 16:09:39 UTC
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
Comment 8 Olivier Fourdan 2016-01-12 16:17:21 UTC
(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
Comment 9 Olivier Fourdan 2016-01-12 16:19:28 UTC
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.
Comment 10 Ignacio Casal Quinteiro (nacho) 2016-01-12 16:21:42 UTC
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 11 Olivier Fourdan 2016-01-12 16:28:29 UTC
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
Comment 12 Olivier Fourdan 2016-01-12 16:29:05 UTC
Closing, thanks!
Comment 13 Sébastien Wilmet 2016-01-13 10:27:41 UTC
*** Bug 758527 has been marked as a duplicate of this bug. ***
Comment 14 Olivier Fourdan 2016-03-15 10:22:27 UTC
*** Bug 759550 has been marked as a duplicate of this bug. ***