Skip to content

Commit

Permalink
Restrict the types of windows that can be prevented from stealing focus
Browse files Browse the repository at this point in the history
Only applies to windows in the application layer that don't have a
parent.
  • Loading branch information
tarek-y-ismail committed Dec 6, 2024
1 parent c71ec3a commit 9002657
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/miral/minimal_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,21 @@ auto miral::MinimalWindowManager::confirm_inherited_move(WindowInfo const& windo

void miral::MinimalWindowManager::advise_new_window(miral::WindowInfo const& window_info)
{
self->application_selector.advise_new_window(window_info, self->focus_stealing == FocusStealing::allow);

// If focus stealing prevention is on, swap the old focused window (now in
// the back) with the new window in the front.
//
// If it's a legitimate window, it'll be focused and raised via
// xdg-activation.
if ((self->focus_stealing == FocusStealing::prevent) && tools.active_window())
//
// This is limited to a couple of window types, as well as windows in the
// "application" layer that don't have a parent.
auto in_background =
(self->focus_stealing == FocusStealing::prevent) && tools.active_window() &&
window_info.depth_layer() == mir_depth_layer_application && !window_info.parent();

self->application_selector.advise_new_window(window_info, in_background);

if (in_background)
tools.swap_tree_order(tools.active_window(), window_info.window());
}

Expand Down

0 comments on commit 9002657

Please sign in to comment.