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 695861 - Allow to use custom surfaces for GdkWindows in Wayland
Allow to use custom surfaces for GdkWindows in Wayland
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
3.7.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 696206
 
 
Reported: 2013-03-14 16:05 UTC by Jan Arne Petersen
Modified: 2013-06-26 14:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] wayland: Add support for custom surfaces (7.79 KB, patch)
2013-03-14 16:06 UTC, Jan Arne Petersen
needs-work Details | Review
[PATCH] wayland: Add support for custom surfaces (7.77 KB, patch)
2013-03-20 15:42 UTC, Jan Arne Petersen
needs-work Details | Review
[PATCH] wayland: Add support for custom surfaces (7.85 KB, patch)
2013-03-21 19:50 UTC, Jan Arne Petersen
accepted-commit_now Details | Review

Description Jan Arne Petersen 2013-03-14 16:05:25 UTC
It should be possible to mark a GdkWindow as a custom Wayland surface. The application can then register the surface as another type of surface using some Wayland interface.
Comment 1 Jan Arne Petersen 2013-03-14 16:06:32 UTC
Created attachment 238896 [details] [review]
[PATCH] wayland: Add support for custom surfaces


Allow to specify a function which is called after a wl_surface is
created for a GdkWindow. It allows to register the surface as a custom
type with some Wayland interface.

Based on a patch by Kristian Høgsberg <krh@bitplanet.net>
---
 gdk/wayland/gdkwaylandwindow.h  | 21 ++++++++++++
 gdk/wayland/gdkwindow-wayland.c | 74 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 89 insertions(+), 6 deletions(-)
Comment 2 Rob Bradford 2013-03-18 14:15:28 UTC
Review of attachment 238896 [details] [review]:

As discussed try to find another solution without using callback..
Comment 3 Jan Arne Petersen 2013-03-20 15:42:16 UTC
Created attachment 239363 [details] [review]
[PATCH] wayland: Add support for custom surfaces


Allow to set a GdkWindow to use a custom surface instead of a
wl_shell_surface. It allows to register the surface as a custom type
with some Wayland interface.
---
 gdk/wayland/gdkwaylandwindow.h  |   1 +
 gdk/wayland/gdkwindow-wayland.c | 119 +++++++++++++++++++++++++++++++++++-----
 2 files changed, 107 insertions(+), 13 deletions(-)
Comment 4 Rob Bradford 2013-03-21 18:43:07 UTC
Review of attachment 239363 [details] [review]:

Very close - I don't want to bikeshed the function naming too much. But the principle is great.

::: gdk/wayland/gdkwaylandwindow.h
@@ +48,3 @@
 struct wl_shell_surface *gdk_wayland_window_get_wl_shell_surface (GdkWindow *window);
 
+void                     gdk_wayland_window_set_custom_surface   (GdkWindow *window);

Can we be more direct here? e,g. gdk_wayland_window_set_use_custom_surface. To me as this name stands i'd expect it to take a parameter of some kind of "custom surface"

::: gdk/wayland/gdkwindow-wayland.c
@@ +142,3 @@
     } saved_fullscreen, saved_maximized;
+
+  gboolean custom;

I'd rather be more verbose here, e.g. use_custom_surface
Comment 5 Jan Arne Petersen 2013-03-21 19:50:08 UTC
Created attachment 239493 [details] [review]
[PATCH] wayland: Add support for custom surfaces


Allow to set a GdkWindow to use a custom surface instead of a
wl_shell_surface. It allows to register the surface as a custom type
with some Wayland interface.
---
 gdk/wayland/gdkwaylandwindow.h  |   2 +
 gdk/wayland/gdkwindow-wayland.c | 119 +++++++++++++++++++++++++++++++++++-----
 2 files changed, 108 insertions(+), 13 deletions(-)
Comment 6 Rob Bradford 2013-03-22 11:58:21 UTC
Review of attachment 239493 [details] [review]:

Cool, let's go with this. Thanks for the tolerating the bikeshedding.
Comment 7 Matthias Clasen 2013-03-22 13:35:42 UTC
How about some more bikeshedding. The documentation seems unnecessarily cloudy: 

" expected to register the surface as some type of surface using some Wayland interface"

