summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-09-07 22:27:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-08 10:53:49 +0200
commitc6e56612f560340a1eda66acc6974a2eb447bc46 (patch)
treef38a366b1bf06e5b8bc19f665b52d3997e39fa6c
parent0a69da08aa4cbbd21203bcce0f33a322cb94b7ad (diff)
downloadserenity-c6e56612f560340a1eda66acc6974a2eb447bc46.zip
LibGUI+WindowServer: Remove now-obsolete cursor tracking feature
This feature was problematic for several reasons: - Tracking *all* the user activity seems like a privacy nightmare. - LibGUI actually only supports one globally tracking widget per window, even if no window is necessary, or if multiple callbacks are desired. - Widgets can easily get confused whether an event is actually directed at it, or is actually just the result of global tracking. The third item caused an issue where right-clicking CatDog opened two context menus instead of one.
-rw-r--r--Userland/Libraries/LibGUI/Widget.cpp16
-rw-r--r--Userland/Libraries/LibGUI/Widget.h3
-rw-r--r--Userland/Libraries/LibGUI/Window.cpp19
-rw-r--r--Userland/Libraries/LibGUI/Window.h5
-rw-r--r--Userland/Services/WindowServer/ClientConnection.cpp10
-rw-r--r--Userland/Services/WindowServer/ClientConnection.h1
-rw-r--r--Userland/Services/WindowServer/WindowManager.cpp6
-rw-r--r--Userland/Services/WindowServer/WindowServer.ipc1
8 files changed, 1 insertions, 60 deletions
diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp
index 71362ff939..3496d3b0a4 100644
--- a/Userland/Libraries/LibGUI/Widget.cpp
+++ b/Userland/Libraries/LibGUI/Widget.cpp
@@ -757,22 +757,6 @@ void Widget::set_font_fixed_width(bool fixed_width)
set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_font().family(), m_font->presentation_size(), m_font->weight()));
}
-void Widget::set_global_cursor_tracking(bool enabled)
-{
- auto* win = window();
- if (!win)
- return;
- win->set_global_cursor_tracking_widget(enabled ? this : nullptr);
-}
-
-bool Widget::global_cursor_tracking() const
-{
- auto* win = window();
- if (!win)
- return false;
- return win->global_cursor_tracking_widget() == this;
-}
-
void Widget::set_min_size(const Gfx::IntSize& size)
{
if (m_min_size == size)
diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h
index d88a70dfec..2327533830 100644
--- a/Userland/Libraries/LibGUI/Widget.h
+++ b/Userland/Libraries/LibGUI/Widget.h
@@ -223,9 +223,6 @@ public:
void set_font_weight(unsigned);
void set_font_fixed_width(bool);
- void set_global_cursor_tracking(bool);
- bool global_cursor_tracking() const;
-
void notify_layout_changed(Badge<Layout>);
void invalidate_layout();
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp
index 72e6b9a630..1df3522d3f 100644
--- a/Userland/Libraries/LibGUI/Window.cpp
+++ b/Userland/Libraries/LibGUI/Window.cpp
@@ -347,13 +347,6 @@ void Window::handle_drop_event(DropEvent& event)
void Window::handle_mouse_event(MouseEvent& event)
{
- if (m_global_cursor_tracking_widget) {
- auto window_relative_rect = m_global_cursor_tracking_widget->window_relative_rect();
- Gfx::IntPoint local_point { event.x() - window_relative_rect.x(), event.y() - window_relative_rect.y() };
- auto local_event = MouseEvent((Event::Type)event.type(), local_point, event.buttons(), event.button(), event.modifiers(), event.wheel_delta());
- m_global_cursor_tracking_widget->dispatch_event(local_event, this);
- return;
- }
if (m_automatic_cursor_tracking_widget) {
auto window_relative_rect = m_automatic_cursor_tracking_widget->window_relative_rect();
Gfx::IntPoint local_point { event.x() - window_relative_rect.x(), event.y() - window_relative_rect.y() };
@@ -371,8 +364,7 @@ void Window::handle_mouse_event(MouseEvent& event)
set_hovered_widget(result.widget);
if (event.buttons() != 0 && !m_automatic_cursor_tracking_widget)
m_automatic_cursor_tracking_widget = *result.widget;
- if (result.widget != m_global_cursor_tracking_widget.ptr())
- result.widget->dispatch_event(local_event, this);
+ result.widget->dispatch_event(local_event, this);
if (!m_pending_paint_event_rects.is_empty()) {
MultiPaintEvent paint_event(move(m_pending_paint_event_rects), size());
@@ -755,13 +747,6 @@ void Window::set_focused_widget(Widget* widget, FocusSource source)
}
}
-void Window::set_global_cursor_tracking_widget(Widget* widget)
-{
- if (widget == m_global_cursor_tracking_widget)
- return;
- m_global_cursor_tracking_widget = widget;
-}
-
void Window::set_automatic_cursor_tracking_widget(Widget* widget)
{
if (widget == m_automatic_cursor_tracking_widget)
@@ -1138,8 +1123,6 @@ void Window::did_remove_widget(Badge<Widget>, Widget& widget)
m_focused_widget = nullptr;
if (m_hovered_widget == &widget)
m_hovered_widget = nullptr;
- if (m_global_cursor_tracking_widget == &widget)
- m_global_cursor_tracking_widget = nullptr;
if (m_automatic_cursor_tracking_widget == &widget)
m_automatic_cursor_tracking_widget = nullptr;
}
diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h
index 013bb4fbe3..a6dd2e872a 100644
--- a/Userland/Libraries/LibGUI/Window.h
+++ b/Userland/Libraries/LibGUI/Window.h
@@ -146,10 +146,6 @@ public:
void update();
void update(const Gfx::IntRect&);
- void set_global_cursor_tracking_widget(Widget*);
- Widget* global_cursor_tracking_widget() { return m_global_cursor_tracking_widget.ptr(); }
- const Widget* global_cursor_tracking_widget() const { return m_global_cursor_tracking_widget.ptr(); }
-
void set_automatic_cursor_tracking_widget(Widget*);
Widget* automatic_cursor_tracking_widget() { return m_automatic_cursor_tracking_widget.ptr(); }
const Widget* automatic_cursor_tracking_widget() const { return m_automatic_cursor_tracking_widget.ptr(); }
@@ -253,7 +249,6 @@ private:
float m_alpha_hit_threshold { 0.0f };
RefPtr<Widget> m_main_widget;
WeakPtr<Widget> m_focused_widget;
- WeakPtr<Widget> m_global_cursor_tracking_widget;
WeakPtr<Widget> m_automatic_cursor_tracking_widget;
WeakPtr<Widget> m_hovered_widget;
Gfx::IntRect m_rect_when_windowless;
diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp
index b6466ccaeb..907cbe6c9a 100644
--- a/Userland/Services/WindowServer/ClientConnection.cpp
+++ b/Userland/Services/WindowServer/ClientConnection.cpp
@@ -653,16 +653,6 @@ void ClientConnection::set_window_backing_store(i32 window_id, [[maybe_unused]]
window.invalidate(false);
}
-void ClientConnection::set_global_cursor_tracking(i32 window_id, bool enabled)
-{
- auto it = m_windows.find(window_id);
- if (it == m_windows.end()) {
- did_misbehave("SetGlobalCursorTracking: Bad window ID");
- return;
- }
- it->value->set_global_cursor_tracking_enabled(enabled);
-}
-
void ClientConnection::set_global_mouse_tracking(bool enabled)
{
m_does_global_mouse_tracking = enabled;
diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h
index 56aca66c31..5e3f4190b3 100644
--- a/Userland/Services/WindowServer/ClientConnection.h
+++ b/Userland/Services/WindowServer/ClientConnection.h
@@ -113,7 +113,6 @@ private:
virtual Messages::WindowServer::GetAppletRectOnScreenResponse get_applet_rect_on_screen(i32) override;
virtual void invalidate_rect(i32, Vector<Gfx::IntRect> const&, bool) override;
virtual void did_finish_painting(i32, Vector<Gfx::IntRect> const&) override;
- virtual void set_global_cursor_tracking(i32, bool) override;
virtual void set_global_mouse_tracking(bool) override;
virtual void set_window_opacity(i32, float) override;
virtual void set_window_backing_store(i32, i32, i32, IPC::File const&, i32, bool, Gfx::IntSize const&, bool) override;
diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp
index a2388d51ef..a49ef0c3cb 100644
--- a/Userland/Services/WindowServer/WindowManager.cpp
+++ b/Userland/Services/WindowServer/WindowManager.cpp
@@ -1201,12 +1201,6 @@ void WindowManager::process_mouse_event(MouseEvent& event)
return;
// 2. Send the mouse event to all clients with global cursor tracking enabled.
- auto& window_stack = current_window_stack();
- for_each_visible_window_from_front_to_back([&](Window& window) {
- if (window.global_cursor_tracking() && &window != window_stack.active_input_tracking_window())
- deliver_mouse_event(window, event, false);
- return IterationDecision::Continue;
- });
ClientConnection::for_each_client([&](ClientConnection& conn) {
if (conn.does_global_mouse_tracking()) {
conn.async_track_mouse_move(event.position());
diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc
index dfa282c36d..6d9a702b56 100644
--- a/Userland/Services/WindowServer/WindowServer.ipc
+++ b/Userland/Services/WindowServer/WindowServer.ipc
@@ -74,7 +74,6 @@ endpoint WindowServer
invalidate_rect(i32 window_id, Vector<Gfx::IntRect> rects, bool ignore_occlusion) =|
did_finish_painting(i32 window_id, Vector<Gfx::IntRect> rects) =|
- set_global_cursor_tracking(i32 window_id, bool enabled) =|
set_global_mouse_tracking(bool enabled) =|
set_window_opacity(i32 window_id, float opacity) =|