Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 8dec751

Browse files
ifreundemersion
authored andcommitted
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.
1 parent 5012121 commit 8dec751

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

types/wlr_layer_shell_v1.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,26 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
307307
return;
308308
}
309309

310+
const uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
311+
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
312+
if (surface->client_pending.desired_width == 0 &&
313+
(surface->client_pending.anchor & horiz) != horiz) {
314+
wl_resource_post_error(surface->resource,
315+
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE,
316+
"width 0 requested without setting left and right anchors");
317+
return;
318+
}
319+
320+
const uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
321+
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
322+
if (surface->client_pending.desired_height == 0 &&
323+
(surface->client_pending.anchor & vert) != vert) {
324+
wl_resource_post_error(surface->resource,
325+
ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE,
326+
"height 0 requested without setting top and bottom anchors");
327+
return;
328+
}
329+
310330
if (surface->closed) {
311331
// Ignore commits after the compositor has closed it
312332
return;

0 commit comments

Comments
 (0)