Can we have some actual use surface types and Wayland interfaces mentioned here, maybe together with some actual use cases ?
Comment 8 Kristian Høgsberg 2013-03-22 14:00:38 UTC
(In reply to comment #7)
> How about some more bikeshedding. The documentation seems unnecessarily cloudy: 
> 
> " expected to register the surface as some type of surface using some Wayland
> interface"
> 
> Can we have some actual use surface types and Wayland interfaces mentioned
> here, maybe together with some actual use cases ?

A good example would be writing a panel or on-screen-keyboard as an out-of-process helper - as opposed to having those in the compositor process.  In this case the underlying surface isn't a wl_shell surface and the panel or OSK client need to identify the wl_surface as a panel or OSK to the compositor.

The assumption is that the compositor will expose a private interface to the special client that lets the client identify the wl_surface as a panel or such.
Comment 9 Kristian Høgsberg 2013-03-22 14:03:38 UTC
There's a small example here:

  http://cgit.freedesktop.org/~krh/overlay-plugin/tree/gtk-overlay-client.c
Comment 10 Tiago Vignatti 2013-03-27 21:46:43 UTC
hey guys. I'm trying to understand why a custom surface that I've created solely doesn't set the cursor and also keeps spitting this kind of errors whenever I move the mouse upon it:

(weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed

(weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed

(weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed

(weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed

(weston-desktop-shell:1492): Gdk-CRITICAL **: gdk_window_get_frame_clock: assertion `GDK_IS_WINDOW (window)' failed

(weston-desktop-shell:1492): Gdk-CRITICAL **: gdk_frame_clock_request_phase: assertion `GDK_IS_FRAME_CLOCK (frame_clock)' failed

the offending application is this example shell I'm using. So I'm actually trying to create a custom surface and pass it to the desktop shell plugin as a background:
https://github.com/tiagovignatti/gtk-shell
Comment 11 Kristian Høgsberg 2013-03-28 02:52:37 UTC
(In reply to comment #10)
> hey guys. I'm trying to understand why a custom surface that I've created
> solely doesn't set the cursor and also keeps spitting this kind of errors
> whenever I move the mouse upon it:
> 
> (weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion
> `G_IS_OBJECT (object)' failed
> 
> (weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion
> `G_IS_OBJECT (object)' failed
> 
> (weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion
> `G_IS_OBJECT (object)' failed
> 
> (weston-desktop-shell:1492): GLib-GObject-CRITICAL **: g_object_ref: assertion
> `G_IS_OBJECT (object)' failed
> 
> (weston-desktop-shell:1492): Gdk-CRITICAL **: gdk_window_get_frame_clock:
> assertion `GDK_IS_WINDOW (window)' failed
> 
> (weston-desktop-shell:1492): Gdk-CRITICAL **: gdk_frame_clock_request_phase:
> assertion `GDK_IS_FRAME_CLOCK (frame_clock)' failed
> 
> the offending application is this example shell I'm using. So I'm actually
> trying to create a custom surface and pass it to the desktop shell plugin as a
> background:
> https://github.com/tiagovignatti/gtk-shell

I updated my overlay-plugin example above to use the final upstream API, seems to work fine.  Maybe take a look there to see it's how hooked up?
Comment 12 Tiago Vignatti 2013-03-28 13:55:51 UTC
(In reply to comment #11)
> I updated my overlay-plugin example above to use the final upstream API, seems
> to work fine.  Maybe take a look there to see it's how hooked up?

I've noticed you placed the realize function and the overlay surface passing inside a callback. That didn't work for me though.

Note that in my example if I simply avoid the call of      gdk_wayland_window_set_use_custom_surface(), followed by desktop_shell_set_background(), everything works fine; the surfaced is placed top-level then and cursor set is also performed by the application (wl_pointer_set_cursor). So that suggests that my application is written correctly now.

Which examples besides the overlay you guys used for implementing the custom surfaces API? Thank you.
Comment 13 Tiago Vignatti 2013-03-28 14:00:16 UTC
(In reply to comment #12)
> I've noticed you placed the realize function and the overlay surface passing
> inside a callback. That didn't work for me though.

reiterating: realize callback worked but didn't solve my real issue.
Comment 14 Kristian Høgsberg 2013-03-28 14:11:43 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > I've noticed you placed the realize function and the overlay surface passing
> > inside a callback. That didn't work for me though.
> 
> reiterating: realize callback worked but didn't solve my real issue.

The point of moving the set_use_custom_surface to the realize callback is that we create and destroty the wl_surface when we show and hide the GTK+ window.  So if we call gtk_widget_hide() and then gtk_widget_show() we need to set the custom surface again, which is handled in the realize callback.
Comment 15 Tiago Vignatti 2013-03-28 14:21:31 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > reiterating: realize callback worked but didn't solve my real issue.
> 
> The point of moving the set_use_custom_surface to the realize callback is that
> we create and destroty the wl_surface when we show and hide the GTK+ window. 
> So if we call gtk_widget_hide() and then gtk_widget_show() we need to set the
> custom surface again, which is handled in the realize callback.

got it... so for setting background I don't think I need to place it inside a cb, cause in principle the background is supposed to be set only once.

should I re-open this bug?
Comment 16 Tiago Vignatti 2013-04-04 20:49:16 UTC
BTW guys, all good now. It was my fault:

https://github.com/tiagovignatti/gtk-shell/commit/71c92c8c7a7c7f80888cb242a53150c4e40f9d00
Comment 17 dgod 2013-06-22 11:29:50 UTC
is function gdk_wayland_window_set_use_custom_surface really exported?

in fedora 20 with gtk3-3.9.6-1.fc20.i686 installed

readelf -s -W /usr/lib/libgdk-3.so.0.906.0 |grep gdk_wayland_window_set_use_custom_surface

return nothing.

use it in ap will cause an link error.

look at the gdkwaylandwindow.h
GDK_AVAILABLE_IN_ALL
struct wl_shell_surface *gdk_wayland_window_get_wl_shell_surface (GdkWindow *window);

void                     gdk_wayland_window_set_use_custom_surface (GdkWindow *window);

no GDK_AVAILABLE_IN_ALL before gdk_wayland_window_set_use_custom_surface
Comment 18 Rob Bradford 2013-06-26 14:16:26 UTC
(In reply to comment #17)

> no GDK_AVAILABLE_IN_ALL before gdk_wayland_window_set_use_custom_surface

Thanks - well spotted. Fixed in master.