Browse Source

WindowServer: Simplify two mouse coordinate conversions.

Andreas Kling 6 years ago
parent
commit
2ac2d79a8e
1 changed files with 3 additions and 9 deletions
  1. 3 9
      Servers/WindowServer/WSWindowManager.cpp

+ 3 - 9
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<WSMouseEvent>(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<WSMouseEvent>(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;
         }