wayland: add support for a private gtk-shell protocol

This protocol will be used by mutter-wayland and gtk to replace
the _GTK X11 properties for DBus names/paths.

https://bugzilla.gnome.org/show_bug.cgi?id=707129
This commit is contained in:
Giovanni Campagna 2013-08-30 13:55:37 +02:00
parent e000ba468f
commit d34335e51c
6 changed files with 55 additions and 0 deletions

View File

@ -404,6 +404,12 @@ if test "x$enable_wayland_backend" = "xyes"; then
#define GDK_WINDOWING_WAYLAND" #define GDK_WINDOWING_WAYLAND"
DISABLE_ON_WAYLAND='%' DISABLE_ON_WAYLAND='%'
WAYLAND_PACKAGES="wayland-client >= 1.1.90 xkbcommon >= 0.2.0 wayland-cursor" WAYLAND_PACKAGES="wayland-client >= 1.1.90 xkbcommon >= 0.2.0 wayland-cursor"
AC_PATH_PROG([WAYLAND_SCANNER],[wayland-scanner],[no])
AS_IF([test "x$WAYLAND_SCANNER" = "xno"],
AC_MSG_ERROR([Could not find wayland-scanner in your PATH, required for parsing wayland extension protocols]))
AC_SUBST([WAYLAND_SCANNER])
AM_CONDITIONAL(USE_WAYLAND, true) AM_CONDITIONAL(USE_WAYLAND, true)
else else
AM_CONDITIONAL(USE_WAYLAND, false) AM_CONDITIONAL(USE_WAYLAND, false)

View File

@ -19,7 +19,12 @@ LDADDS = $(GDK_DEP_LIBS)
noinst_LTLIBRARIES = \ noinst_LTLIBRARIES = \
libgdk-wayland.la libgdk-wayland.la
BUILT_SOURCES = \
gtk-shell-client-protocol.h \
gtk-shell-protocol.c
libgdk_wayland_la_SOURCES = \ libgdk_wayland_la_SOURCES = \
$(BUILT_SOURCES) \
gdkapplaunchcontext-wayland.c \ gdkapplaunchcontext-wayland.c \
gdkcursor-wayland.c \ gdkcursor-wayland.c \
gdkdevice-wayland.c \ gdkdevice-wayland.c \
@ -43,4 +48,13 @@ libgdkwaylandinclude_HEADERS = \
gdkwaylandselection.h \ gdkwaylandselection.h \
gdkwaylandwindow.h gdkwaylandwindow.h
%-protocol.c : protocol/%.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
%-server-protocol.h : protocol/%.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) server-header < $< > $@
%-client-protocol.h : protocol/%.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
EXTRA_DIST += protocol/gtk-shell.xml
-include $(top_srcdir)/git.mk -include $(top_srcdir)/git.mk

View File

@ -167,6 +167,9 @@ gdk_registry_handle_global(void *data, struct wl_registry *registry, uint32_t id
} else if (strcmp(interface, "wl_shell") == 0) { } else if (strcmp(interface, "wl_shell") == 0) {
display_wayland->shell = display_wayland->shell =
wl_registry_bind(display_wayland->wl_registry, id, &wl_shell_interface, 1); wl_registry_bind(display_wayland->wl_registry, id, &wl_shell_interface, 1);
} else if (strcmp(interface, "gtk_shell") == 0) {
display_wayland->gtk_shell =
wl_registry_bind(display_wayland->wl_registry, id, &gtk_shell_interface, 1);
} else if (strcmp(interface, "wl_output") == 0) { } else if (strcmp(interface, "wl_output") == 0) {
output = output =
wl_registry_bind(display_wayland->wl_registry, id, &wl_output_interface, MIN (version, 2)); wl_registry_bind(display_wayland->wl_registry, id, &wl_output_interface, MIN (version, 2));

View File

@ -26,6 +26,7 @@
#include <stdint.h> #include <stdint.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wayland-cursor.h> #include <wayland-cursor.h>
#include "gtk-shell-client-protocol.h"
#include <glib.h> #include <glib.h>
#include <gdk/gdkkeys.h> #include <gdk/gdkkeys.h>
@ -58,6 +59,7 @@ struct _GdkWaylandDisplay
struct wl_compositor *compositor; struct wl_compositor *compositor;
struct wl_shm *shm; struct wl_shm *shm;
struct wl_shell *shell; struct wl_shell *shell;
struct gtk_shell *gtk_shell;
struct wl_input_device *input_device; struct wl_input_device *input_device;
struct wl_data_device_manager *data_device_manager; struct wl_data_device_manager *data_device_manager;

View File

@ -102,6 +102,7 @@ struct _GdkWindowImplWayland
struct wl_surface *surface; struct wl_surface *surface;
struct wl_shell_surface *shell_surface; struct wl_shell_surface *shell_surface;
struct gtk_surface *gtk_surface;
unsigned int mapped : 1; unsigned int mapped : 1;
GdkWindow *transient_for; GdkWindow *transient_for;
GdkWindowTypeHint hint; GdkWindowTypeHint hint;
@ -1030,6 +1031,10 @@ gdk_wayland_window_create_surface (GdkWindow *window)
wl_surface_set_user_data(impl->surface, window); wl_surface_set_user_data(impl->surface, window);
wl_surface_add_listener(impl->surface, wl_surface_add_listener(impl->surface,
&surface_listener, window); &surface_listener, window);
if (display_wayland->gtk_shell)
impl->gtk_surface = gtk_shell_get_gtk_surface (display_wayland->gtk_shell,
impl->surface);
} }
static void static void
@ -1091,6 +1096,10 @@ gdk_wayland_window_hide_surface (GdkWindow *window,
} }
else if (impl->surface) else if (impl->surface)
{ {
if (impl->gtk_surface)
gtk_surface_destroy(impl->gtk_surface);
impl->gtk_surface = NULL;
wl_surface_destroy(impl->surface); wl_surface_destroy(impl->surface);
impl->surface = NULL; impl->surface = NULL;

View File

@ -0,0 +1,21 @@
<protocol name="gtk">
<interface name="gtk_shell" version="1">
<request name="get_gtk_surface">
<arg name="gtk_surface" type="new_id" interface="gtk_surface"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
</interface>
<interface name="gtk_surface" version="1">
<request name="set_dbus_properties">
<arg name="application_id" type="string" allow-null="true"/>
<arg name="app_menu_path" type="string" allow-null="true"/>
<arg name="menubar_path" type="string" allow-null="true"/>
<arg name="window_object_path" type="string" allow-null="true"/>
<arg name="application_object_path" type="string" allow-null="true"/>
<arg name="unique_bus_name" type="string" allow-null="true"/>
</request>
</interface>
</protocol>