diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-11 21:40:06 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-11 21:40:06 +0200 |
| commit | 59b9172393224dd988d281dbbec898decd24b649 (patch) | |
| tree | fae3ef240fd452e7236a86e9ba1a2d669df963f6 /src/output.zig | |
| parent | 03691722b2d608f173ec7adb872ffafef174f76c (diff) | |
| download | river-59b9172393224dd988d281dbbec898decd24b649.tar.gz river-59b9172393224dd988d281dbbec898decd24b649.tar.xz | |
Handle layer shell protocol error
Requesting a size of 0 without setting opposing anchors in that dimension is
a protocol error.
Diffstat (limited to 'src/output.zig')
| -rw-r--r-- | src/output.zig | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/output.zig b/src/output.zig index 10a9709..3aa1ae8 100644 --- a/src/output.zig +++ b/src/output.zig @@ -242,12 +242,20 @@ pub const Output = struct { // Horizontal alignment const anchor_left = @intCast(u32, c.ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT); const anchor_right = @intCast(u32, c.ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT); - if (current_state.anchor & (anchor_left | anchor_right) != 0 and - current_state.desired_width == 0) - { - new_box.x = bounds.x + @intCast(i32, current_state.margin.left); - new_box.width = bounds.width - - (current_state.margin.left + current_state.margin.right); + if (current_state.desired_width == 0) { + const anchor_left_right = anchor_left | anchor_right; + if (current_state.anchor & anchor_left_right == anchor_left_right) { + new_box.x = bounds.x + @intCast(i32, current_state.margin.left); + new_box.width = bounds.width - + (current_state.margin.left + current_state.margin.right); + } else { + Log.Error.log( + "Protocol Error: layer surface '{}' requested width 0 without anchoring to opposite edges.", + .{layer_surface.wlr_layer_surface.namespace}, + ); + c.wlr_layer_surface_v1_close(layer_surface.wlr_layer_surface); + continue; + } } else if (current_state.anchor & anchor_left != 0) { new_box.x = bounds.x + @intCast(i32, current_state.margin.left); new_box.width = current_state.desired_width; @@ -263,12 +271,20 @@ pub const Output = struct { // Vertical alignment const anchor_top = @intCast(u32, c.ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP); const anchor_bottom = @intCast(u32, c.ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM); - if (current_state.anchor & (anchor_top | anchor_bottom) != 0 and - current_state.desired_height == 0) - { - new_box.y = bounds.y + @intCast(i32, current_state.margin.top); - new_box.height = bounds.height - - (current_state.margin.top + current_state.margin.bottom); + if (current_state.desired_height == 0) { + const anchor_top_bottom = anchor_top | anchor_bottom; + if (current_state.anchor & anchor_top_bottom == anchor_top_bottom) { + new_box.y = bounds.y + @intCast(i32, current_state.margin.top); + new_box.height = bounds.height - + (current_state.margin.top + current_state.margin.bottom); + } else { + Log.Error.log( + "Protocol Error: layer surface '{}' requested height 0 without anchoring to opposite edges.", + .{layer_surface.wlr_layer_surface.namespace}, + ); + c.wlr_layer_surface_v1_close(layer_surface.wlr_layer_surface); + continue; + } } else if (current_state.anchor & anchor_top != 0) { new_box.y = bounds.y + @intCast(i32, current_state.margin.top); new_box.height = current_state.desired_height; |
