scene/layer_shell_v1: Add support for exclusive_edge

The v5 layer shell interface allows the client to specify which edge the
exclusive zone will apply to, instead of deducing it from the anchor
points. Add support for this to the layer shell scene helper.
This commit is contained in:
Kenny Levinsen 2026-02-24 11:52:00 +01:00 committed by Simon Ser
parent 2367d78c3c
commit 1ce992d7cb

View file

@ -1,6 +1,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <wlr/types/wlr_scene.h> #include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/util/edges.h>
static void scene_layer_surface_handle_tree_destroy( static void scene_layer_surface_handle_tree_destroy(
struct wl_listener *listener, void *data) { struct wl_listener *listener, void *data) {
@ -21,36 +22,23 @@ static void scene_layer_surface_handle_layer_surface_destroy(
static void layer_surface_exclusive_zone( static void layer_surface_exclusive_zone(
struct wlr_layer_surface_v1_state *state, struct wlr_layer_surface_v1_state *state,
enum wlr_edges edge,
struct wlr_box *usable_area) { struct wlr_box *usable_area) {
switch (state->anchor) { switch (edge) {
case ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP: case WLR_EDGE_NONE:
case (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | return;
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | case WLR_EDGE_TOP:
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT):
// Anchor top
usable_area->y += state->exclusive_zone + state->margin.top; usable_area->y += state->exclusive_zone + state->margin.top;
usable_area->height -= state->exclusive_zone + state->margin.top; usable_area->height -= state->exclusive_zone + state->margin.top;
break; break;
case ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM: case WLR_EDGE_BOTTOM:
case (ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT):
// Anchor bottom
usable_area->height -= state->exclusive_zone + state->margin.bottom; usable_area->height -= state->exclusive_zone + state->margin.bottom;
break; break;
case ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT: case WLR_EDGE_LEFT:
case (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT):
// Anchor left
usable_area->x += state->exclusive_zone + state->margin.left; usable_area->x += state->exclusive_zone + state->margin.left;
usable_area->width -= state->exclusive_zone + state->margin.left; usable_area->width -= state->exclusive_zone + state->margin.left;
break; break;
case ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT: case WLR_EDGE_RIGHT:
case (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT):
// Anchor right
usable_area->width -= state->exclusive_zone + state->margin.right; usable_area->width -= state->exclusive_zone + state->margin.right;
break; break;
} }
@ -121,7 +109,8 @@ void wlr_scene_layer_surface_v1_configure(
wlr_layer_surface_v1_configure(layer_surface, box.width, box.height); wlr_layer_surface_v1_configure(layer_surface, box.width, box.height);
if (layer_surface->surface->mapped && state->exclusive_zone > 0) { if (layer_surface->surface->mapped && state->exclusive_zone > 0) {
layer_surface_exclusive_zone(state, usable_area); enum wlr_edges edge = wlr_layer_surface_v1_get_exclusive_edge(layer_surface);
layer_surface_exclusive_zone(state, edge, usable_area);
} }
} }