Skip to content

Commit

Permalink
shell: prevent focus stealing
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Nov 7, 2023
1 parent 0ef78e9 commit e5ec54e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,12 +1435,21 @@ impl Shell {
workspace.fullscreen_request(&mapped.active_window(), None);
}

if workspace.output == seat.active_output() && active_handle == workspace.handle {
// TODO: enforce focus stealing prevention by also checking the same rules as for the else case.
Shell::set_focus(state, Some(&KeyboardFocusTarget::from(mapped)), &seat, None);
} else if workspace_empty || workspace_handle.is_some() || should_be_fullscreen {
let should_change_focus =
workspace_empty || workspace_handle.is_some() || should_be_fullscreen;
let is_active_workspace =
workspace.output == seat.active_output() && active_handle == workspace.handle;

if should_change_focus {
if is_active_workspace {
Shell::set_focus(state, Some(&KeyboardFocusTarget::from(mapped)), &seat, None);
} else {
let handle = workspace.handle;
Shell::append_focus_stack(state, Some(&KeyboardFocusTarget::from(mapped)), &seat);
state.common.shell.set_urgent(&handle);
}
} else if !is_active_workspace {
let handle = workspace.handle;
Shell::append_focus_stack(state, Some(&KeyboardFocusTarget::from(mapped)), &seat);
state.common.shell.set_urgent(&handle);
}

Expand Down

0 comments on commit e5ec54e

Please sign in to comment.