summaryrefslogtreecommitdiff
path: root/gdk/wayland/gdkdisplay-wayland.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-04-28 20:35:51 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-10-26 15:51:56 -0400
commit1b279e3d4ac33ebd9a3925d1a388c28bd96232d5 (patch)
tree53a2aa12712990e23be747be2c5a620d348851af /gdk/wayland/gdkdisplay-wayland.c
parent028e39d6ee53a5c09da4b4d5a9bbb1d6e768f368 (diff)
downloadgtk+-1b279e3d4ac33ebd9a3925d1a388c28bd96232d5.tar.gz
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 <sir@cmpwn.com> https://bugzilla.gnome.org/show_bug.cgi?id=781909
Diffstat (limited to 'gdk/wayland/gdkdisplay-wayland.c')
-rw-r--r--gdk/wayland/gdkdisplay-wayland.c39
1 files changed, 39 insertions, 0 deletions
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 <wayland/xdg-shell-unstable-v6-client-protocol.h>
#include <wayland/xdg-foreign-unstable-v1-client-protocol.h>
+#include <wayland/server-decoration-client-protocol.h>
/**
* SECTION:wayland_interaction
@@ -337,6 +338,35 @@ static const struct wl_shm_listener wl_shm_listener = {
};
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,
uint32_t id,
@@ -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;