summaryrefslogtreecommitdiff
path: root/Userland/Libraries
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 /Userland/Libraries
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.
Diffstat (limited to 'Userland/Libraries')
-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
4 files changed, 1 insertions, 42 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;