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 }; + } } }