From 2ac2d79a8e75e6083b9c0c6a1ad8b5899af7addb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 5 Apr 2019 20:27:12 +0200 Subject: [PATCH] WindowServer: Simplify two mouse coordinate conversions. --- Servers/WindowServer/WSWindowManager.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index bab256285b1..5611f6798ae 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -620,10 +620,8 @@ void WSWindowManager::process_mouse_event(const WSMouseEvent& event, WSWindow*& if (!window->global_cursor_tracking()) continue; ASSERT(window->is_visible()); // Maybe this should be supported? Idk. Let's catch it and think about it later. - Point position { event.x() - window->rect().x(), event.y() - window->rect().y() }; - auto local_event = make(event.type(), position, event.buttons(), event.button(), event.modifiers()); windows_who_received_mouse_event_due_to_cursor_tracking.set(window); - window->on_message(*local_event); + window->on_message(WSMouseEvent(event.type(), event.position().translated(-window->position()), event.buttons(), event.button(), event.modifiers())); } if (menubar_rect().contains(event.position())) { @@ -661,12 +659,8 @@ void WSWindowManager::process_mouse_event(const WSMouseEvent& event, WSWindow*& if (window.type() == WSWindowType::Normal && event.type() == WSMessage::MouseDown) move_to_front_and_make_active(window); event_window = &window; - if (!window.global_cursor_tracking() && !windows_who_received_mouse_event_due_to_cursor_tracking.contains(&window)) { - // FIXME: Should we just alter the coordinates of the existing MouseEvent and pass it through? - Point position { event.x() - window.rect().x(), event.y() - window.rect().y() }; - auto local_event = make(event.type(), position, event.buttons(), event.button(), event.modifiers()); - window.on_message(*local_event); - } + if (!window.global_cursor_tracking() && !windows_who_received_mouse_event_due_to_cursor_tracking.contains(&window)) + window.on_message(WSMouseEvent(event.type(), event.position().translated(-window.position()), event.buttons(), event.button(), event.modifiers())); return IterationDecision::Abort; }