Add layer shell support and fix floating windows
Now, I actually save the river-layer-shell-v1 and keep track of the non-exclusive area. The layout calculation uses the usable area instead of the entire output's geometry. I removed boundary clamping for the floating windows because it was a bit janky when hitting the edges. I'll probably add it back at some point. I also made windows default to 75% of the usable area instead of keeping their tiled size so that maximized windows look decent when floating for the first time. Finally, since I removed the clamping, I added a center_float keybind to center a floating window. If you're cycling through focused windows and one isn't on the screen, you can use the center_float bind to get the window visible again. Replaced all divTrunc with divFloor to be consistent. I think they should all be positive, anyways, so they'd be the same, but I like just having one.
This commit is contained in:
parent
6bf607b759
commit
5c427234d7
9 changed files with 108 additions and 71 deletions
|
|
@ -184,14 +184,17 @@ pub fn manage(window: *Window) void {
|
|||
river_window_v1.setTiled(.{});
|
||||
|
||||
if (window.float_width == 0) {
|
||||
// Never floated before; use current dimensions but centered on output
|
||||
window.float_width = window.width;
|
||||
window.float_height = window.height;
|
||||
// Never floated before; use 75% of usable area, centered on output
|
||||
if (window.output) |output| {
|
||||
// Need to find center and then subtract half of the window's width/height
|
||||
window.float_x = output.x + @divTrunc(output.width, 2) - @divTrunc(window.width, 2);
|
||||
window.float_y = output.y + @divTrunc(output.height, 2) - @divTrunc(window.height, 2);
|
||||
window.float_width = @divFloor(output.usable_width * 3, 4);
|
||||
window.float_height = @divFloor(output.usable_height * 3, 4);
|
||||
window.float_x = output.usable_x + @divFloor(output.usable_width, 2) - @divFloor(window.float_width, 2);
|
||||
window.float_y = output.usable_y + @divFloor(output.usable_height, 2) - @divFloor(window.float_height, 2);
|
||||
} else {
|
||||
window.float_width = window.width;
|
||||
window.float_height = window.height;
|
||||
}
|
||||
river_window_v1.proposeDimensions(window.float_width, window.float_height);
|
||||
} else {
|
||||
// Window has floated before; re-use its old dimensions
|
||||
river_window_v1.proposeDimensions(window.float_width, window.float_height);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue