summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-13 00:08:56 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-13 00:08:56 +0200
commit8c4b7fe38530ca8fc6f86af0126098a0413ec2dd (patch)
treee472c6f27d6f002ad02d0e55ae95ee732350b0d0 /Servers
parenta20ce4d2b84bfe16d3fbd8448351532c9c0be746 (diff)
downloadserenity-8c4b7fe38530ca8fc6f86af0126098a0413ec2dd.zip
WindowServer: Make the ordering in the window switcher a bit more sane.
Diffstat (limited to 'Servers')
-rw-r--r--Servers/WindowServer/WSWindowManager.h14
-rw-r--r--Servers/WindowServer/WSWindowSwitcher.cpp11
2 files changed, 14 insertions, 11 deletions
diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h
index 634427233c..c3a4cd1671 100644
--- a/Servers/WindowServer/WSWindowManager.h
+++ b/Servers/WindowServer/WSWindowManager.h
@@ -131,8 +131,8 @@ private:
void start_window_drag(WSWindow&, const WSMouseEvent&);
void handle_client_request(const WSAPIClientRequest&);
void set_hovered_window(WSWindow*);
- template<typename Callback> IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback);
- template<typename Callback> IterationDecision for_each_visible_window_of_type_from_front_to_back(WSWindowType, Callback);
+ template<typename Callback> IterationDecision for_each_visible_window_of_type_from_back_to_front(WSWindowType, Callback, bool ignore_highlight = false);
+ template<typename Callback> IterationDecision for_each_visible_window_of_type_from_front_to_back(WSWindowType, Callback, bool ignore_highlight = false);
template<typename Callback> IterationDecision for_each_visible_window_from_front_to_back(Callback);
template<typename Callback> IterationDecision for_each_visible_window_from_back_to_front(Callback);
template<typename Callback> void for_each_window_listening_to_wm_events(Callback);
@@ -234,7 +234,7 @@ private:
};
template<typename Callback>
-IterationDecision WSWindowManager::for_each_visible_window_of_type_from_back_to_front(WSWindowType type, Callback callback)
+IterationDecision WSWindowManager::for_each_visible_window_of_type_from_back_to_front(WSWindowType type, Callback callback, bool ignore_highlight)
{
bool do_highlight_window_at_end = false;
for (auto* window = m_windows_in_order.head(); window; window = window->next()) {
@@ -244,7 +244,7 @@ IterationDecision WSWindowManager::for_each_visible_window_of_type_from_back_to_
continue;
if (window->type() != type)
continue;
- if (m_highlight_window == window) {
+ if (!ignore_highlight && m_highlight_window == window) {
do_highlight_window_at_end = true;
continue;
}
@@ -273,9 +273,9 @@ IterationDecision WSWindowManager::for_each_visible_window_from_back_to_front(Ca
}
template<typename Callback>
-IterationDecision WSWindowManager::for_each_visible_window_of_type_from_front_to_back(WSWindowType type, Callback callback)
+IterationDecision WSWindowManager::for_each_visible_window_of_type_from_front_to_back(WSWindowType type, Callback callback, bool ignore_highlight)
{
- if (m_highlight_window && m_highlight_window->type() == type && m_highlight_window->is_visible()) {
+ if (!ignore_highlight && m_highlight_window && m_highlight_window->type() == type && m_highlight_window->is_visible()) {
if (callback(*m_highlight_window) == IterationDecision::Abort)
return IterationDecision::Abort;
}
@@ -287,7 +287,7 @@ IterationDecision WSWindowManager::for_each_visible_window_of_type_from_front_to
continue;
if (window->type() != type)
continue;
- if (window == m_highlight_window)
+ if (!ignore_highlight && window == m_highlight_window)
continue;
if (callback(*window) == IterationDecision::Abort)
return IterationDecision::Abort;
diff --git a/Servers/WindowServer/WSWindowSwitcher.cpp b/Servers/WindowServer/WSWindowSwitcher.cpp
index ed0e5dd428..e9a2d27084 100644
--- a/Servers/WindowServer/WSWindowSwitcher.cpp
+++ b/Servers/WindowServer/WSWindowSwitcher.cpp
@@ -105,21 +105,24 @@ void WSWindowSwitcher::draw()
void WSWindowSwitcher::refresh()
{
+ auto& wm = WSWindowManager::the();
WSWindow* selected_window = nullptr;
if (m_selected_index > 0 && m_windows[m_selected_index])
selected_window = m_windows[m_selected_index].ptr();
+ if (!selected_window)
+ selected_window = wm.highlight_window() ? wm.highlight_window() : wm.active_window();
m_windows.clear();
m_selected_index = 0;
int window_count = 0;
int longest_title_width = 0;
- WSWindowManager::the().for_each_visible_window_of_type_from_back_to_front(WSWindowType::Normal, [&] (WSWindow& window) {
+ wm.for_each_visible_window_of_type_from_front_to_back(WSWindowType::Normal, [&] (WSWindow& window) {
++window_count;
- longest_title_width = max(longest_title_width, WSWindowManager::the().font().width(window.title()));
+ longest_title_width = max(longest_title_width, wm.font().width(window.title()));
if (selected_window == &window)
m_selected_index = m_windows.size();
m_windows.append(window.make_weak_ptr());
return IterationDecision::Continue;
- });
+ }, true);
if (m_windows.is_empty()) {
hide();
return;
@@ -127,7 +130,7 @@ void WSWindowSwitcher::refresh()
int space_for_window_rect = 180;
m_rect.set_width(thumbnail_width() + longest_title_width + space_for_window_rect + padding() * 2 + item_padding() * 2);
m_rect.set_height(window_count * item_height() + padding() * 2);
- m_rect.center_within(WSWindowManager::the().m_screen_rect);
+ m_rect.center_within(wm.m_screen_rect);
if (!m_switcher_window)
m_switcher_window = make<WSWindow>(*this, WSWindowType::WindowSwitcher);
m_switcher_window->set_rect(m_rect);