Skip to content

Commit

Permalink
Fixing case of no selectable applications
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Jul 21, 2023
1 parent 2ba5d60 commit 2f798ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/miral/application_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ auto ApplicationSelector::next(bool reverse) -> Application

// Attempt to focus the next application after the originally selected application.
auto it = std::find(focus_list.begin(), focus_list.end(), selected);
auto start_it = it;
do {
if (reverse)
{
Expand All @@ -137,6 +138,10 @@ auto ApplicationSelector::next(bool reverse) -> Application
it = focus_list.begin();
}
}

// We made it all the way through the list but failed to find anything.
if (it == start_it)
break;
} while (!tools.try_select_application(*it));

return *it;
Expand Down
16 changes: 15 additions & 1 deletion tests/miral/application_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ struct ApplicationSelectorTest : mt::TestWindowManagerTools
return window;
}

auto create_unfocusable_window() -> Window
{
mir::shell::SurfaceSpecification creation_parameters;
creation_parameters.type = mir_window_type_normal;
creation_parameters.focus_mode = MirFocusMode::mir_focus_mode_disabled;
creation_parameters.set_size({600, 400});
auto window = create_and_select_window(creation_parameters);

// Simulates a new application opening and gaining focus
application_selector.advise_new_app(window.application());
application_selector.advise_focus_gained(window_manager_tools.info_for(window));
return window;
}

auto create_window_list(int num_windows) -> std::vector<Window>
{
std::vector<Window> window_list;
Expand Down Expand Up @@ -126,4 +140,4 @@ TEST_F(ApplicationSelectorTest, deleting_selected_app_makes_the_next_app_selecte
application_selector.advise_delete_app(windows[1].application());
auto application = application_selector.get_focused();
EXPECT_TRUE(application == windows[0].application());
}
}

0 comments on commit 2f798ad

Please sign in to comment.