summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-05 20:27:12 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-05 20:27:12 +0200
commit2ac2d79a8e75e6083b9c0c6a1ad8b5899af7addb (patch)
treeac3cab7dcdb531558bc369fd9115bc10fad50496
parent3155a2e12881823c1c5353bee6c92b39ac5fe4fe (diff)
downloadserenity-2ac2d79a8e75e6083b9c0c6a1ad8b5899af7addb.zip
WindowServer: Simplify two mouse coordinate conversions.
-rw-r--r--Servers/WindowServer/WSWindowManager.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp
index bab256285b..5611f6798a 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<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;
}