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/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/XKBlib.h> | 8 #include <X11/XKBlib.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 | 10 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 if (time_difference < 0 || time_difference > (UINT32_MAX >> 1)) | 199 if (time_difference < 0 || time_difference > (UINT32_MAX >> 1)) |
200 last_seen_server_time_ = event_time; | 200 last_seen_server_time_ = event_time; |
201 } | 201 } |
202 delegate_->ProcessXEvent(xevent); | 202 delegate_->ProcessXEvent(xevent); |
203 PostDispatchEvent(xevent); | 203 PostDispatchEvent(xevent); |
204 if (have_cookie) | 204 if (have_cookie) |
205 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); | 205 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); |
206 } | 206 } |
207 | 207 |
208 void X11EventSource::PostDispatchEvent(XEvent* xevent) { | 208 void X11EventSource::PostDispatchEvent(XEvent* xevent) { |
209 if (xevent->type == GenericEvent && | 209 bool should_update_device_list = false; |
210 (xevent->xgeneric.evtype == XI_HierarchyChanged || | 210 |
211 xevent->xgeneric.evtype == XI_DeviceChanged)) { | 211 if (xevent->type == GenericEvent) { |
212 if (xevent->xgeneric.evtype == XI_HierarchyChanged) { | |
213 should_update_device_list = true; | |
214 } else if (xevent->xgeneric.evtype == XI_DeviceChanged) { | |
215 XIDeviceChangedEvent* xev = | |
216 static_cast<XIDeviceChangedEvent*>(xevent->xcookie.data); | |
217 if (xev->reason == XIDeviceChange) { | |
218 should_update_device_list = true; | |
219 } else { | |
220 DCHECK_EQ(XISlaveSwitch, xev->reason); | |
bokan
2016/07/13 14:45:50
Is it guaranteed that there won't ever be a new re
Will Shackleton
2016/07/14 18:11:10
Hah. Not in the current X11 spec but I'll make thi
| |
221 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses( | |
222 xev->sourceid); | |
223 } | |
224 } | |
225 } | |
226 | |
227 if (should_update_device_list) { | |
212 UpdateDeviceList(); | 228 UpdateDeviceList(); |
213 hotplug_event_handler_->OnHotplugEvent(); | 229 hotplug_event_handler_->OnHotplugEvent(); |
214 } | 230 } |
215 | 231 |
216 if (xevent->type == EnterNotify && | 232 if (xevent->type == EnterNotify && |
217 xevent->xcrossing.detail != NotifyInferior && | 233 xevent->xcrossing.detail != NotifyInferior && |
218 xevent->xcrossing.mode != NotifyUngrab) { | 234 xevent->xcrossing.mode != NotifyUngrab) { |
219 // Clear stored scroll data | 235 // Clear stored scroll data |
220 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(); | 236 ui::DeviceDataManagerX11::GetInstance()->InvalidateScrollClasses(-1); |
bokan
2016/07/13 14:45:50
Make the -1 an Enum (e.g. ALL_DEVICES) for readabi
Will Shackleton
2016/07/14 18:11:09
Done.
| |
221 } | 237 } |
222 } | 238 } |
223 | 239 |
224 void X11EventSource::BlockOnWindowStructureEvent(XID window, int type) { | 240 void X11EventSource::BlockOnWindowStructureEvent(XID window, int type) { |
225 XEvent event; | 241 XEvent event; |
226 do { | 242 do { |
227 // Block until there's a StructureNotify event of |type| on |window|. Then | 243 // Block until there's a StructureNotify event of |type| on |window|. Then |
228 // remove it from the queue and stuff it in |event|. | 244 // remove it from the queue and stuff it in |event|. |
229 XWindowEvent(display_, window, StructureNotifyMask, &event); | 245 XWindowEvent(display_, window, StructureNotifyMask, &event); |
230 ExtractCookieDataDispatchEvent(&event); | 246 ExtractCookieDataDispatchEvent(&event); |
231 } while (event.type != type); | 247 } while (event.type != type); |
232 } | 248 } |
233 | 249 |
234 void X11EventSource::StopCurrentEventStream() { | 250 void X11EventSource::StopCurrentEventStream() { |
235 continue_stream_ = false; | 251 continue_stream_ = false; |
236 } | 252 } |
237 | 253 |
238 void X11EventSource::OnDispatcherListChanged() { | 254 void X11EventSource::OnDispatcherListChanged() { |
239 if (!hotplug_event_handler_) { | 255 if (!hotplug_event_handler_) { |
240 hotplug_event_handler_.reset(new X11HotplugEventHandler()); | 256 hotplug_event_handler_.reset(new X11HotplugEventHandler()); |
241 // Force the initial device query to have an update list of active devices. | 257 // Force the initial device query to have an update list of active devices. |
242 hotplug_event_handler_->OnHotplugEvent(); | 258 hotplug_event_handler_->OnHotplugEvent(); |
243 } | 259 } |
244 } | 260 } |
245 | 261 |
246 } // namespace ui | 262 } // namespace ui |
OLD | NEW |