From c71ec3a18131c1070cb5bed267c4c2cf372d5b1c Mon Sep 17 00:00:00 2001 From: Tarek Ismail Date: Thu, 5 Dec 2024 17:32:23 +0200 Subject: [PATCH] Overload `ApplicationSelector::advise_new_window` to account for unfocused windows --- src/miral/application_selector.cpp | 10 +++++++++- src/miral/application_selector.h | 2 ++ src/miral/minimal_window_manager.cpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/miral/application_selector.cpp b/src/miral/application_selector.cpp index f71c5cc7e74..1d4e8d5de5b 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 f8bb3246008..456a8193af8 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 c43b98ec745..b7b083e9c4f 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.