Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/platform_window/x11/x11_window_ozone.h" | 5 #include "ui/platform_window/x11/x11_window_ozone.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 if (xwindow() == None) | 65 if (xwindow() == None) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| 68 // If there is a grab, capture events here. | 68 // If there is a grab, capture events here. |
| 69 XID grabber = window_manager_->event_grabber(); | 69 XID grabber = window_manager_->event_grabber(); |
| 70 if (grabber != None) | 70 if (grabber != None) |
| 71 return grabber == xwindow(); | 71 return grabber == xwindow(); |
| 72 | 72 |
| 73 // TODO(kylechar): We may need to do something special for TouchEvents similar | 73 // TODO(kylechar): We may need to do something special for TouchEvents similar |
| 74 // to how DrmWindowHost handles them. | 74 // to how DrmWindowHost handles them. |
| 75 if (static_cast<Event*>(platform_event)->IsLocatedEvent()) { | 75 auto* ewpe = static_cast<EventWithPlatformEvent*>(platform_event); |
| 76 const LocatedEvent* event = | 76 auto* xev = static_cast<XEvent*>(ewpe->platform_event); |
| 77 static_cast<const LocatedEvent*>(platform_event); | 77 DCHECK(xev); |
| 78 return GetBounds().Contains(event->root_location()); | 78 if (!IsEventForXWindow(*xev)) |
| 79 return false; | |
| 80 | |
| 81 Event* event = ewpe->event; | |
| 82 DCHECK(event); | |
| 83 if (event->IsLocatedEvent()) { | |
| 84 const LocatedEvent* located_event = static_cast<const LocatedEvent*>(event); | |
| 85 return GetBounds().Contains(located_event->root_location()); | |
| 79 } | 86 } |
| 80 | 87 |
| 81 return true; | 88 return true; |
| 82 } | 89 } |
| 83 | 90 |
| 84 uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& platform_event) { | 91 uint32_t X11WindowOzone::DispatchEvent(const PlatformEvent& platform_event) { |
| 85 // This is unfortunately needed otherwise events that depend on global state | 92 // This is unfortunately needed otherwise events that depend on global state |
| 86 // (eg. double click) are broken. | 93 // (eg. double click) are broken. |
| 94 auto* ewpe = static_cast<EventWithPlatformEvent*>(platform_event); | |
| 95 auto* event = static_cast<ui::Event*>(ewpe->event); | |
|
fwang
2017/04/03 09:36:57
I guess you want DCHECK(event) here.
| |
| 87 DispatchEventFromNativeUiEvent( | 96 DispatchEventFromNativeUiEvent( |
| 88 platform_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 97 event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
| 89 base::Unretained(delegate()))); | 98 base::Unretained(delegate()))); |
| 90 return POST_DISPATCH_STOP_PROPAGATION; | 99 return POST_DISPATCH_STOP_PROPAGATION; |
| 91 } | 100 } |
| 92 | 101 |
| 93 } // namespace ui | 102 } // namespace ui |
| OLD | NEW |