Skip to content

Commit

Permalink
Overload ApplicationSelector::advise_new_window to account for
Browse files Browse the repository at this point in the history
unfocused windows
  • Loading branch information
tarek-y-ismail committed Dec 6, 2024
1 parent 8284f3e commit c71ec3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/miral/application_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -281,4 +289,4 @@ auto ApplicationSelector::find(Window window) -> std::vector<Window>::iterator
{
return window == other;
});
}
}
2 changes: 2 additions & 0 deletions src/miral/application_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);

Expand Down
2 changes: 1 addition & 1 deletion src/miral/minimal_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c71ec3a

Please sign in to comment.