Commit 7fb02064 authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

linux: Use Event location in WindowEventFilterLinux

WindowEventFilterLinux currently calculates event's screen location (in
pixels) using window bounds' origin + event's root_location(), while the
correct would be to use Event::location() instead. It currently works
because (for some reason) MouseEvent ctor that takes an XEvent as input,
which is used atm in Aura/X11 to instantiate such events, sets
root_location to the same value as location [1].

This is causing issues in window drag handling after migrating
PlatformEvent to ui::Event (CL under review at crrev.com/c/2022280).
Such change involves switching to x11_event_translation.{h,cc} to build
ui::Events out of XEvents, which was originally based on X11 event
source impl used in ozone/x11 (formerly used only for "CrOS on Linux")
[2] which correctly sets MouseEvent's root_location [3] using
ui::EventSystemLocationFromXEvent function, which is required, for
example, to be able to retrieve event's screen point in
X11WholeScreeMoveLoop [4].

[1] https://source.chromium.org/chromium/chromium/src/+/master:ui/events/event.cc;l=417-418;drc=948073da23
[2] https://source.chromium.org/chromium/chromium/src/+/d436c8e6a1:ui/events/platform/x11/x11_event_source_default.cc;l=91-94
[3] https://source.chromium.org/chromium/chromium/src/+/master:ui/events/x/x11_event_translation.cc;l=53-56;drc=bb682b7a02
[4] https://crrev.com/c/2022280/15/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc#64

Bug: 965991
Change-Id: I2ad3fbde354ff66885253ccaca0e74391d4a11db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032307Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#737542}
parent 788c19b1
...@@ -163,7 +163,7 @@ void WindowEventFilterLinux::MaybeDispatchHostWindowDragMovement( ...@@ -163,7 +163,7 @@ void WindowEventFilterLinux::MaybeDispatchHostWindowDragMovement(
// interactive move/resize. // interactive move/resize.
auto bounds_in_px = auto bounds_in_px =
desktop_window_tree_host_->AsWindowTreeHost()->GetBoundsInPixels(); desktop_window_tree_host_->AsWindowTreeHost()->GetBoundsInPixels();
auto screen_point_in_px = event->root_location(); auto screen_point_in_px = event->location();
screen_point_in_px.Offset(bounds_in_px.x(), bounds_in_px.y()); screen_point_in_px.Offset(bounds_in_px.x(), bounds_in_px.y());
handler_->DispatchHostWindowDragMovement(hittest, screen_point_in_px); handler_->DispatchHostWindowDragMovement(hittest, screen_point_in_px);
event->StopPropagation(); event->StopPropagation();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment