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 695737 - Add wayland support
Add wayland support
Status: RESOLVED FIXED
Product: clutter-gtk
Classification: Platform
Component: GtkClutterEmbed
unspecified
Other Linux
: Normal normal
: ---
Assigned To: clutter-gtk maintainer(s)
clutter-gtk maintainer(s)
wayland
Depends on: 724811
Blocks: 672735 wayland
 
 
Reported: 2013-03-12 23:42 UTC by Bastien Nocera
Modified: 2014-04-25 22:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
util: Add Wayland support to init (1.70 KB, patch)
2013-03-12 23:44 UTC, Bastien Nocera
none Details | Review
wayland: Import a copy of the subsurface protocol extension (11.47 KB, patch)
2013-09-03 14:46 UTC, Rob Bradford
reviewed Details | Review
wayland: Generate client side binding for the subsurface protocol (2.13 KB, patch)
2013-09-03 14:46 UTC, Rob Bradford
needs-work Details | Review
gitignore: Update for generated subsurface code (682 bytes, patch)
2013-09-03 14:47 UTC, Rob Bradford
reviewed Details | Review
wayland: Integrate GTK+ and Clutter's display (1.03 KB, patch)
2013-09-03 14:47 UTC, Rob Bradford
needs-work Details | Review
wayland: Use the subsurface protocol to implement GtkClutterEmbed (5.55 KB, patch)
2013-09-03 14:47 UTC, Rob Bradford
needs-work Details | Review
wayland: Integrate GTK+ and Clutter's display (1.40 KB, patch)
2013-09-07 22:48 UTC, Bastien Nocera
none Details | Review
wayland: Integrate GTK+ and Clutter's display (1.57 KB, patch)
2013-09-07 23:17 UTC, Bastien Nocera
reviewed Details | Review
util: Add Wayland support to init (1.77 KB, patch)
2013-09-07 23:19 UTC, Bastien Nocera
reviewed Details | Review
wayland: Generate client side binding for the subsurface protocol (2.18 KB, patch)
2013-09-20 15:40 UTC, Rob Bradford
needs-work Details | Review
wayland: Integrate GTK+ and Clutter's display (2.17 KB, patch)
2013-09-20 15:45 UTC, Rob Bradford
needs-work Details | Review
examples: Add a GtkStack to the examples (2.40 KB, patch)
2013-10-04 16:33 UTC, Bastien Nocera
none Details | Review
gtk-clutter-util: Remove extraneous set to ARGB32 visuals (1.03 KB, patch)
2014-04-16 17:46 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gtk-clutter-util: Use the GDK display when using the GDK backend (1019 bytes, patch)
2014-04-16 17:46 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gtk-clutter-util: Don't error out for an unknown backend (1.58 KB, patch)
2014-04-16 17:46 UTC, Jasper St. Pierre (not reading bugmail)
rejected Details | Review
gtk-clutter-util: Merge fixes from post_parse_hook (2.35 KB, patch)
2014-04-16 17:46 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
gtk-clutter-util: Disable accessibility in the post_parse_hook as well (922 bytes, patch)
2014-04-16 17:47 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gtk-clutter-util: Put the shared initializion logic in a shared function (3.35 KB, patch)
2014-04-16 17:47 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
gdk-clutter-util: Add Wayland support to init (1.59 KB, patch)
2014-04-16 17:47 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
wayland: Use the subsurface protocol to implement GtkClutterEmbed (5.42 KB, patch)
2014-04-16 17:47 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
gtk-clutter-util: Merge fixes from post_parse_hook (2.47 KB, patch)
2014-04-16 18:05 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gtk-clutter-util: Put the shared initializion logic in a shared function (3.41 KB, patch)
2014-04-16 18:05 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gdk-clutter-util: Add Wayland support to init (1.59 KB, patch)
2014-04-16 18:05 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
wayland: Use the subsurface protocol to implement GtkClutterEmbed (5.42 KB, patch)
2014-04-16 18:05 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Bastien Nocera 2013-03-12 23:42:12 UTC
GtkClutterEmbed doesn't work on wayland because it uses X11 specific calls, and wayland doesn't have support for sub-surfaces that are needed to get an equivalent to the child windows we use in X11.
Comment 1 Bastien Nocera 2013-03-12 23:44:01 UTC
Created attachment 238749 [details] [review]
util: Add Wayland support to init

Pretty useless, but gets the code running a little bit further.
Comment 2 Bastien Nocera 2013-03-13 16:41:07 UTC
The above patch allows to do this:
https://twitter.com/hadessuk/status/311844151337562112
Comment 3 Thomas Andersen 2013-03-23 21:46:23 UTC
This patch helped to get quadrapassel to at least start on wayland.

