commit bc903f4d01de470ed6479aa7ad5af0406ccf3f10
parent 27d50e52dc4b86a064d534f4f5b3d142bfaebf00
Author: Michael Forney <mforney@mforney.org>
Date: Mon, 27 Jan 2020 22:04:39 -0800
Add support for xdg-decoration protocol
Diffstat:
7 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -6,6 +6,8 @@ protocol/swc-protocol.c
protocol/swc-server-protocol.h
protocol/wayland-drm-protocol.c
protocol/wayland-drm-server-protocol.h
+protocol/xdg-decoration-unstable-v1-protocol.c
+protocol/xdg-decoration-unstable-v1-server-protocol.h
protocol/xdg-shell-protocol.c
protocol/xdg-shell-server-protocol.h
protocol/linux-dmabuf-unstable-v1-server-protocol.h
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -49,6 +49,7 @@ struct swc {
struct wl_global *panel_manager;
struct wl_global *shell;
struct wl_global *subcompositor;
+ struct wl_global *xdg_decoration_manager;
struct wl_global *xdg_shell;
};
diff --git a/libswc/local.mk b/libswc/local.mk
@@ -53,11 +53,13 @@ SWC_SOURCES = \
libswc/view.c \
libswc/wayland_buffer.c \
libswc/window.c \
+ libswc/xdg_decoration.c \
libswc/xdg_shell.c \
+ protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/swc-protocol.c \
protocol/wayland-drm-protocol.c \
- protocol/xdg-shell-protocol.c \
- protocol/linux-dmabuf-unstable-v1-protocol.c
+ protocol/xdg-decoration-unstable-v1-protocol.c \
+ protocol/xdg-shell-protocol.c
ifeq ($(ENABLE_LIBUDEV),1)
$(dir)_CFLAGS += -DENABLE_LIBUDEV
@@ -72,6 +74,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,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
@@ -39,6 +39,7 @@
#include "subcompositor.h"
#include "util.h"
#include "window.h"
+#include "xdg_decoration.h"
#include "xdg_shell.h"
extern struct swc_launch swc_launch;
@@ -167,16 +168,24 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, con
goto error10;
}
+ swc.xdg_decoration_manager = xdg_decoration_manager_create(display);
+ if (!swc.xdg_decoration_manager) {
+ ERROR("Could not initialize XDG decoration manager\n");
+ goto error11;
+ }
+
swc.panel_manager = panel_manager_create(display);
if (!swc.panel_manager) {
ERROR("Could not initialize panel manager\n");
- goto error11;
+ goto error12;
}
setup_compositor();
return true;
+error12:
+ wl_global_destroy(swc.xdg_decoration_manager);
error11:
wl_global_destroy(swc.xdg_shell);
error10:
@@ -207,6 +216,7 @@ EXPORT void
swc_finalize(void)
{
wl_global_destroy(swc.panel_manager);
+ wl_global_destroy(swc.xdg_decoration_manager);
wl_global_destroy(swc.xdg_shell);
wl_global_destroy(swc.shell);
seat_destroy(swc.seat);
diff --git a/libswc/xdg_decoration.c b/libswc/xdg_decoration.c
@@ -0,0 +1,63 @@
+/* swc: libswc/xdg_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 "xdg_decoration.h"
+#include "util.h"
+
+#include <wayland-server.h>
+#include "xdg-decoration-unstable-v1-server-protocol.h"
+
+static void
+get_toplevel_decoration(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, &zxdg_toplevel_decoration_v1_interface, wl_resource_get_version(resource), id);
+ if (!decoration)
+ wl_resource_post_no_memory(resource);
+ zxdg_toplevel_decoration_v1_send_configure(decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
+}
+
+static const struct zxdg_decoration_manager_v1_interface decoration_manager_impl = {
+ .destroy = destroy_resource,
+ .get_toplevel_decoration = get_toplevel_decoration,
+};
+
+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, &zxdg_decoration_manager_v1_interface, version, id);
+ if (!resource) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+ wl_resource_set_implementation(resource, &decoration_manager_impl, NULL, NULL);
+}
+
+struct wl_global *
+xdg_decoration_manager_create(struct wl_display *display)
+{
+ return wl_global_create(display, &zxdg_decoration_manager_v1_interface, 1, NULL, &bind_decoration_manager);
+}
diff --git a/libswc/xdg_decoration.h b/libswc/xdg_decoration.h
@@ -0,0 +1,31 @@
+/* swc: libswc/xdg_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_XDG_DECORATION_H
+#define SWC_XDG_DECORATION_H
+
+struct wl_display;
+
+struct wl_global *xdg_decoration_manager_create(struct wl_display *display);
+
+#endif
diff --git a/protocol/local.mk b/protocol/local.mk
@@ -7,7 +7,8 @@ PROTOCOL_EXTENSIONS = \
$(dir)/swc.xml \
$(dir)/wayland-drm.xml \
$(wayland_protocols)/stable/xdg-shell/xdg-shell.xml \
- $(wayland_protocols)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+ $(wayland_protocols)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml \
+ $(wayland_protocols)/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
$(dir)_PACKAGES := wayland-server