From 1b279e3d4ac33ebd9a3925d1a388c28bd96232d5 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 28 Apr 2017 20:35:51 -0400 Subject: Wayland: Implement KDE's SSD protocol If the compositor prefers server-side decorations and the client doesn't customize the title bar, we disable client-side decorations and let the compositor know. Otherwise, we continue to use client-side decorations. Signed-off-by: Drew DeVault https://bugzilla.gnome.org/show_bug.cgi?id=781909 --- gdk/wayland/gdkdisplay-wayland.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'gdk/wayland/gdkdisplay-wayland.c') diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 2154e5101e..ab1aa72a02 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -49,6 +49,7 @@ #include "tablet-unstable-v2-client-protocol.h" #include #include +#include /** * SECTION:wayland_interaction @@ -336,6 +337,35 @@ static const struct wl_shm_listener wl_shm_listener = { wl_shm_format }; +static void +server_decoration_manager_default_mode (void *data, + struct org_kde_kwin_server_decoration_manager *manager, + uint32_t mode) +{ + g_assert (mode <= ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER); + const char *modes[] = { + [ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE] = "none", + [ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT] = "client", + [ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER] = "server", + }; + GdkWaylandDisplay *display_wayland = data; + g_debug ("Compositor prefers decoration mode '%s'", modes[mode]); + display_wayland->server_decoration_mode = mode; +} + +static const struct org_kde_kwin_server_decoration_manager_listener server_decoration_listener = { + .default_mode = server_decoration_manager_default_mode +}; + +gboolean +gdk_wayland_display_prefers_ssd (GdkDisplay *display) +{ + GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); + if (display_wayland->server_decoration_manager) + return display_wayland->server_decoration_mode == ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER; + return FALSE; +} + static void gdk_registry_handle_global (void *data, struct wl_registry *registry, @@ -459,6 +489,15 @@ gdk_registry_handle_global (void *data, wl_registry_bind (display_wayland->wl_registry, id, &zwp_keyboard_shortcuts_inhibit_manager_v1_interface, 1); } + else if (strcmp (interface, "org_kde_kwin_server_decoration_manager") == 0) + { + display_wayland->server_decoration_manager = + wl_registry_bind (display_wayland->wl_registry, id, + &org_kde_kwin_server_decoration_manager_interface, 1); + org_kde_kwin_server_decoration_manager_add_listener (display_wayland->server_decoration_manager, + &server_decoration_listener, + display_wayland); + } else handled = FALSE; -- cgit v1.2.1