The other games that use clutter-gtk did start but they call gtk_clutter_init. Quadrapassel instead calls gtk_clutter_init_with_args which calls post_parse_hook where clutter-gtk fails on wayland.
Comment 4 Rob Bradford 2013-09-03 14:46:52 UTC
Created attachment 253979 [details] [review]
wayland: Import a copy of the subsurface protocol extension
Comment 5 Rob Bradford 2013-09-03 14:46:56 UTC
Created attachment 253980 [details] [review]
wayland: Generate client side binding for the subsurface protocol

This adds a non-optional dependency on Clutter Wayland and GTK Wayland
as well as the Wayland client library itself.
Comment 6 Rob Bradford 2013-09-03 14:47:00 UTC
Created attachment 253981 [details] [review]
gitignore: Update for generated subsurface code
Comment 7 Rob Bradford 2013-09-03 14:47:03 UTC
Created attachment 253982 [details] [review]
wayland: Integrate GTK+ and Clutter's display

Tell Clutter to use the display from GTK and in order to avoid deadlocks
on the Wayland socket disable Clutter's polling on that socket.
Comment 8 Rob Bradford 2013-09-03 14:47:07 UTC
Created attachment 253983 [details] [review]
wayland: Use the subsurface protocol to implement GtkClutterEmbed

The subsurface protocol lets us "embed" one surface within another. The
compositor will compose the two surfaces together to create a single
window. We use it here to take the surface we get from Clutter and make
that into a subsurface and then associate that subsurface with the main
surface coming from GTK+.
Comment 9 Bastien Nocera 2013-09-07 22:46:52 UTC
Review of attachment 253982 [details] [review]:

::: clutter-gtk/gtk-clutter-util.c
@@ +107,3 @@
       /* let GTK+ be in charge of the event handling */
+      clutter_wayland_disable_event_retrieval ();
+      clutter_wayland_set_display (gdk_wayland_display_get_wl_display (display));

You're missing the same fix in gtk_clutter_init()
Comment 10 Bastien Nocera 2013-09-07 22:48:16 UTC
Created attachment 254364 [details] [review]
wayland: Integrate GTK+ and Clutter's display

Tell Clutter to use the display from GTK and in order to avoid deadlocks
on the Wayland socket disable Clutter's polling on that socket.
Comment 11 Bastien Nocera 2013-09-07 22:54:18 UTC
Review of attachment 253980 [details] [review]:

This seems to fail to create the files when using parallel builds, I had to "make subsurface-client-protocol.h"

::: clutter-gtk/Makefile.am
@@ +22,3 @@
 lib_LTLIBRARIES = libclutter-gtk-@CLUTTER_GTK_API_VERSION@.la
 
+source_c = $(srcdir)/subsurface-protocol.c $(srcdir)/subsurface-client-protocol.h

Those should be $(builddir), not $(srcdir), as they're generated files.
Comment 12 Bastien Nocera 2013-09-07 22:56:30 UTC
Review of attachment 253981 [details] [review]:

Looks good.
Comment 13 Bastien Nocera 2013-09-07 23:17:47 UTC
Created attachment 254366 [details] [review]
wayland: Integrate GTK+ and Clutter's display

Tell Clutter to use the display from GTK and in order to avoid deadlocks
on the Wayland socket disable Clutter's polling on that socket.
Comment 14 Bastien Nocera 2013-09-07 23:19:18 UTC
Created attachment 254367 [details] [review]
util: Add Wayland support to init

Pretty useless, but gets the code running a little bit further.
Comment 15 Bastien Nocera 2013-09-07 23:20:12 UTC
Review of attachment 254366 [details] [review]:

The original fix was missing an include, and the fix in gtk_clutter_init().
Comment 16 Bastien Nocera 2013-09-07 23:22:20 UTC
Review of attachment 254367 [details] [review]:

Old and incomplete, maybe should be merged into your other patch?
This is rebased on current master.
Comment 17 Bastien Nocera 2013-09-07 23:22:54 UTC
Review of attachment 253979 [details] [review]:

This is easy enough.
Comment 18 Bastien Nocera 2013-09-07 23:25:51 UTC
Review of attachment 253983 [details] [review]:

I don't know whether this code is responsible for the problem, but I only see between 1 and zero floating windows in wayland, whereas I see between 3 and 4 with X11, with the gtk-clutter-test-actor example.

