From 5f4d80f31398570cbb45196b3d1b5e8f49005c4b Mon Sep 17 00:00:00 2001 From: Ben Buhse Date: Thu, 19 Feb 2026 14:01:51 -0600 Subject: [PATCH] Fix sendTo{Prev,Next}Output commands Before, they would try send the window to the "next" output even if there was only one output... which really just means sending the window to the bottom of the stack. Instead, they should be a noop. Also fixed a bug when removing all outputs where the seat wouldn't clear its focused output. --- src/Output.zig | 9 +++++++-- src/XkbBindings.zig | 15 +++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Output.zig b/src/Output.zig index 7e7d0ea..7930412 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -205,8 +205,13 @@ fn riverOutputListener(river_output_v1: *river.OutputV1, event: river.OutputV1.E if (seat.focused_output != output) break :blk; const next_output = wm.nextOutput(output); - if (next_output == output) break :blk; - const o = next_output orelse break :blk; + if (next_output == output or next_output == null) { + // This was the last output; clear focus + seat.pending_manage.output = .clear_focus; + seat.pending_manage.window = .clear_focus; + break :blk; + } + const o = next_output.?; seat.pending_manage.output = .{ .output = o }; if (o.windows.first()) |window| { diff --git a/src/XkbBindings.zig b/src/XkbBindings.zig index f0126c2..4ca36af 100644 --- a/src/XkbBindings.zig +++ b/src/XkbBindings.zig @@ -333,13 +333,16 @@ const XkbBinding = struct { }; if (pending_output) |output| { - // We have to remove window from current output's windows list first - window.link.remove(); - output.windows.append(window); + // This should be a noop if there's only one output + if (output != window.output) { + // We have to remove window from current output's windows list first + window.link.remove(); + output.windows.append(window); - seat.pending_manage.output = .{ .output = output }; - seat.pending_manage.should_warp_pointer = true; - window.pending_manage.pending_output = .{ .output = output }; + seat.pending_manage.output = .{ .output = output }; + seat.pending_manage.should_warp_pointer = true; + window.pending_manage.pending_output = .{ .output = output }; + } } }