commit 17d40aae6f95931306f32ee7f198f75abda6c9ef
parent bc903f4d01de470ed6479aa7ad5af0406ccf3f10
Author: Michael Forney <mforney@mforney.org>
Date: Mon, 27 Jan 2020 22:22:51 -0800
Add support for KDE server-side decoration protocol
GTK still does not support xdg-decoration, so implement this for
now.
Diffstat:
8 files changed, 219 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
@@ -2,6 +2,8 @@
*.lo
.*.sw*
+protocol/server-decoration-protocol.c
+protocol/server-decoration-server-protocol.h
protocol/swc-protocol.c
protocol/swc-server-protocol.h
protocol/wayland-drm-protocol.c
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -46,6 +46,7 @@ struct swc {
struct swc_shm *shm;
struct swc_drm *const drm;
struct wl_global *data_device_manager;
+ struct wl_global *kde_decoration_manager;
struct wl_global *panel_manager;
struct wl_global *shell;
struct wl_global *subcompositor;
diff --git a/libswc/kde_decoration.c b/libswc/kde_decoration.c
@@ -0,0 +1,75 @@
+/* swc: libswc/kde_decoration.c
+ *
+ * Copyright (c) 2020 Michael Forney
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "kde_decoration.h"
+
+#include <wayland-server.h>
+#include "server-decoration-server-protocol.h"
+
+static void
+request_mode(struct wl_client *client, struct wl_resource *resource, uint32_t mode)
+{
+ /* Server is required to send back the mode requested by
+ * the client, we just don't plan to do anything with it. */
+ org_kde_kwin_server_decoration_send_mode(resource, mode);
+}
+
+static const struct org_kde_kwin_server_decoration_interface decoration_impl = {
+ .request_mode = request_mode,
+};
+
+static void
+create(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *toplevel_resource)
+{
+ struct wl_resource *decoration;
+
+ decoration = wl_resource_create(client, &org_kde_kwin_server_decoration_interface, wl_resource_get_version(resource), id);
+ if (!decoration)
+ wl_resource_post_no_memory(resource);
+ wl_resource_set_implementation(decoration, &decoration_impl, NULL, NULL);
+ org_kde_kwin_server_decoration_send_mode(decoration, ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
+}
+
+static const struct org_kde_kwin_server_decoration_manager_interface decoration_manager_impl = {
+ .create = create,
+};
+
+static void
+bind_decoration_manager(struct wl_client *client, void *data, uint32_t version, uint32_t id)
+{
+ struct wl_resource *resource;
+
+ resource = wl_resource_create(client, &org_kde_kwin_server_decoration_manager_interface, version, id);
+ if (!resource) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+ wl_resource_set_implementation(resource, &decoration_manager_impl, NULL, NULL);
+ org_kde_kwin_server_decoration_manager_send_default_mode(resource, ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
+}
+
+struct wl_global *
+kde_decoration_manager_create(struct wl_display *display)
+{
+ return wl_global_create(display, &org_kde_kwin_server_decoration_manager_interface, 1, NULL, &bind_decoration_manager);
+}
diff --git a/libswc/kde_decoration.h b/libswc/kde_decoration.h
@@ -0,0 +1,31 @@
+/* swc: libswc/kde_decoration.h
+ *
+ * Copyright (c) 2020 Michael Forney
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef SWC_KDE_DECORATION_H
+#define SWC_KDE_DECORATION_H
+
+struct wl_display;
+
+struct wl_global *kde_decoration_manager_create(struct wl_display *display);
+
+#endif
diff --git a/libswc/local.mk b/libswc/local.mk
@@ -30,6 +30,7 @@ SWC_SOURCES = \
libswc/dmabuf.c \
libswc/drm.c \
libswc/input.c \
+ libswc/kde_decoration.c \
libswc/keyboard.c \
libswc/launch.c \
libswc/mode.c \
@@ -56,6 +57,7 @@ SWC_SOURCES = \
libswc/xdg_decoration.c \
libswc/xdg_shell.c \
protocol/linux-dmabuf-unstable-v1-protocol.c \
+ protocol/server-decoration-protocol.c \
protocol/swc-protocol.c \
protocol/wayland-drm-protocol.c \
protocol/xdg-decoration-unstable-v1-protocol.c \
@@ -74,6 +76,7 @@ objects = $(foreach obj,$(1),$(dir)/$(obj).o $(dir)/$(obj).lo)
$(call objects,compositor panel_manager panel screen): protocol/swc-server-protocol.h
$(call objects,dmabuf): protocol/linux-dmabuf-unstable-v1-server-protocol.h
$(call objects,drm drm_buffer): protocol/wayland-drm-server-protocol.h
+$(call objects,kde_decoration): protocol/server-decoration-server-protocol.h
$(call objects,xdg_decoration): protocol/xdg-decoration-unstable-v1-server-protocol.h
$(call objects,xdg_shell): protocol/xdg-shell-server-protocol.h
$(call objects,pointer): cursor/cursor_data.h
diff --git a/libswc/swc.c b/libswc/swc.c
@@ -29,6 +29,7 @@
#include "event.h"
#include "internal.h"
#include "launch.h"
+#include "kde_decoration.h"
#include "keyboard.h"
#include "panel_manager.h"
#include "pointer.h"
@@ -174,16 +175,24 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
goto error11;
}
+ swc.kde_decoration_manager = kde_decoration_manager_create(display);
+ if (!swc.kde_decoration_manager) {
+ ERROR("Could not initialize KDE decoration manager\n");
+ goto error12;
+ }
+
swc.panel_manager = panel_manager_create(display);
if (!swc.panel_manager) {
ERROR("Could not initialize panel manager\n");
- goto error12;
+ goto error13;
}
setup_compositor();
return true;
+error13:
+ wl_global_destroy(swc.kde_decoration_manager);
error12:
wl_global_destroy(swc.xdg_decoration_manager);
error11:
diff --git a/protocol/local.mk b/protocol/local.mk
@@ -4,6 +4,7 @@ dir := protocol
wayland_protocols := $(call pkgconfig,wayland-protocols,variable=pkgdatadir,DATADIR)
PROTOCOL_EXTENSIONS = \
+ $(dir)/server-decoration.xml\
$(dir)/swc.xml \
$(dir)/wayland-drm.xml \
$(wayland_protocols)/stable/xdg-shell/xdg-shell.xml \
diff --git a/protocol/server-decoration.xml b/protocol/server-decoration.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="server_decoration">
+ <copyright><![CDATA[
+ Copyright (C) 2015 Martin Gräßlin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ ]]></copyright>
+ <interface name="org_kde_kwin_server_decoration_manager" version="1">
+ <description summary="Server side window decoration manager">
+ This interface allows to coordinate whether the server should create
+ a server-side window decoration around a wl_surface representing a
+ shell surface (wl_shell_surface or similar). By announcing support
+ for this interface the server indicates that it supports server
+ side decorations.
+
+ Use in conjunction with zxdg_decoration_manager_v1 is undefined.
+ </description>
+ <request name="create">
+ <description summary="Create a server-side decoration object for a given surface">
+ When a client creates a server-side decoration object it indicates
+ that it supports the protocol. The client is supposed to tell the
+ server whether it wants server-side decorations or will provide
+ client-side decorations.
+
+ If the client does not create a server-side decoration object for
+ a surface the server interprets this as lack of support for this
+ protocol and considers it as client-side decorated. Nevertheless a
+ client-side decorated surface should use this protocol to indicate
+ to the server that it does not want a server-side deco.
+ </description>
+ <arg name="id" type="new_id" interface="org_kde_kwin_server_decoration"/>
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+ <enum name="mode">
+ <description summary="Possible values to use in request_mode and the event mode."/>
+ <entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
+ <entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
+ <entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
+ </enum>
+ <event name="default_mode">
+ <description summary="The default mode used on the server">
+ This event is emitted directly after binding the interface. It contains
+ the default mode for the decoration. When a new server decoration object
+ is created this new object will be in the default mode until the first
+ request_mode is requested.
+
+ The server may change the default mode at any time.
+ </description>
+ <arg name="mode" type="uint" summary="The default decoration mode applied to newly created server decorations."/>
+ </event>
+ </interface>
+ <interface name="org_kde_kwin_server_decoration" version="1">
+ <request name="release" type="destructor">
+ <description summary="release the server decoration object"/>
+ </request>
+ <enum name="mode">
+ <description summary="Possible values to use in request_mode and the event mode."/>
+ <entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
+ <entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
+ <entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
+ </enum>
+ <request name="request_mode">
+ <description summary="The decoration mode the surface wants to use."/>
+ <arg name="mode" type="uint" summary="The mode this surface wants to use."/>
+ </request>
+ <event name="mode">
+ <description summary="The new decoration mode applied by the server">
+ This event is emitted directly after the decoration is created and
+ represents the base decoration policy by the server. E.g. a server
+ which wants all surfaces to be client-side decorated will send Client,
+ a server which wants server-side decoration will send Server.
+
+ The client can request a different mode through the decoration request.
+ The server will acknowledge this by another event with the same mode. So
+ even if a server prefers server-side decoration it's possible to force a
+ client-side decoration.
+
+ The server may emit this event at any time. In this case the client can
+ again request a different mode. It's the responsibility of the server to
+ prevent a feedback loop.
+ </description>
+ <arg name="mode" type="uint" summary="The decoration mode applied to the surface by the server."/>
+ </event>
+ </interface>
+</protocol>