summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-11 18:38:48 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-11 18:38:48 +0100
commit4c620dea8300d908baf0dab9facb093fca15a50d (patch)
tree9cd1d14cb859f0bfe76b2ce9d626824fbd0fcf2e /Servers
parentba135dc0c09b5be2e702a4c24b613a06ef152f7e (diff)
downloadserenity-4c620dea8300d908baf0dab9facb093fca15a50d.zip
WindowServer: Update window switcher when moving window to front
If the window switcher is up when a window is made frontmost (usually by clicking on it), the window will now become the selected window in the switcher. This still has a slight feeling of "hmm" but is definitely better than what we had before.
Diffstat (limited to 'Servers')
-rw-r--r--Servers/WindowServer/WindowManager.cpp6
-rw-r--r--Servers/WindowServer/WindowSwitcher.cpp10
-rw-r--r--Servers/WindowServer/WindowSwitcher.h2
3 files changed, 18 insertions, 0 deletions
diff --git a/Servers/WindowServer/WindowManager.cpp b/Servers/WindowServer/WindowManager.cpp
index d3c69330f1..e149e8a762 100644
--- a/Servers/WindowServer/WindowManager.cpp
+++ b/Servers/WindowServer/WindowManager.cpp
@@ -187,6 +187,12 @@ void WindowManager::move_to_front_and_make_active(Window& window)
recompute_occlusions();
set_active_window(&window);
+
+ if (m_switcher.is_visible()) {
+ m_switcher.refresh();
+ m_switcher.select_window(window);
+ set_highlight_window(&window);
+ }
}
void WindowManager::remove_window(Window& window)
diff --git a/Servers/WindowServer/WindowSwitcher.cpp b/Servers/WindowServer/WindowSwitcher.cpp
index 468b6926bf..9931655f29 100644
--- a/Servers/WindowServer/WindowSwitcher.cpp
+++ b/Servers/WindowServer/WindowSwitcher.cpp
@@ -126,6 +126,16 @@ void WindowSwitcher::on_key_event(const KeyEvent& event)
select_window_at_index(new_selected_index);
}
+void WindowSwitcher::select_window(Window& window)
+{
+ for (int i = 0; i < m_windows.size(); ++i) {
+ if (m_windows.at(i) == &window) {
+ select_window_at_index(i);
+ return;
+ }
+ }
+}
+
void WindowSwitcher::select_window_at_index(int index)
{
m_selected_index = index;
diff --git a/Servers/WindowServer/WindowSwitcher.h b/Servers/WindowServer/WindowSwitcher.h
index 3121ef087f..5aa0d0ca6b 100644
--- a/Servers/WindowServer/WindowSwitcher.h
+++ b/Servers/WindowServer/WindowSwitcher.h
@@ -68,6 +68,8 @@ public:
int padding() const { return 8; }
int item_padding() const { return 8; }
+ void select_window(Window&);
+
Window* selected_window();
Window* switcher_window() { return m_switcher_window.ptr(); }