mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:57:34 +00:00
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.
This commit is contained in:
parent
0a69da08aa
commit
c6e56612f5
8 changed files with 1 additions and 60 deletions
|
@ -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()));
|
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)
|
void Widget::set_min_size(const Gfx::IntSize& size)
|
||||||
{
|
{
|
||||||
if (m_min_size == size)
|
if (m_min_size == size)
|
||||||
|
|
|
@ -223,9 +223,6 @@ public:
|
||||||
void set_font_weight(unsigned);
|
void set_font_weight(unsigned);
|
||||||
void set_font_fixed_width(bool);
|
void set_font_fixed_width(bool);
|
||||||
|
|
||||||
void set_global_cursor_tracking(bool);
|
|
||||||
bool global_cursor_tracking() const;
|
|
||||||
|
|
||||||
void notify_layout_changed(Badge<Layout>);
|
void notify_layout_changed(Badge<Layout>);
|
||||||
void invalidate_layout();
|
void invalidate_layout();
|
||||||
|
|
||||||
|
|
|
@ -347,13 +347,6 @@ void Window::handle_drop_event(DropEvent& event)
|
||||||
|
|
||||||
void Window::handle_mouse_event(MouseEvent& 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) {
|
if (m_automatic_cursor_tracking_widget) {
|
||||||
auto window_relative_rect = m_automatic_cursor_tracking_widget->window_relative_rect();
|
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() };
|
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);
|
set_hovered_widget(result.widget);
|
||||||
if (event.buttons() != 0 && !m_automatic_cursor_tracking_widget)
|
if (event.buttons() != 0 && !m_automatic_cursor_tracking_widget)
|
||||||
m_automatic_cursor_tracking_widget = *result.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()) {
|
if (!m_pending_paint_event_rects.is_empty()) {
|
||||||
MultiPaintEvent paint_event(move(m_pending_paint_event_rects), size());
|
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)
|
void Window::set_automatic_cursor_tracking_widget(Widget* widget)
|
||||||
{
|
{
|
||||||
if (widget == m_automatic_cursor_tracking_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;
|
m_focused_widget = nullptr;
|
||||||
if (m_hovered_widget == &widget)
|
if (m_hovered_widget == &widget)
|
||||||
m_hovered_widget = nullptr;
|
m_hovered_widget = nullptr;
|
||||||
if (m_global_cursor_tracking_widget == &widget)
|
|
||||||
m_global_cursor_tracking_widget = nullptr;
|
|
||||||
if (m_automatic_cursor_tracking_widget == &widget)
|
if (m_automatic_cursor_tracking_widget == &widget)
|
||||||
m_automatic_cursor_tracking_widget = nullptr;
|
m_automatic_cursor_tracking_widget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,10 +146,6 @@ public:
|
||||||
void update();
|
void update();
|
||||||
void update(const Gfx::IntRect&);
|
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*);
|
void set_automatic_cursor_tracking_widget(Widget*);
|
||||||
Widget* automatic_cursor_tracking_widget() { return m_automatic_cursor_tracking_widget.ptr(); }
|
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(); }
|
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 };
|
float m_alpha_hit_threshold { 0.0f };
|
||||||
RefPtr<Widget> m_main_widget;
|
RefPtr<Widget> m_main_widget;
|
||||||
WeakPtr<Widget> m_focused_widget;
|
WeakPtr<Widget> m_focused_widget;
|
||||||
WeakPtr<Widget> m_global_cursor_tracking_widget;
|
|
||||||
WeakPtr<Widget> m_automatic_cursor_tracking_widget;
|
WeakPtr<Widget> m_automatic_cursor_tracking_widget;
|
||||||
WeakPtr<Widget> m_hovered_widget;
|
WeakPtr<Widget> m_hovered_widget;
|
||||||
Gfx::IntRect m_rect_when_windowless;
|
Gfx::IntRect m_rect_when_windowless;
|
||||||
|
|
|
@ -653,16 +653,6 @@ void ClientConnection::set_window_backing_store(i32 window_id, [[maybe_unused]]
|
||||||
window.invalidate(false);
|
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)
|
void ClientConnection::set_global_mouse_tracking(bool enabled)
|
||||||
{
|
{
|
||||||
m_does_global_mouse_tracking = enabled;
|
m_does_global_mouse_tracking = enabled;
|
||||||
|
|
|
@ -113,7 +113,6 @@ private:
|
||||||
virtual Messages::WindowServer::GetAppletRectOnScreenResponse get_applet_rect_on_screen(i32) override;
|
virtual Messages::WindowServer::GetAppletRectOnScreenResponse get_applet_rect_on_screen(i32) override;
|
||||||
virtual void invalidate_rect(i32, Vector<Gfx::IntRect> const&, bool) 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 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_global_mouse_tracking(bool) override;
|
||||||
virtual void set_window_opacity(i32, float) 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;
|
virtual void set_window_backing_store(i32, i32, i32, IPC::File const&, i32, bool, Gfx::IntSize const&, bool) override;
|
||||||
|
|
|
@ -1201,12 +1201,6 @@ void WindowManager::process_mouse_event(MouseEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 2. Send the mouse event to all clients with global cursor tracking enabled.
|
// 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) {
|
ClientConnection::for_each_client([&](ClientConnection& conn) {
|
||||||
if (conn.does_global_mouse_tracking()) {
|
if (conn.does_global_mouse_tracking()) {
|
||||||
conn.async_track_mouse_move(event.position());
|
conn.async_track_mouse_move(event.position());
|
||||||
|
|
|
@ -74,7 +74,6 @@ endpoint WindowServer
|
||||||
invalidate_rect(i32 window_id, Vector<Gfx::IntRect> rects, bool ignore_occlusion) =|
|
invalidate_rect(i32 window_id, Vector<Gfx::IntRect> rects, bool ignore_occlusion) =|
|
||||||
did_finish_painting(i32 window_id, Vector<Gfx::IntRect> rects) =|
|
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_global_mouse_tracking(bool enabled) =|
|
||||||
set_window_opacity(i32 window_id, float opacity) =|
|
set_window_opacity(i32 window_id, float opacity) =|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue