From 51727cf8f702ee2e2c8617fddcf19a4edcf2a51f Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Wed, 6 Jul 2022 17:37:22 +0200 Subject: [PATCH] SnapToRegion: Add implementation --- include/common/graphic-helpers.h | 1 + include/regions.h | 30 +++++++++++++++++++++++++ src/regions.c | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 include/regions.h create mode 100644 src/regions.c diff --git a/include/common/graphic-helpers.h b/include/common/graphic-helpers.h index 6ee4d2f6..c8c8a1dc 100644 --- a/include/common/graphic-helpers.h +++ b/include/common/graphic-helpers.h @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include struct wlr_scene_tree; diff --git a/include/regions.h b/include/regions.h new file mode 100644 index 00000000..f071c64a --- /dev/null +++ b/include/regions.h @@ -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 index 00000000..47b75d88 --- /dev/null +++ b/src/regions.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#define _POSIX_C_SOURCE 200809L +#include +#include +#include +#include +#include +#include +#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(®ion->link); + zfree(region->name); + zfree(region); + } +} + -- 2.52.0