OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/events/platform/x11/x11_event_source.h" | 5 #include "ui/events/platform/x11/x11_event_source.h" |
6 | 6 |
7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
8 #include <X11/X.h> | 8 #include <X11/X.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/XKBlib.h> | 10 #include <X11/XKBlib.h> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "ui/events/devices/x11/device_data_manager_x11.h" | 13 #include "ui/events/devices/x11/device_data_manager_x11.h" |
14 #include "ui/events/event_utils.h" | 14 #include "ui/events/event_utils.h" |
15 #include "ui/events/platform/platform_event_dispatcher.h" | 15 #include "ui/events/platform/platform_event_dispatcher.h" |
16 #include "ui/events/platform/x11/x11_hotplug_event_handler.h" | 16 #include "ui/events/platform/x11/x11_hotplug_event_handler.h" |
| 17 #include "ui/events/x/events_x.h" |
17 #include "ui/gfx/x/x11_types.h" | 18 #include "ui/gfx/x/x11_types.h" |
18 | 19 |
19 namespace ui { | 20 namespace ui { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 int g_xinput_opcode = -1; | 24 int g_xinput_opcode = -1; |
24 | 25 |
25 bool InitializeXInput2(XDisplay* display) { | 26 bool InitializeXInput2(XDisplay* display) { |
26 if (!display) | 27 if (!display) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // Block until there's a message of |event_mask| type on |w|. Then remove | 114 // Block until there's a message of |event_mask| type on |w|. Then remove |
114 // it from the queue and stuff it in |event|. | 115 // it from the queue and stuff it in |event|. |
115 XWindowEvent(display_, window, StructureNotifyMask, &event); | 116 XWindowEvent(display_, window, StructureNotifyMask, &event); |
116 DispatchEvent(&event); | 117 DispatchEvent(&event); |
117 } while (event.type != MapNotify); | 118 } while (event.type != MapNotify); |
118 } | 119 } |
119 | 120 |
120 //////////////////////////////////////////////////////////////////////////////// | 121 //////////////////////////////////////////////////////////////////////////////// |
121 // X11EventSource, private | 122 // X11EventSource, private |
122 | 123 |
123 uint32_t X11EventSource::DispatchEvent(XEvent* xevent) { | 124 uint32_t X11EventSource::DispatchEvent(base::NativeEvent event) { |
| 125 XEvent* xevent = static_cast<XEvent*>(event); |
124 bool have_cookie = false; | 126 bool have_cookie = false; |
125 if (xevent->type == GenericEvent && | 127 if (xevent->type == GenericEvent && |
126 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { | 128 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { |
127 have_cookie = true; | 129 have_cookie = true; |
128 } | 130 } |
129 | 131 |
130 uint32_t action = PlatformEventSource::DispatchEvent(xevent); | 132 uint32_t action = POST_DISPATCH_STOP_PROPAGATION; |
| 133 #if defined(USE_OZONE) && !defined(USE_X11) |
| 134 event = TranslateXEventToNativeEvent(xevent); |
| 135 #endif |
| 136 if (event) |
| 137 action = PlatformEventSource::DispatchEvent(event); |
131 if (xevent->type == GenericEvent && | 138 if (xevent->type == GenericEvent && |
132 xevent->xgeneric.evtype == XI_HierarchyChanged) { | 139 xevent->xgeneric.evtype == XI_HierarchyChanged) { |
133 ui::UpdateDeviceList(); | 140 ui::UpdateDeviceList(); |
134 hotplug_event_handler_->OnHotplugEvent(); | 141 hotplug_event_handler_->OnHotplugEvent(); |
135 } | 142 } |
136 | 143 |
137 if (have_cookie) | 144 if (have_cookie) |
138 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); | 145 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); |
139 return action; | 146 return action; |
140 } | 147 } |
141 | 148 |
142 void X11EventSource::StopCurrentEventStream() { | 149 void X11EventSource::StopCurrentEventStream() { |
143 continue_stream_ = false; | 150 continue_stream_ = false; |
144 } | 151 } |
145 | 152 |
146 void X11EventSource::OnDispatcherListChanged() { | 153 void X11EventSource::OnDispatcherListChanged() { |
147 if (!hotplug_event_handler_) { | 154 if (!hotplug_event_handler_) { |
148 hotplug_event_handler_.reset(new X11HotplugEventHandler()); | 155 hotplug_event_handler_.reset(new X11HotplugEventHandler()); |
149 // Force the initial device query to have an update list of active devices. | 156 // Force the initial device query to have an update list of active devices. |
150 hotplug_event_handler_->OnHotplugEvent(); | 157 hotplug_event_handler_->OnHotplugEvent(); |
151 } | 158 } |
152 } | 159 } |
153 | 160 |
154 } // namespace ui | 161 } // namespace ui |
OLD | NEW |