]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Create xdg-deco.c
authorJohan Malm <jgm323@gmail.com>
Tue, 2 Mar 2021 20:53:03 +0000 (20:53 +0000)
committerJohan Malm <jgm323@gmail.com>
Tue, 2 Mar 2021 20:53:03 +0000 (20:53 +0000)
src/meson.build
src/xdg-deco.c [new file with mode: 0644]
src/xdg.c

index 2220eb249415c8647a48da17723b6e15d766eba9..d5389dd6dab451627122d97298223e3cd42e2d7a 100644 (file)
@@ -17,6 +17,7 @@ labwc_sources = files(
   'view.c',
   'view-child.c',
   'xdg.c',
+  'xdg-deco.c',
   'xdg-popup.c',
 )
 
diff --git a/src/xdg-deco.c b/src/xdg-deco.c
new file mode 100644 (file)
index 0000000..1bbe36c
--- /dev/null
@@ -0,0 +1,52 @@
+#include "labwc.h"
+
+struct xdg_deco {
+       struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration;
+       struct server *server;
+       struct wl_listener destroy;
+       struct wl_listener request_mode;
+};
+
+static void
+xdg_deco_destroy(struct wl_listener *listener, void *data)
+{
+       struct xdg_deco *xdg_deco =
+               wl_container_of(listener, xdg_deco, destroy);
+       wl_list_remove(&xdg_deco->destroy.link);
+       wl_list_remove(&xdg_deco->request_mode.link);
+       free(xdg_deco);
+}
+
+static void
+xdg_deco_request_mode(struct wl_listener *listener, void *data)
+{
+       struct xdg_deco *xdg_deco;
+       xdg_deco = wl_container_of(listener, xdg_deco, request_mode);
+       enum wlr_xdg_toplevel_decoration_v1_mode mode;
+       if (rc.xdg_shell_server_side_deco) {
+               mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
+       } else {
+               mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
+       }
+       wlr_xdg_toplevel_decoration_v1_set_mode(xdg_deco->wlr_decoration, mode);
+}
+
+void
+xdg_toplevel_decoration(struct wl_listener *listener, void *data)
+{
+       struct server *server =
+               wl_container_of(listener, server, xdg_toplevel_decoration);
+       struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration = data;
+       struct xdg_deco *xdg_deco = calloc(1, sizeof(struct xdg_deco));
+       if (!xdg_deco) {
+               return;
+       }
+       xdg_deco->wlr_decoration = wlr_decoration;
+       xdg_deco->server = server;
+       xdg_deco->destroy.notify = xdg_deco_destroy;
+       wl_signal_add(&wlr_decoration->events.destroy, &xdg_deco->destroy);
+       xdg_deco->request_mode.notify = xdg_deco_request_mode;
+       wl_signal_add(&wlr_decoration->events.request_mode,
+                     &xdg_deco->request_mode);
+       xdg_deco_request_mode(&xdg_deco->request_mode, wlr_decoration);
+}
index 73923291f72c94d704e37f5b311650ac2417894f..b5a7e87f44d332b4984e24b1af05e807a08dc4b4 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -1,58 +1,10 @@
 #include <assert.h>
 #include "labwc.h"
 
-struct xdg_deco {
-       struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration;
-       struct server *server;
-       struct wl_listener destroy;
-       struct wl_listener request_mode;
-};
-
-static void
-xdg_deco_destroy(struct wl_listener *listener, void *data)
-{
-       struct xdg_deco *xdg_deco =
-               wl_container_of(listener, xdg_deco, destroy);
-       wl_list_remove(&xdg_deco->destroy.link);
-       wl_list_remove(&xdg_deco->request_mode.link);
-       free(xdg_deco);
-}
-
-static void
-xdg_deco_request_mode(struct wl_listener *listener, void *data)
-{
-       struct xdg_deco *xdg_deco;
-       xdg_deco = wl_container_of(listener, xdg_deco, request_mode);
-       enum wlr_xdg_toplevel_decoration_v1_mode mode;
-       if (rc.xdg_shell_server_side_deco) {
-               mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
-       } else {
-               mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
-       }
-       wlr_xdg_toplevel_decoration_v1_set_mode(xdg_deco->wlr_decoration, mode);
-}
-
-void
-xdg_toplevel_decoration(struct wl_listener *listener, void *data)
-{
-       struct server *server =
-               wl_container_of(listener, server, xdg_toplevel_decoration);
-       struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration = data;
-       struct xdg_deco *xdg_deco = calloc(1, sizeof(struct xdg_deco));
-       if (!xdg_deco) {
-               return;
-       }
-       xdg_deco->wlr_decoration = wlr_decoration;
-       xdg_deco->server = server;
-       xdg_deco->destroy.notify = xdg_deco_destroy;
-       wl_signal_add(&wlr_decoration->events.destroy, &xdg_deco->destroy);
-       xdg_deco->request_mode.notify = xdg_deco_request_mode;
-       wl_signal_add(&wlr_decoration->events.request_mode,
-                     &xdg_deco->request_mode);
-       xdg_deco_request_mode(&xdg_deco->request_mode, wlr_decoration);
-}
-
-/* This is merely needed to track damage */
+/*
+ * xdg_popup_create() and subsurface_create() are only called for the
+ * purposes of tracking damage.
+ */
 static void
 handle_new_xdg_popup(struct wl_listener *listener, void *data)
 {
@@ -78,8 +30,8 @@ has_ssd(struct view *view)
 
        /*
         * Some XDG shells refuse to disable CSD in which case their
-        * geometry.{x,y} seems to be greater. We filter on that on the
-        * assumption that this will remain true.
+        * geometry.{x,y} seems to be greater than zero. We filter on that
+        * on the assumption that this will remain true.
         */
        if (view->xdg_surface->geometry.x || view->xdg_surface->geometry.y) {
                return false;