WindowServer: Simplify two mouse coordinate conversions.

This commit is contained in:
Andreas Kling 2019-04-05 20:27:12 +02:00
parent 3155a2e128
commit 2ac2d79a8e
Notes: sideshowbarker 2024-07-19 14:48:41 +09:00

View File

@ -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;
}