layer-shell: fix overflow if desired size exceeds output bounds

This commit is contained in:
Isaac Freund 2022-05-16 19:03:23 +02:00
parent 47c02ebcbc
commit 7122df7ec4
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -313,7 +313,7 @@ fn arrangeLayer(
new_box.x = bounds.x + @intCast(i32, current_state.margin.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); new_box.width = bounds.width - (current_state.margin.left + current_state.margin.right);
} else if (current_state.anchor.left == current_state.anchor.right) { } else if (current_state.anchor.left == current_state.anchor.right) {
new_box.x = bounds.x + @intCast(i32, bounds.width / 2 - current_state.desired_width / 2); new_box.x = bounds.x + @intCast(i32, bounds.width / 2 -| current_state.desired_width / 2);
new_box.width = current_state.desired_width; new_box.width = current_state.desired_width;
} else if (current_state.anchor.left) { } else if (current_state.anchor.left) {
new_box.x = bounds.x + @intCast(i32, current_state.margin.left); new_box.x = bounds.x + @intCast(i32, current_state.margin.left);
@ -333,7 +333,7 @@ fn arrangeLayer(
new_box.y = bounds.y + @intCast(i32, current_state.margin.top); new_box.y = bounds.y + @intCast(i32, current_state.margin.top);
new_box.height = bounds.height - (current_state.margin.top + current_state.margin.bottom); new_box.height = bounds.height - (current_state.margin.top + current_state.margin.bottom);
} else if (current_state.anchor.top == current_state.anchor.bottom) { } else if (current_state.anchor.top == current_state.anchor.bottom) {
new_box.y = bounds.y + @intCast(i32, bounds.height / 2 - current_state.desired_height / 2); new_box.y = bounds.y + @intCast(i32, bounds.height / 2 -| current_state.desired_height / 2);
new_box.height = current_state.desired_height; new_box.height = current_state.desired_height;
} else if (current_state.anchor.top) { } else if (current_state.anchor.top) {
new_box.y = bounds.y + @intCast(i32, current_state.margin.top); new_box.y = bounds.y + @intCast(i32, current_state.margin.top);