command: fix possible crash on focus

If the currently focused view has been moved to a different output but
the transaction has not yet been completed, we can hit unreachable code
in this function.

thread 1073 panic: reached unreachable code
/home/pkaplan/Software/river/river/command/view_operations.zig💯21: 0x11752d6 in getTarget (river)
                    unreachable;
                    ^
/home/pkaplan/Software/river/river/command/view_operations.zig:46:22: 0x1146f36 in focusView (river)
    if (try getTarget(
                     ^
/home/pkaplan/Software/river/river/command.zig:144:16: 0x11124e3 in run (river)
    try impl_fn(seat, args, out);
               ^
/home/pkaplan/Software/river/river/Seat.zig:447:16: 0x10eb00f in runCommand (river)
    command.run(seat, args, &out) catch |err| {
               ^
/home/pkaplan/Software/river/river/Seat.zig:423:24: 0x1110350 in handleMapping (river)
        seat.runCommand(mapping.command_args);
                       ^
/home/pkaplan/Software/river/river/Keyboard.zig:213:47: 0x10e83b8 in wrapper (river)
        if (keyboard.device.seat.handleMapping(keycode, modifiers, released, xkb_state)) {
                                              ^
???:?:?: 0x7d8f73aa051d in ??? (libwayland-server.so.0)
Unwind information for `libwayland-server.so.0:0x7d8f73aa051d` was not available, trace may be incomplete

???:?:?: 0x7d8f739fecc7 in ??? (libwlroots-0.18.so)
???:?:?: 0x7d8f739d0dbb in ??? (libwlroots-0.18.so)
???:?:?: 0x7d8f73aa2111 in ??? (libwayland-server.so.0)
???:?:?: 0x7d8f73aa41f6 in ??? (libwayland-server.so.0)
/home/pkaplan/Software/river/river/main.zig:139:25: 0x10715dd in main (river)
    server.wl_server.run();
                        ^
/usr/lib/zig/std/start.zig:524:37: 0x107083e in main (river)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7d8f736b06b4 in ??? (libc.so.6)
???:?:?: 0x7d8f736b0768 in ??? (libc.so.6)
???:?:?: 0x1070354 in ??? (???)
This commit is contained in:
Isaac Freund
2025-10-03 11:28:19 +02:00
parent 633f4e2733
commit 165871e0fc

View File

@ -78,6 +78,7 @@ fn getTarget(seat: *Seat, direction_str: []const u8, target_mode: TargetMode) !?
if (seat.focused.view.pending.fullscreen) return null; if (seat.focused.view.pending.fullscreen) return null;
if (target_mode == .skip_float and seat.focused.view.pending.float) return null; if (target_mode == .skip_float and seat.focused.view.pending.float) return null;
const output = seat.focused_output orelse return null; const output = seat.focused_output orelse return null;
if (seat.focused.view.pending.output != output) return null;
// Logical direction, based on the view stack. // Logical direction, based on the view stack.
if (std.meta.stringToEnum(Direction, direction_str)) |direction| { if (std.meta.stringToEnum(Direction, direction_str)) |direction| {