Skip to content

Commit

Permalink
WindowServer: Include minimised windows for switching
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonbooth authored and awesomekling committed Dec 29, 2019
1 parent 24bc674 commit d1d7db2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 21 additions & 0 deletions Servers/WindowServer/WSWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class WSWindowManager : public CObject {
void for_each_window_listening_to_wm_events(Callback);
template<typename Callback>
void for_each_window(Callback);
template<typename Callback>
IterationDecision for_each_window_of_type_from_front_to_back(WSWindowType, Callback, bool ignore_highlight = false);

virtual void event(CEvent&) override;
void paint_window_frame(const WSWindow&);
Expand Down Expand Up @@ -412,3 +414,22 @@ void WSWindowManager::for_each_window(Callback callback)
return;
}
}

template<typename Callback>
IterationDecision WSWindowManager::for_each_window_of_type_from_front_to_back(WSWindowType type, Callback callback, bool ignore_highlight)
{
if (!ignore_highlight && m_highlight_window && m_highlight_window->type() == type && m_highlight_window->is_visible()) {
if (callback(*m_highlight_window) == IterationDecision::Break)
return IterationDecision::Break;
}

for (auto* window = m_windows_in_order.tail(); window; window = window->prev()) {
if (window->type() != type)
continue;
if (!ignore_highlight && window == m_highlight_window)
continue;
if (callback(*window) == IterationDecision::Break)
return IterationDecision::Break;
}
return IterationDecision::Continue;
}
6 changes: 4 additions & 2 deletions Servers/WindowServer/WSWindowSwitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ void WSWindowSwitcher::on_key_event(const WSKeyEvent& event)
{
if (event.type() == WSEvent::KeyUp) {
if (event.key() == Key_Logo) {
if (auto* window = selected_window())
if (auto* window = selected_window()) {
window->set_minimized(false);
WSWindowManager::the().move_to_front_and_make_active(*window);
}
WSWindowManager::the().set_highlight_window(nullptr);
hide();
}
Expand Down Expand Up @@ -119,7 +121,7 @@ void WSWindowSwitcher::refresh()
m_selected_index = 0;
int window_count = 0;
int longest_title_width = 0;
wm.for_each_visible_window_of_type_from_front_to_back(WSWindowType::Normal, [&](WSWindow& window) {
wm.for_each_window_of_type_from_front_to_back(WSWindowType::Normal, [&](WSWindow& window) {
++window_count;
longest_title_width = max(longest_title_width, wm.font().width(window.title()));
if (selected_window == &window)
Expand Down

0 comments on commit d1d7db2

Please sign in to comment.