]> git.mdlowis.com Git - proto/labwc.git/commitdiff
SnapToRegion: Add implementation
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 6 Jul 2022 15:37:22 +0000 (17:37 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 10 Jan 2023 22:29:10 +0000 (23:29 +0100)
include/common/graphic-helpers.h
include/regions.h [new file with mode: 0644]
src/regions.c [new file with mode: 0644]

index 6ee4d2f6d7563fb45b91da6ca029e79c91ec592b..c8c8a1dc7326754e97c8f3cb8e05395d98f88f94 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#include <cairo.h>
 #include <wayland-server-core.h>
 
 struct wlr_scene_tree;
diff --git a/include/regions.h b/include/regions.h
new file mode 100644 (file)
index 0000000..f071c64
--- /dev/null
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __LABWC_REGIONS_H
+#define __LABWC_REGIONS_H
+
+//FIXME: ignore that there could be more than a single seat
+
+struct seat;
+struct view;
+struct server;
+struct output;
+struct wl_list;
+struct wlr_box;
+
+/* Double use: rcxml.c for config and output.c for usage */
+struct region {
+       struct wl_list link; /* struct rcxml.regions, struct output.regions */
+       char *name;
+       struct wlr_box geo;
+       struct wlr_box percentage;
+       struct {
+               int x;
+               int y;
+       } center;
+};
+
+void regions_init(struct server *server, struct seat *seat);
+void regions_update(struct output *output);
+void regions_destroy(struct wl_list *regions);
+
+#endif /* __LABWC_REGIONS_H */
diff --git a/src/regions.c b/src/regions.c
new file mode 100644 (file)
index 0000000..47b75d8
--- /dev/null
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define _POSIX_C_SOURCE 200809L
+#include <assert.h>
+#include <float.h>
+#include <string.h>
+#include <wlr/types/wlr_scene.h>
+#include <wlr/util/box.h>
+#include <wlr/util/log.h>
+#include "common/graphic-helpers.h"
+#include "common/mem.h"
+#include "labwc.h"
+#include "regions.h"
+
+void
+regions_init(struct server *server, struct seat *seat)
+{
+       /* To be filled later */
+}
+
+void
+regions_update(struct output *output)
+{
+       /* To be filled later */
+}
+
+void
+regions_destroy(struct wl_list *regions)
+{
+       assert(regions);
+       struct region *region, *region_tmp;
+       wl_list_for_each_safe(region, region_tmp, regions, link) {
+               wl_list_remove(&region->link);
+               zfree(region->name);
+               zfree(region);
+       }
+}
+