diff --git a/src/miral/application_selector.cpp b/src/miral/application_selector.cpp index f71c5cc7e7..1d4e8d5de5 100644 --- a/src/miral/application_selector.cpp +++ b/src/miral/application_selector.cpp @@ -50,6 +50,14 @@ void ApplicationSelector::advise_new_window(WindowInfo const& window_info) focus_list.push_back(window_info.window()); } +void ApplicationSelector::advise_new_window(WindowInfo const& window_info, bool focused) +{ + if(!focused && !focus_list.empty()) + focus_list.insert(focus_list.end() - 1, window_info.window()); + else + advise_new_window(window_info); +} + void ApplicationSelector::select(miral::Window const& window) { if (selected) @@ -281,4 +289,4 @@ auto ApplicationSelector::find(Window window) -> std::vector::iterator { return window == other; }); -} \ No newline at end of file +} diff --git a/src/miral/application_selector.h b/src/miral/application_selector.h index f8bb324600..456a8193af 100644 --- a/src/miral/application_selector.h +++ b/src/miral/application_selector.h @@ -43,6 +43,8 @@ class ApplicationSelector /// Called when a window is created void advise_new_window(WindowInfo const&); + void advise_new_window(WindowInfo const&, bool focused); + /// Called when focus is given to a window. void advise_focus_gained(WindowInfo const&); diff --git a/src/miral/minimal_window_manager.cpp b/src/miral/minimal_window_manager.cpp index c43b98ec74..b7b083e9c4 100644 --- a/src/miral/minimal_window_manager.cpp +++ b/src/miral/minimal_window_manager.cpp @@ -297,7 +297,7 @@ 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->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.