$ GDK_BACKEND=wayland CLUTTER_BACKEND=wayland ./gtk-clutter-test-actor
<one or no floating windows)
$ ./gtk-clutter-test-actor
<three or 4 floating windows>
Comment 19 Bastien Nocera 2013-09-07 23:28:13 UTC
I also had to apply the patch from https://bugzilla.gnome.org/show_bug.cgi?id=707704 to prevent the above X11 test case from crashing (GTK+ would prefer wayland, and Clutter X11, thus, assertion).
Comment 20 Tomeu Vizoso 2013-09-11 08:53:51 UTC
Seems to be a problem with positioning of the subsurface within scrolled windows. In those cases, this works better than using the allocation:

gtk_widget_translate_coordinates (widget, toplevel, 0, 0, &x, &y);

But sizing is still wrong.
Comment 21 Rob Bradford 2013-09-20 15:40:44 UTC
Created attachment 255417 [details] [review]
wayland: Generate client side binding for the subsurface protocol

This adds a non-optional dependency on Clutter Wayland and GTK Wayland
as well as the Wayland client library itself.

v1: Integrate fix from Bastien to use $(builddir)
Comment 22 Rob Bradford 2013-09-20 15:45:30 UTC
Created attachment 255418 [details] [review]
wayland: Integrate GTK+ and Clutter's display

Tell Clutter to use the display from GTK and in order to avoid deadlocks
on the Wayland socket disable Clutter's polling on that socket.

v1: Integrates Bastien's original enabling patch: attachment#254367 [details]
Comment 23 Emmanuele Bassi (:ebassi) 2013-09-24 13:15:58 UTC
Review of attachment 255417 [details] [review]:

::: clutter-gtk/Makefile.am
@@ +3,3 @@
 NULL =
 
+CLEANFILES = subsurface-client-protocol.h subsurface-protocol.c

these should go below, and conditionally added i.e.

if BUILD_WAYLAND
CLEANFILES += subsurface-client-protocol.h subsurface-protocol.c
endif

@@ +22,3 @@
 lib_LTLIBRARIES = libclutter-gtk-@CLUTTER_GTK_API_VERSION@.la
 
+source_c = $(builddir)/subsurface-protocol.c $(builddir)/subsurface-client-protocol.h

same as above, plus builddir is never used.

if BUILD_WAYLAND
source_c += \
    $(top_builddir)/clutter-gtk/subsurface-protocol.c \
    $(top_builddir)/clutter-gtk/subsurface-protocol.h \
    $(NULL)
endif

@@ +64,3 @@
 
+
+@wayland_scanner_rules@

should be conditionally expanded.

::: configure.ac
@@ +89,3 @@
 AC_SUBST([CLUTTER_GTK_DEPS_CFLAGS])
 AC_SUBST([CLUTTER_GTK_DEPS_LIBS])
+PKG_CHECK_MODULES([WAYLAND_DEPS], [wayland-client gtk+-wayland-3.0 clutter-wayland-1.0])

this should really be conditional.

PKG_CHECK_MODULES([WAYLAND_DEPS],
                  [wayland-client gtk+-wayland-3.0 clutter-wayland-1.0],
                  [build_wayland=yes],
                  [build_wayland=no])

AM_CONDITIONAL(BUILD_WAYLAND, [test "x$build_wayland" = "xyes"])

you're also not using WAYLAND_DEPS_CFLAGS and WAYLAND_DEPS_LIBS anywhere.

@@ +204,3 @@
 GOBJECT_INTROSPECTION_CHECK([0.9.12])
 
+WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol'])

again, conditional, under an AS_IF([test "x$build_wayland" = "xyes"],...)
Comment 24 Emmanuele Bassi (:ebassi) 2013-09-24 13:17:07 UTC
Review of attachment 255418 [details] [review]:

::: clutter-gtk/gtk-clutter-util.c
@@ +219,3 @@
 
+#if defined(GDK_WINDOWING_WAYLAND) && defined(CLUTTER_WINDOWING_WAYLAND)
+  if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WAYLAND))

needs run-time check on the GdkDisplay.
Comment 25 Emmanuele Bassi (:ebassi) 2013-09-24 13:20:35 UTC
Review of attachment 253983 [details] [review]:

::: clutter-gtk/gtk-clutter-embed.c
@@ +389,3 @@
+      struct wl_compositor *compositor;
+
+      display = gdk_display_get_default ();

should probably get the display from the GdkWindow, to ensure consistency.

@@ +392,3 @@
+      compositor = gdk_wayland_display_get_wl_compositor (display);
+      clutter_surface = wl_compositor_create_surface (compositor);
+      struct wl_surface *clutter_surface, *gtk_surface;

coding style: missing space between function and arguments.

