Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(559)

Issue 2791693003: [Ozone/x11] events can be dispatched to the wrong window

Created:
3 years, 8 months ago by tonikitoo
Modified:
3 years, 8 months ago
Reviewers:
kylechar, sadrul, fwang
CC:
chromium-reviews, fwang, msisov
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[Ozone/x11] events can be dispatched to the wrong window When multiple X11Window/X11WindowOzone instances are created, each registers itself in PlatformEventSource as a "platform event dispatcher". Before dispatching an event to a specific window, PlatformEventSource iterates over the list of registered dispatchers, "asking" each dispatcher whether the event can be dispatch to it. In case of non-Ozone X11 windows, X11Window::CanDispatchEvent is called receiving a XEvent* parameter, and checks whether the xwindow targeted by the event is the same as the xwindow it wraps (see ::IsEventForXWindow). If so it dispatches the event to this X11Window instance. In case of Ozone X11 windows, X11WindowOzone::CanDispatchEvent is called receiving a ui::Event* parameter, and it is not possible to access its associated NativeEvent*, because event was manually constructed in EventSourceLibevent::ProcessXEvent. Hence, ::CanDispatchEvent does not check if it is the event's target window, but instead whether the event location is contained in its bounds. This is fragile: if there are two overlapping X11WindowOzone instances, the first one that registered itself in PlatformEventSource will be the one receiving mouse events in the overlapping area, even if it is not the foreground window. CL fixes it by making it possible to pass the original ui::PlatformEvent event alongside with the ui::Event instance created off of it, which allows X11WindowOzone::CanDispatchEvent to minic the check that both X11WindowOzone and DesktopWindowTreeHostX11 do. BUG=707406

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+24 lines, -7 lines) Patch
M ui/events/platform/x11/x11_event_source_libevent.h View 1 chunk +7 lines, -0 lines 0 comments Download
M ui/events/platform/x11/x11_event_source_libevent.cc View 1 chunk +2 lines, -1 line 1 comment Download
M ui/platform_window/x11/x11_window_ozone.cc View 2 chunks +15 lines, -6 lines 1 comment Download

Messages

Total messages: 11 (6 generated)
tonikitoo
Sadrul/Kylechar: This CL is a first attempt to fix the issue. I would like to ...
3 years, 8 months ago (2017-04-03 04:26:41 UTC) #6
fwang
This approach l g t m. (I guess the only not-so-nice thing is that a ...
3 years, 8 months ago (2017-04-03 09:36:57 UTC) #8
kylechar
We need sadrul@ to chime in here but I'm not totally sure this approach will ...
3 years, 8 months ago (2017-04-03 13:13:45 UTC) #9
sadrul
https://codereview.chromium.org/2791693003/diff/1/ui/events/platform/x11/x11_event_source_libevent.cc File ui/events/platform/x11/x11_event_source_libevent.cc (right): https://codereview.chromium.org/2791693003/diff/1/ui/events/platform/x11/x11_event_source_libevent.cc#newcode162 ui/events/platform/x11/x11_event_source_libevent.cc:162: DispatchEvent(&ewxe); This is fairly hacky. Maybe this should always ...
3 years, 8 months ago (2017-04-04 04:02:07 UTC) #10
tonikitoo
3 years, 8 months ago (2017-04-04 04:07:31 UTC) #11
Thanks for looking kyle/sadrul/fred.

On 2017/04/04 04:02:07, sadrul wrote:
>
https://codereview.chromium.org/2791693003/diff/1/ui/events/platform/x11/x11_...
> File ui/events/platform/x11/x11_event_source_libevent.cc (right):
> 
>
https://codereview.chromium.org/2791693003/diff/1/ui/events/platform/x11/x11_...
> ui/events/platform/x11/x11_event_source_libevent.cc:162: DispatchEvent(&ewxe);
> This is fairly hacky.

Right, this ain't to be a final solution. The CL was an attempt to make it
explicit what the problem was.

> Maybe this should always go through the XEventDispatcher, or negotiate with
the
> XEventDispatchers to find the real target first?

Alternatively, we could to the "XEvent -> ui::Event" conversion in
x11_window_ozone.cc instead of in x11_event_source_libevent.cc?

Powered by Google App Engine
This is Rietveld 408576698