Commit de291ec2 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

Prehandle events with WindowEventFilterLinux instead of posthandling.

Posthandling events does not work properly in this case as we are
not able to track if the event that has been sent to sink
is handled or not.

That is, SendEventToSink results in copying the entire event which
means that the original event is not going to have its handling
status changed. That means that we are not able to track if the
event is handled or not unless a dispatcher or a target are destroyed
(remember that SendEventToSink returns EventDispatchDetails, but
does not say anything about handling results).

That resulted in the WindowEventFilterLinux always post-processing
events and opening context menus twice (the first one was closed
immediately after it was shown and the second one was shown instead).

TEST: manually tested.
Bug: 1028046
Change-Id: I2bedda57c7ca8a05171428da26b889eac04cf36f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1947733Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#721406}
parent 40f9fb67
......@@ -257,24 +257,17 @@ void DesktopWindowTreeHostLinux::DispatchEvent(ui::Event* event) {
FlashFrame(false);
}
// Store the location in px to restore it later.
gfx::Point previous_mouse_location_in_px;
if (event->IsMouseEvent())
previous_mouse_location_in_px = event->AsMouseEvent()->location();
WindowTreeHostPlatform::DispatchEvent(event);
// Posthandle the event if it has not been consumed.
if (!event->handled() && event->IsMouseEvent() &&
non_client_window_event_filter_) {
auto* mouse_event = event->AsMouseEvent();
// Location is set in dip after the event is dispatched to the event sink.
// Restore it back to be in px that WindowEventFilterLinux requires.
mouse_event->set_location(previous_mouse_location_in_px);
mouse_event->set_root_location(previous_mouse_location_in_px);
non_client_window_event_filter_->HandleMouseEventWithHitTest(hit_test_code,
mouse_event);
// Prehandle the event as long as as we are not able to track if it is handled
// or not as SendEventToSink results in copying the event and our copy of the
// event will not set to handled unless a dispatcher or a target are
// destroyed.
if (event->IsMouseEvent() && non_client_window_event_filter_) {
non_client_window_event_filter_->HandleMouseEventWithHitTest(
hit_test_code, event->AsMouseEvent());
}
if (!event->handled())
WindowTreeHostPlatform::DispatchEvent(event);
}
void DesktopWindowTreeHostLinux::OnClosed() {
......
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