diff --git a/include/wlr/types/wlr_layer_shell_v1.h b/include/wlr/types/wlr_layer_shell_v1.h index c0043ee1..9be246e1 100644 --- a/include/wlr/types/wlr_layer_shell_v1.h +++ b/include/wlr/types/wlr_layer_shell_v1.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "wlr-layer-shell-unstable-v1-protocol.h" /** @@ -187,4 +188,11 @@ struct wlr_surface *wlr_layer_surface_v1_popup_surface_at( struct wlr_layer_surface_v1 *wlr_layer_surface_v1_from_resource( struct wl_resource *resource); +/** + * Get the edge the exclusive zone must be applied to. + * + * Returns WLR_EDGE_NONE if the exclusive zone is nonpositive or must not be applied. + */ +enum wlr_edges wlr_layer_surface_v1_get_exclusive_edge(struct wlr_layer_surface_v1 *surface); + #endif diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c index 718c63b7..6df4b7a8 100644 --- a/types/wlr_layer_shell_v1.c +++ b/types/wlr_layer_shell_v1.c @@ -654,3 +654,33 @@ struct wlr_surface *wlr_layer_surface_v1_popup_surface_at( return NULL; } + +enum wlr_edges wlr_layer_surface_v1_get_exclusive_edge(struct wlr_layer_surface_v1 *surface) { + if (surface->current.exclusive_zone <= 0) { + return WLR_EDGE_NONE; + } + uint32_t anchor = surface->current.anchor; + if (surface->current.exclusive_edge != 0) { + anchor = surface->current.exclusive_edge; + } + switch (anchor) { + case ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP: + case ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP: + return WLR_EDGE_TOP; + case ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM: + case ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | + ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM: + return WLR_EDGE_BOTTOM; + case ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT: + case ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | + ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT: + return WLR_EDGE_LEFT; + case ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT: + case ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | + ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT: + return WLR_EDGE_RIGHT; + default: + return WLR_EDGE_NONE; + } +}