Handle exclusive zone of -1 properly

This commit is contained in:
Isaac Freund 2020-04-15 14:35:05 +02:00
parent 5bbfcab60e
commit 652a347fa0
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -194,7 +194,7 @@ pub const Output = struct {
/// Arrange all layer surfaces of this output and addjust the usable aread /// Arrange all layer surfaces of this output and addjust the usable aread
pub fn arrangeLayers(self: *Self) void { pub fn arrangeLayers(self: *Self) void {
var bounds = blk: { const full_box = blk: {
var width: c_int = undefined; var width: c_int = undefined;
var height: c_int = undefined; var height: c_int = undefined;
c.wlr_output_effective_resolution(self.wlr_output, &width, &height); c.wlr_output_effective_resolution(self.wlr_output, &width, &height);
@ -206,26 +206,35 @@ pub const Output = struct {
}; };
}; };
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY)], &bounds, true); // This box is modified as exclusive zones are applied
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_TOP)], &bounds, true); var usable_box = full_box;
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)], &bounds, true);
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND)], &bounds, true);
if (self.usable_box.width != bounds.width or self.usable_box.height != bounds.height) { self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY)], full_box, &usable_box, true);
self.usable_box = bounds; self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_TOP)], full_box, &usable_box, true);
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)], full_box, &usable_box, true);
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND)], full_box, &usable_box, true);
if (self.usable_box.width != usable_box.width or self.usable_box.height != usable_box.height) {
self.usable_box = usable_box;
self.root.arrange(); self.root.arrange();
} }
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY)], &bounds, false); self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY)], full_box, &usable_box, false);
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_TOP)], &bounds, false); self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_TOP)], full_box, &usable_box, false);
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)], &bounds, false); self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)], full_box, &usable_box, false);
self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND)], &bounds, false); self.arrangeLayer(self.layers[@intCast(usize, c.ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND)], full_box, &usable_box, false);
// TODO: handle seat focus // TODO: handle seat focus
} }
/// Arrange the layer surfaces of a given layer /// Arrange the layer surfaces of a given layer
fn arrangeLayer(self: *Self, layer: std.TailQueue(LayerSurface), bounds: *Box, exclusive: bool) void { fn arrangeLayer(
self: *Self,
layer: std.TailQueue(LayerSurface),
full_box: Box,
usable_box: *Box,
exclusive: bool,
) void {
var it = layer.first; var it = layer.first;
while (it) |node| : (it = node.next) { while (it) |node| : (it = node.next) {
const layer_surface = &node.data; const layer_surface = &node.data;
@ -237,6 +246,10 @@ pub const Output = struct {
continue; continue;
} }
// If the exclusive zone is set to -1, this means the the client would like
// to ignore any exclusive zones and use the full area of the output.
const bounds = if (current_state.exclusive_zone == -1) &full_box else usable_box;
var new_box: Box = undefined; var new_box: Box = undefined;
// Horizontal alignment // Horizontal alignment
@ -308,26 +321,26 @@ pub const Output = struct {
}{ }{
.{ .{
.anchors = anchor_left | anchor_right | anchor_top, .anchors = anchor_left | anchor_right | anchor_top,
.to_increase = &bounds.y, .to_increase = &usable_box.y,
.to_decrease = &bounds.height, .to_decrease = &usable_box.height,
.margin = current_state.margin.top, .margin = current_state.margin.top,
}, },
.{ .{
.anchors = anchor_left | anchor_right | anchor_bottom, .anchors = anchor_left | anchor_right | anchor_bottom,
.to_increase = null, .to_increase = null,
.to_decrease = &bounds.height, .to_decrease = &usable_box.height,
.margin = current_state.margin.bottom, .margin = current_state.margin.bottom,
}, },
.{ .{
.anchors = anchor_left | anchor_top | anchor_bottom, .anchors = anchor_left | anchor_top | anchor_bottom,
.to_increase = &bounds.x, .to_increase = &usable_box.x,
.to_decrease = &bounds.width, .to_decrease = &usable_box.width,
.margin = current_state.margin.left, .margin = current_state.margin.left,
}, },
.{ .{
.anchors = anchor_right | anchor_top | anchor_bottom, .anchors = anchor_right | anchor_top | anchor_bottom,
.to_increase = null, .to_increase = null,
.to_decrease = &bounds.width, .to_decrease = &usable_box.width,
.margin = current_state.margin.right, .margin = current_state.margin.right,
}, },
}; };