mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
layer-shell: error on 0 dimension without anchors
The protocol requires clients to set opposing anchors when requesting a width or height of 0. The goal of this patch is not to break clients that rely on this behavior but to improve the consistency of the layer shell ecosystem through adherence to the protocol.
This commit is contained in:
parent
c150177a94
commit
b2daec9c4e
1 changed files with 24 additions and 6 deletions
|
|
@ -115,9 +115,18 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list,
|
|||
// Horizontal axis
|
||||
const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
|
||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
if ((state->anchor & both_horiz) && box.width == 0) {
|
||||
if (box.width == 0) {
|
||||
if ((state->anchor & both_horiz) == both_horiz) {
|
||||
box.x = bounds.x;
|
||||
box.width = bounds.width;
|
||||
} else {
|
||||
sway_log(SWAY_ERROR, "layer surface '%s' requested width 0 "
|
||||
"without setting left and right anchors", layer->namespace);
|
||||
wl_resource_post_error(layer->resource,
|
||||
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE,
|
||||
"width 0 requested without setting left and right anchors");
|
||||
continue;
|
||||
}
|
||||
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) {
|
||||
box.x = bounds.x;
|
||||
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) {
|
||||
|
|
@ -128,9 +137,18 @@ static void arrange_layer(struct sway_output *output, struct wl_list *list,
|
|||
// Vertical axis
|
||||
const uint32_t both_vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
|
||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
|
||||
if ((state->anchor & both_vert) && box.height == 0) {
|
||||
if (box.height == 0) {
|
||||
if ((state->anchor & both_vert) == both_vert) {
|
||||
box.y = bounds.y;
|
||||
box.height = bounds.height;
|
||||
} else {
|
||||
sway_log(SWAY_ERROR, "layer surface '%s' requested height 0 "
|
||||
"without setting top and bottom anchors", layer->namespace);
|
||||
wl_resource_post_error(layer->resource,
|
||||
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE,
|
||||
"height 0 requested without setting top and bottom anchors");
|
||||
continue;
|
||||
}
|
||||
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) {
|
||||
box.y = bounds.y;
|
||||
} else if ((state->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue