layer-shell: allow surfaces larger than the output
The motivation for this change is to simplify the implementation and remove a massive footgun that is currently present and causing UB/crashes. If a layer surface is destroyed in arrangeLayers() then the code in LayerSurface.handleCommit() after the arrangeLayers() call accesses free'd memory. This is of course possible to fix, but it's far simpler to loosen up the protocol implementation a bit. The new implementation is also in line with what sway and the new wlroots layer shell helper do and is perfectly valid according to the protocol.
This commit is contained in:
parent
c4c0bece59
commit
adf6e1f19d
@ -308,17 +308,7 @@ fn arrangeLayer(
|
||||
var new_box: Box = undefined;
|
||||
|
||||
// Horizontal alignment
|
||||
const horizontal_margin_size = current_state.margin.left + current_state.margin.right;
|
||||
if (horizontal_margin_size + current_state.desired_width > bounds.width) {
|
||||
std.log.scoped(.layer_shell).warn(
|
||||
"margins of layer surface '{s}' are too large to be reasonably handled. Closing.",
|
||||
.{layer_surface.wlr_layer_surface.namespace},
|
||||
);
|
||||
// This will cause the output to be rearranged, so it's fine to
|
||||
// stop this attempt early.
|
||||
layer_surface.wlr_layer_surface.destroy();
|
||||
return;
|
||||
} else if (current_state.desired_width == 0) {
|
||||
if (current_state.desired_width == 0) {
|
||||
assert(current_state.anchor.right and current_state.anchor.left);
|
||||
new_box.x = bounds.x + @intCast(i32, current_state.margin.left);
|
||||
new_box.width = bounds.width - (current_state.margin.left + current_state.margin.right);
|
||||
@ -336,17 +326,7 @@ fn arrangeLayer(
|
||||
}
|
||||
|
||||
// Vertical alignment
|
||||
const vertical_margin_size = current_state.margin.bottom + current_state.margin.top;
|
||||
if (vertical_margin_size + current_state.desired_height > bounds.height) {
|
||||
std.log.scoped(.layer_shell).warn(
|
||||
"margins of layer surface '{s}' are too large to be reasonably handled. Closing.",
|
||||
.{layer_surface.wlr_layer_surface.namespace},
|
||||
);
|
||||
layer_surface.wlr_layer_surface.destroy();
|
||||
// This will cause the output to be rearranged, so it's fine to
|
||||
// stop this attempt early.
|
||||
return;
|
||||
} else if (current_state.desired_height == 0) {
|
||||
if (current_state.desired_height == 0) {
|
||||
assert(current_state.anchor.top and current_state.anchor.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);
|
||||
|
Loading…
Reference in New Issue
Block a user