summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-15 22:39:36 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-16 00:58:26 +0200
commit296e68fdbf858244e722b2113002035d20b76901 (patch)
tree59003a6bf498dec2bd95462a1341e45dd9bb406b
parentadd4f42d219a4a7f7b8641f8836a7d90c39a608e (diff)
downloadserenity-296e68fdbf858244e722b2113002035d20b76901.zip
WindowServer: Move "automatic cursor tracking window" to WindowManager
It didn't make sense for this to be a per-WindowStack concept, since automatic cursor tracking is globally modal.
-rw-r--r--Userland/Services/WindowServer/WindowManager.cpp26
-rw-r--r--Userland/Services/WindowServer/WindowManager.h5
-rw-r--r--Userland/Services/WindowServer/WindowStack.cpp3
-rw-r--r--Userland/Services/WindowServer/WindowStack.h5
4 files changed, 17 insertions, 22 deletions
diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp
index ca3ef0edba..b4daf1d6bd 100644
--- a/Userland/Services/WindowServer/WindowManager.cpp
+++ b/Userland/Services/WindowServer/WindowManager.cpp
@@ -747,7 +747,7 @@ void WindowManager::start_window_resize(Window& window, Gfx::IntPoint const& pos
m_geometry_overlay->set_enabled(true);
}
- current_window_stack().set_automatic_cursor_tracking_window(nullptr);
+ set_automatic_cursor_tracking_window(nullptr);
window.invalidate(true, true);
@@ -1206,8 +1206,7 @@ void WindowManager::deliver_mouse_event(Window& window, MouseEvent const& event,
bool WindowManager::process_ongoing_active_input_mouse_event(MouseEvent const& event)
{
- auto& window_stack = current_window_stack();
- auto* input_tracking_window = window_stack.automatic_cursor_tracking_window();
+ auto* input_tracking_window = automatic_cursor_tracking_window();
if (!input_tracking_window)
return false;
@@ -1220,7 +1219,7 @@ bool WindowManager::process_ongoing_active_input_mouse_event(MouseEvent const& e
deliver_mouse_event(*input_tracking_window, event, true);
if (event.type() == Event::MouseUp && event.buttons() == 0)
- window_stack.set_automatic_cursor_tracking_window(nullptr);
+ set_automatic_cursor_tracking_window(nullptr);
return true;
}
@@ -1291,7 +1290,7 @@ void WindowManager::process_mouse_event_for_window(HitTestResult& result, MouseE
}
if (event.type() == Event::MouseDown)
- current_window_stack().set_automatic_cursor_tracking_window(&window);
+ set_automatic_cursor_tracking_window(&window);
}
void WindowManager::process_mouse_event(MouseEvent& event)
@@ -1312,9 +1311,8 @@ void WindowManager::process_mouse_event(MouseEvent& event)
});
// The automatic cursor tracking window is excluded here because we're sending the event to it
// in the next step.
- auto& window_stack = current_window_stack();
for_each_visible_window_from_front_to_back([&](Window& window) {
- if (window.is_automatic_cursor_tracking() && &window != window_stack.automatic_cursor_tracking_window())
+ if (window.is_automatic_cursor_tracking() && &window != automatic_cursor_tracking_window())
deliver_mouse_event(window, event, false);
return IterationDecision::Continue;
});
@@ -1615,7 +1613,7 @@ void WindowManager::process_key_event(KeyEvent& event)
m_previous_event_was_super_keydown = true;
} else if (m_previous_event_was_super_keydown) {
m_previous_event_was_super_keydown = false;
- if (!m_dnd_client && !current_window_stack().automatic_cursor_tracking_window() && event.type() == Event::KeyUp && event.key() == Key_Super) {
+ if (!m_dnd_client && !automatic_cursor_tracking_window() && event.type() == Event::KeyUp && event.key() == Key_Super) {
tell_wms_super_key_pressed();
return;
}
@@ -1891,7 +1889,7 @@ void WindowManager::set_active_window(Window* new_active_window, bool make_input
if (auto* previously_active_window = window_stack.active_window()) {
window_stack.set_active_window(nullptr);
- window_stack.set_automatic_cursor_tracking_window(nullptr);
+ set_automatic_cursor_tracking_window(nullptr);
notify_previous_active_window(*previously_active_window);
}
@@ -2083,7 +2081,7 @@ void WindowManager::start_dnd_drag(ConnectionFromClient& client, String const& t
m_dnd_overlay->set_enabled(true);
m_dnd_mime_data = mime_data;
Compositor::the().invalidate_cursor();
- current_window_stack().set_automatic_cursor_tracking_window(nullptr);
+ set_automatic_cursor_tracking_window(nullptr);
}
void WindowManager::end_dnd_drag()
@@ -2164,11 +2162,11 @@ void WindowManager::clear_theme_override()
void WindowManager::did_popup_a_menu(Badge<Menu>)
{
// Clear any ongoing input gesture
- auto* automatic_cursor_tracking_window = current_window_stack().automatic_cursor_tracking_window();
- if (!automatic_cursor_tracking_window)
+ auto* window = automatic_cursor_tracking_window();
+ if (!window)
return;
- automatic_cursor_tracking_window->set_automatic_cursor_tracking_enabled(false);
- current_window_stack().set_automatic_cursor_tracking_window(nullptr);
+ window->set_automatic_cursor_tracking_enabled(false);
+ set_automatic_cursor_tracking_window(nullptr);
}
void WindowManager::minimize_windows(Window& window, bool minimized)
diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h
index 20924fa37c..3a5459c911 100644
--- a/Userland/Services/WindowServer/WindowManager.h
+++ b/Userland/Services/WindowServer/WindowManager.h
@@ -343,6 +343,10 @@ public:
RefPtr<KeymapSwitcher> keymap_switcher() { return m_keymap_switcher; }
+ Window* automatic_cursor_tracking_window() { return m_automatic_cursor_tracking_window; }
+ Window const* automatic_cursor_tracking_window() const { return m_automatic_cursor_tracking_window; }
+ void set_automatic_cursor_tracking_window(Window* window) { m_automatic_cursor_tracking_window = window; }
+
private:
explicit WindowManager(Gfx::PaletteImpl const&);
@@ -448,6 +452,7 @@ private:
WeakPtr<Window> m_hovered_window;
WeakPtr<Window> m_highlight_window;
WeakPtr<Window> m_window_with_active_menu;
+ WeakPtr<Window> m_automatic_cursor_tracking_window;
OwnPtr<WindowGeometryOverlay> m_geometry_overlay;
WeakPtr<Window> m_move_window;
diff --git a/Userland/Services/WindowServer/WindowStack.cpp b/Userland/Services/WindowServer/WindowStack.cpp
index a080eef3c1..60a1fca855 100644
--- a/Userland/Services/WindowServer/WindowStack.cpp
+++ b/Userland/Services/WindowServer/WindowStack.cpp
@@ -40,8 +40,6 @@ void WindowStack::remove(Window& window)
m_active_window = nullptr;
if (m_active_input_window == &window)
m_active_input_window = nullptr;
- if (m_automatic_cursor_tracking_window == &window)
- m_automatic_cursor_tracking_window = nullptr;
}
void WindowStack::move_to_front(Window& window)
@@ -102,7 +100,6 @@ void WindowStack::move_all_windows(WindowStack& new_window_stack, Vector<Window*
}
m_active_window = nullptr;
m_active_input_window = nullptr;
- m_automatic_cursor_tracking_window = nullptr;
}
Window* WindowStack::window_at(Gfx::IntPoint const& position, IncludeWindowFrame include_window_frame) const
diff --git a/Userland/Services/WindowServer/WindowStack.h b/Userland/Services/WindowServer/WindowStack.h
index 03a7103312..5f7468ed2b 100644
--- a/Userland/Services/WindowServer/WindowStack.h
+++ b/Userland/Services/WindowServer/WindowStack.h
@@ -60,10 +60,6 @@ public:
Window const* active_input_window() const { return m_active_input_window; }
void set_active_input_window(Window* window) { m_active_input_window = window; }
- Window* automatic_cursor_tracking_window() { return m_automatic_cursor_tracking_window; }
- Window const* automatic_cursor_tracking_window() const { return m_automatic_cursor_tracking_window; }
- void set_automatic_cursor_tracking_window(Window* window) { m_automatic_cursor_tracking_window = window; }
-
Optional<HitTestResult> hit_test(Gfx::IntPoint const&) const;
unsigned row() const { return m_row; }
@@ -84,7 +80,6 @@ public:
private:
WeakPtr<Window> m_active_window;
WeakPtr<Window> m_active_input_window;
- WeakPtr<Window> m_automatic_cursor_tracking_window;
Window::List m_windows;
unsigned m_row { 0 };