@@ +396,3 @@
+                                            clutter_surface);
+      priv->subsurface =
+

coding style: indentation level.

@@ +576,3 @@
+#if defined(GDK_WINDOWING_WAYLAND) && defined(CLUTTER_WINDOWING_WAYLAND)
+      if (priv->subsurface)
+      {

coding style: indentation.

@@ +999,3 @@
+  GtkClutterEmbedPrivate *priv = embed->priv;
+
+                        uint32_t name,

coding style: braces on a different indentation level.

@@ +1011,3 @@
+                               struct wl_registry *registry,
+                               uint32_t name)
+

shouldn't priv->subcompositor be NULL-ified here? do we need to care?

@@ +1075,3 @@
+    if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WAYLAND) &&
+        GDK_IS_WAYLAND_DISPLAY (gdk_display))
+    {

coding style: indentation level.
Comment 26 Rob Bradford 2013-10-04 13:48:31 UTC
(In reply to comment #18)
> Review of attachment 253983 [details] [review]:
> 
> I don't know whether this code is responsible for the problem, but I only see
> between 1 and zero floating windows in wayland, whereas I see between 3 and 4
> with X11, with the gtk-clutter-test-actor example.
> 
> $ GDK_BACKEND=wayland CLUTTER_BACKEND=wayland ./gtk-clutter-test-actor
> <one or no floating windows)
> $ ./gtk-clutter-test-actor
> <three or 4 floating windows>

Isn't this GTK embedding Clutter rather than Clutter embedding in GTK?

This might be the same offscreen window problem as: https://bugzilla.gnome.org/show_bug.cgi?id=695494 ?
Comment 27 Bastien Nocera 2013-10-04 16:33:43 UTC
Created attachment 256487 [details] [review]
examples: Add a GtkStack to the examples

Clicking on the "clickety" button in the gtk-clutter-test
will toggle, in a GtkStack, between a label, and a clutter-gtk
stage. It doesn't take very long to see the display artifacts after
that.
Comment 28 Matthias Clasen 2014-03-18 18:19:47 UTC
Sadly, it looks like this won't happen for 3.12
Comment 29 Matthias Clasen 2014-04-02 19:17:09 UTC
Trying the clutter-gtk tests here with 3.12 and these patches here, the first impression is that I don't get any events - no clicking or typing...
Comment 30 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:46:42 UTC
Created attachment 274495 [details] [review]
gtk-clutter-util: Remove extraneous set to ARGB32 visuals

This is already done in the post-parse hook
Comment 31 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:46:48 UTC
Created attachment 274496 [details] [review]
gtk-clutter-util: Use the GDK display when using the GDK backend

This is what the post-parse hook does.
Comment 32 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:46:52 UTC
Created attachment 274497 [details] [review]
gtk-clutter-util: Don't error out for an unknown backend

We could be just fine with e.g. the Wayland backend.
Comment 33 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:46:56 UTC
Created attachment 274498 [details] [review]
gtk-clutter-util: Merge fixes from post_parse_hook

Get these two methods back in sync.
Comment 34 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:47:00 UTC
Created attachment 274499 [details] [review]
gtk-clutter-util: Disable accessibility in the post_parse_hook as well
Comment 35 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:47:04 UTC
Created attachment 274500 [details] [review]
gtk-clutter-util: Put the shared initializion logic in a shared function
Comment 36 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:47:09 UTC
Created attachment 274501 [details] [review]
gdk-clutter-util: Add Wayland support to init

Pretty useless, but gets the code running a little bit further.
Comment 37 Jasper St. Pierre (not reading bugmail) 2014-04-16 17:47:15 UTC
Created attachment 274502 [details] [review]
wayland: Use the subsurface protocol to implement GtkClutterEmbed

The subsurface protocol lets us "embed" one surface within another. The
compositor will compose the two surfaces together to create a single
window. We use it here to take the surface we get from Clutter and make
that into a subsurface and then associate that subsurface with the main
surface coming from GTK+.
Comment 38 Emmanuele Bassi (:ebassi) 2014-04-16 17:52:49 UTC
Review of attachment 274495 [details] [review]:

okay.
Comment 39 Emmanuele Bassi (:ebassi) 2014-04-16 17:53:17 UTC
Review of attachment 274496 [details] [review]:

okay.
Comment 40 Emmanuele Bassi (:ebassi) 2014-04-16 17:54:47 UTC
Review of attachment 274497 [details] [review]:

I'd actually add a Wayland windowing system backend check, and still `g_error()` out for unrecognised backends.
Comment 41 Emmanuele Bassi (:ebassi) 2014-04-16 17:57:04 UTC
Review of attachment 274498 [details] [review]:

okay.
Comment 42 Emmanuele Bassi (:ebassi) 2014-04-16 17:57:25 UTC
Review of attachment 274499 [details] [review]:

okay.
Comment 43 Emmanuele Bassi (:ebassi) 2014-04-16 17:58:14 UTC
Review of attachment 274500 [details] [review]:

okay.
Comment 44 Emmanuele Bassi (:ebassi) 2014-04-16 17:58:38 UTC
Review of attachment 274501 [details] [review]:

okay.
Comment 45 Emmanuele Bassi (:ebassi) 2014-04-16 18:01:31 UTC
Review of attachment 274502 [details] [review]:

looks good, with one minor issue that can be fixed prior to pushing.

::: clutter-gtk/gtk-clutter-embed.c
@@ +385,3 @@
+      struct wl_compositor *compositor;
+
+      display = gdk_display_get_default ();

we may want to get the GdkDisplay from the widget, in case we end up supporting multiple display connections.
Comment 46 Jasper St. Pierre (not reading bugmail) 2014-04-16 18:04:33 UTC
Attachment 274495 [details] pushed as 95c004c - gtk-clutter-util: Remove extraneous set to ARGB32 visuals
Attachment 274496 [details] pushed as e56061b - gtk-clutter-util: Use the GDK display when using the GDK backend
Attachment 274499 [details] pushed as a160c1e - gtk-clutter-util: Disable accessibility in the post_parse_hook as well
Comment 47 Jasper St. Pierre (not reading bugmail) 2014-04-16 18:05:13 UTC
Created attachment 274507 [details] [review]
gtk-clutter-util: Merge fixes from post_parse_hook

Get these two methods back in sync.
Comment 48 Jasper St. Pierre (not reading bugmail) 2014-04-16 18:05:18 UTC
Created attachment 274508 [details] [review]
gtk-clutter-util: Put the shared initializion logic in a shared function
Comment 49 Jasper St. Pierre (not reading bugmail) 2014-04-16 18:05:24 UTC
Created attachment 274509 [details] [review]
gdk-clutter-util: Add Wayland support to init

Pretty useless, but gets the code running a little bit further.
Comment 50 Jasper St. Pierre (not reading bugmail) 2014-04-16 18:05:29 UTC
Created attachment 274510 [details] [review]
wayland: Use the subsurface protocol to implement GtkClutterEmbed

The subsurface protocol lets us "embed" one surface within another. The
compositor will compose the two surfaces together to create a single
window. We use it here to take the surface we get from Clutter and make
that into a subsurface and then associate that subsurface with the main
surface coming from GTK+.
Comment 51 Emmanuele Bassi (:ebassi) 2014-04-16 18:07:48 UTC
Review of attachment 274507 [details] [review]:

okay
Comment 52 Emmanuele Bassi (:ebassi) 2014-04-16 18:08:25 UTC
Review of attachment 274508 [details] [review]:

okay
Comment 53 Emmanuele Bassi (:ebassi) 2014-04-16 18:08:51 UTC
Review of attachment 274509 [details] [review]:

okay
Comment 54 Emmanuele Bassi (:ebassi) 2014-04-16 18:11:29 UTC
Review of attachment 274510 [details] [review]:

okay

::: clutter-gtk/gtk-clutter-embed.c
@@ +1004,3 @@
+                               struct wl_registry *registry,
+                               uint32_t name)
+  if (strcmp (interface, "wl_subcompositor") == 0)

should we unset priv->subcompositor here? can it even happen that the interface may go away? I doubt it...
Comment 55 Jasper St. Pierre (not reading bugmail) 2014-04-16 18:12:23 UTC
Review of attachment 274510 [details] [review]:

It's theoretically possible (that's what the global_removed hook is for), but I can't imagine it happening on a real compositor in practice.
Comment 56 Jasper St. Pierre (not reading bugmail) 2014-04-16 18:12:46 UTC
Attachment 274507 [details] pushed as fbd8889 - gtk-clutter-util: Merge fixes from post_parse_hook
Attachment 274508 [details] pushed as 7c143f8 - gtk-clutter-util: Put the shared initializion logic in a shared function
Attachment 274509 [details] pushed as a117b16 - gdk-clutter-util: Add Wayland support to init
Attachment 274510 [details] pushed as 25db4f8 - wayland: Use the subsurface protocol to implement GtkClutterEmbed
Comment 57 Rob Bradford 2014-04-25 22:51:29 UTC
Jasper, Emmanuele, Bastien, Matthias, thanks for pursuing this after I ran out of time to work on this.