From 5824f84c358c14731bc12d6bcbb620de794fcaa0 Mon Sep 17 00:00:00 2001 From: Ben Buhse Date: Tue, 17 Feb 2026 11:20:43 -0600 Subject: [PATCH] Fix zoom keybind bugs There were two bugs: 1) If we were focused on the first window and then tried to use the zoom keybind, we looked for the next tiled window in the list (correctly skipping floating windows), but we didn't also check the tags. This meant that if the next window was on a non-visible tag, it didn't work. 2) After fixing that, we weren't updating the focus to the newly promoted window, so the border would flash around the window that got moved to 2nd for a frame. We just needed to update the pending focus window for seat if we had to swap windows. --- src/XkbBindings.zig | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/XkbBindings.zig b/src/XkbBindings.zig index 3d968de..51ff05f 100644 --- a/src/XkbBindings.zig +++ b/src/XkbBindings.zig @@ -121,24 +121,31 @@ const XkbBinding = struct { if (current_focus.floating) return; // Get the first tiled window to try zoom with + // If the first window is focused, we instead try to get the second tiled window const output = current_focus.output orelse { - log.err("focused window has no output during zoom", .{}); + log.warn("Focused window has no output during zoom", .{}); return; }; + var focus_is_first_tiled = false; const first_tiled: *Window = blk: { var it = output.windows.iterator(.forward); while (it.next()) |window| { - if (window != current_focus and !window.floating) { - break :blk window; + if (window.floating or output.tags & window.tags == 0) continue; + if (window == current_focus) { + focus_is_first_tiled = true; + continue; } + break :blk window; } - // No (or only one) tiled windows, nothing to do + // No (or only one) visible tiled windows, nothing to do return; }; current_focus.link.swapWith(&first_tiled.link); - // Don't warp pointer if the first was the one focused before - if (output.windows.first() == current_focus) { + // Update focus + seat.pending_manage.window = .{ .window = current_focus }; + // Warp pointer when the focused window is promoted to primary + if (!focus_is_first_tiled) { seat.pending_manage.should_warp_pointer = true; } },