GNOME Bugzilla – Bug 695861
Allow to use custom surfaces for GdkWindows in Wayland
Last modified: 2013-06-26 14:16:26 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.
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(-)
Review of attachment 238896 [details] [review]: As discussed try to find another solution without using callback..
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(-)
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
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(-)
Review of attachment 239493 [details] [review]: Cool, let's go with this. Thanks for the tolerating the bikeshedding.
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 ?
(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.
There's a small example here: http://cgit.freedesktop.org/~krh/overlay-plugin/tree/gtk-overlay-client.c
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
(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?
(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.
(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.
(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.
(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?
BTW guys, all good now. It was my fault: https://github.com/tiagovignatti/gtk-shell/commit/71c92c8c7a7c7f80888cb242a53150c4e40f9d00
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
(In reply to comment #17) > no GDK_AVAILABLE_IN_ALL before gdk_wayland_window_set_use_custom_surface Thanks - well spotted. Fixed in master.