Skip to content

Commit

Permalink
focus: Fix active/focused output on refresh_focus
Browse files Browse the repository at this point in the history
Previously removing the last output could have left seats with an
invalid active output. We already have logic to check this in
`refresh_focus` but failed to apply it before `update_pointer_focus`.
Let's fix that.
  • Loading branch information
Drakulix committed Dec 16, 2024
1 parent f2e53f0 commit 7ac204e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/shell/focus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,19 +344,27 @@ impl Common {
.cloned()
.collect::<Vec<_>>();
for seat in &seats {
update_pointer_focus(state, &seat);

let mut shell = state.common.shell.write().unwrap();
let output = seat.focused_or_active_output();
{
let shell = state.common.shell.read().unwrap();
let focused_output = seat.focused_output();
let active_output = seat.active_output();

// If the focused or active output is not in the list of outputs, switch to the first output
if !shell.outputs().any(|o| o == &output) {
if let Some(other) = shell.outputs().next() {
seat.set_active_output(other);
// If the focused or active output is not in the list of outputs, switch to the first output
if focused_output.is_some_and(|f| !shell.outputs().any(|o| &f == o)) {
seat.set_focused_output(None);
}
if !shell.outputs().any(|o| o == &active_output) {
if let Some(other) = shell.outputs().next() {
seat.set_active_output(other);
}
continue;
}
continue;
}

update_pointer_focus(state, &seat);

let output = seat.focused_or_active_output();
let mut shell = state.common.shell.write().unwrap();
let last_known_focus = ActiveFocus::get(&seat);

if let Some(target) = last_known_focus {
Expand Down

0 comments on commit 7ac204e

Please sign in to comment.