commit 4707d48ab6673369b8e79e5103a0604121db471c
parent 9faf0d298561aeae84e78b9f1b85bf0704cd0f24
Author: dalem <lain@dalem.foo>
Date: Sat, 21 Feb 2026 23:36:28 +0100
Add an offset on the Y axis to the panel protocol
This adds an option to offset the geometry of a panel by set amount of pixels
New function provided and accesible via the protocol: set_y_offset
Diffstat:
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/libswc/panel.c b/libswc/panel.c
@@ -46,6 +46,7 @@ struct panel {
struct screen_modifier modifier;
uint32_t edge;
uint32_t offset, strut_size;
+ uint32_t y_offset;
bool docked;
};
@@ -59,11 +60,11 @@ update_position(struct panel *panel)
switch (panel->edge) {
case SWC_PANEL_EDGE_TOP:
x = screen->x + panel->offset;
- y = screen->y;
+ y = screen->y + panel->y_offset;
break;
case SWC_PANEL_EDGE_BOTTOM:
x = screen->x + panel->offset;
- y = screen->y + screen->height - view->height;
+ y = screen->y + screen->height - view->height - panel->y_offset;
break;
case SWC_PANEL_EDGE_LEFT:
x = screen->x;
@@ -140,6 +141,18 @@ set_offset(struct wl_client *client, struct wl_resource *resource,
}
static void
+set_y_offset(struct wl_client *client, struct wl_resource *resource,
+ uint32_t offset)
+{
+ struct panel *panel = wl_resource_get_user_data(resource);
+
+ panel->y_offset = offset;
+ if (panel->docked) {
+ update_position(panel);
+ }
+}
+
+static void
set_strut(struct wl_client *client, struct wl_resource *resource, uint32_t size,
uint32_t begin, uint32_t end)
{
@@ -154,6 +167,7 @@ set_strut(struct wl_client *client, struct wl_resource *resource, uint32_t size,
static const struct swc_panel_interface panel_impl = {
.dock = dock,
.set_offset = set_offset,
+ .set_y_offset = set_y_offset,
.set_strut = set_strut,
};
@@ -257,6 +271,7 @@ panel_new(struct wl_client *client, uint32_t version, uint32_t id,
panel->modifier.modify = &modify;
panel->screen = NULL;
panel->offset = 0;
+ panel->y_offset = 0;
panel->strut_size = 0;
panel->docked = false;
wl_list_insert(&panel->view->base.handlers, &panel->view_handler.link);
diff --git a/protocol/swc.xml b/protocol/swc.xml
@@ -56,6 +56,10 @@
<arg name="offset" type="uint" />
</request>
+ <request name="set_y_offset">
+ <arg name="offset" type="uint" />
+ </request>
+
<request name="set_strut">
<arg name="size" type="uint" />
<arg name="begin" type="uint" />