diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2021-08-02 16:16:58 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2021-08-02 16:16:58 +0200 |
| commit | 2fc0875a3e17a0328d14d0c6323bd8022d5b15de (patch) | |
| tree | e81951911e1e9cd0b699a0674d387c52809a203b | |
| parent | 295f965f9179d99c421decb67611b83605d5fcad (diff) | |
| download | river-2fc0875a3e17a0328d14d0c6323bd8022d5b15de.tar.gz river-2fc0875a3e17a0328d14d0c6323bd8022d5b15de.tar.xz | |
river: fix crash on disabling all outputs
If using the on-output-change cursor warp option river currently crashes
when the last real output is disabled as the noop output used as a
fallback is not present in the output layout.
| -rw-r--r-- | river/Seat.zig | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/river/Seat.zig b/river/Seat.zig index 0d25860..95a5e3f 100644 --- a/river/Seat.zig +++ b/river/Seat.zig @@ -256,6 +256,16 @@ pub fn setFocusRaw(self: *Self, new_focus: FocusTarget) void { pub fn focusOutput(self: *Self, output: *Output) void { if (self.focused_output == output) return; + var it = self.status_trackers.first; + while (it) |node| : (it = node.next) node.data.sendOutput(.unfocused); + + self.focused_output = output; + + it = self.status_trackers.first; + while (it) |node| : (it = node.next) node.data.sendOutput(.focused); + + if (self.focused_output == &server.root.noop_output) return; + // Warp pointer to center of newly focused output (In layout coordinates), // but only if cursor is not already on the output and this feature is enabled. switch (server.config.warp_cursor) { @@ -272,14 +282,6 @@ pub fn focusOutput(self: *Self, output: *Output) void { } }, } - - var it = self.status_trackers.first; - while (it) |node| : (it = node.next) node.data.sendOutput(.unfocused); - - self.focused_output = output; - - it = self.status_trackers.first; - while (it) |node| : (it = node.next) node.data.sendOutput(.focused); } pub fn handleActivity(self: Self) void { |
