Implement floating windows

As of this commit, there's not-yet a way to resize or move floating
windows, but it's possible to create one and focus through all windows.

Floating windows are always above tiled windows and, if floating window
is focused, that window is always above any another floating windows.

Windows have a separate float_{x, y, width, height} to remember their
floating location if they go from float=>tiled=>float again.
This commit is contained in:
Ben Buhse 2026-02-05 17:09:58 -06:00
commit 6d4352a217
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
7 changed files with 100 additions and 20 deletions

View file

@ -188,9 +188,24 @@ pub fn manage(output: *Output) void {
}
pub fn render(output: *Output) void {
const seat = output.context.wm.seats.first();
const focused = if (seat) |s| s.focused_window else null;
var it = output.windows.iterator(.forward);
while (it.next()) |window| {
window.render();
// Make sure floating windows are above tiled windows
if (window.floating and output.tags & window.tags != 0 and window != focused) {
window.river_node_v1.placeTop();
}
}
// Make sure that the *focused* floating window goes above any other floating windows
if (focused) |f| {
if (f.floating and f.output == output and output.tags & f.tags != 0) {
f.river_node_v1.placeTop();
}
}
}
@ -206,8 +221,12 @@ fn calculatePrimaryStackLayout(output: *Output) void {
var it = output.windows.iterator(.forward);
while (it.next()) |window| {
if (output.tags & window.tags != 0x0000) {
active_list.append(&window.active_list_node);
active_count += 1;
// Floating windows should be shown but not included in this layout generation
const will_float = window.pending_manage.floating orelse window.floating;
if (!will_float) {
active_count += 1;
active_list.append(&window.active_list_node);
}
window.pending_render.show = true;
} else {
window.pending_render.show = false;