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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 X11EventSource* X11EventSource::instance_ = nullptr; | 93 X11EventSource* X11EventSource::instance_ = nullptr; |
94 | 94 |
95 X11EventSource::X11EventSource(X11EventSourceDelegate* delegate, | 95 X11EventSource::X11EventSource(X11EventSourceDelegate* delegate, |
96 XDisplay* display) | 96 XDisplay* display) |
97 : delegate_(delegate), | 97 : delegate_(delegate), |
98 display_(display), | 98 display_(display), |
99 event_timestamp_(CurrentTime), | 99 event_timestamp_(CurrentTime), |
100 dispatching_event_(nullptr), | |
100 dummy_initialized_(false), | 101 dummy_initialized_(false), |
101 continue_stream_(true) { | 102 continue_stream_(true) { |
102 DCHECK(!instance_); | 103 DCHECK(!instance_); |
103 instance_ = this; | 104 instance_ = this; |
104 | 105 |
105 DCHECK(delegate_); | 106 DCHECK(delegate_); |
106 DCHECK(display_); | 107 DCHECK(display_); |
107 DeviceDataManagerX11::CreateInstance(); | 108 DeviceDataManagerX11::CreateInstance(); |
108 InitializeXkb(display_); | 109 InitializeXkb(display_); |
109 } | 110 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 //////////////////////////////////////////////////////////////////////////////// | 195 //////////////////////////////////////////////////////////////////////////////// |
195 // X11EventSource, protected | 196 // X11EventSource, protected |
196 | 197 |
197 void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) { | 198 void X11EventSource::ExtractCookieDataDispatchEvent(XEvent* xevent) { |
198 bool have_cookie = false; | 199 bool have_cookie = false; |
199 if (xevent->type == GenericEvent && | 200 if (xevent->type == GenericEvent && |
200 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { | 201 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { |
201 have_cookie = true; | 202 have_cookie = true; |
202 } | 203 } |
203 | 204 |
205 dispatching_event_ = xevent; | |
204 event_timestamp_ = ExtractTimeFromXEvent(*xevent); | 206 event_timestamp_ = ExtractTimeFromXEvent(*xevent); |
205 | 207 |
206 delegate_->ProcessXEvent(xevent); | 208 delegate_->ProcessXEvent(xevent); |
sadrul
2016/10/07 02:12:51
This can trigger a nested message loop, which mean
Tom (Use chromium acct)
2016/10/07 21:13:18
done: added a stack of events to handle this.
| |
207 PostDispatchEvent(xevent); | 209 PostDispatchEvent(xevent); |
208 | 210 |
209 event_timestamp_ = CurrentTime; | 211 event_timestamp_ = CurrentTime; |
212 dispatching_event_ = nullptr; | |
210 | 213 |
211 if (have_cookie) | 214 if (have_cookie) |
212 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); | 215 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); |
213 } | 216 } |
214 | 217 |
215 void X11EventSource::PostDispatchEvent(XEvent* xevent) { | 218 void X11EventSource::PostDispatchEvent(XEvent* xevent) { |
216 bool should_update_device_list = false; | 219 bool should_update_device_list = false; |
217 | 220 |
218 if (xevent->type == GenericEvent) { | 221 if (xevent->type == GenericEvent) { |
219 if (xevent->xgeneric.evtype == XI_HierarchyChanged) { | 222 if (xevent->xgeneric.evtype == XI_HierarchyChanged) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 | 263 |
261 void X11EventSource::OnDispatcherListChanged() { | 264 void X11EventSource::OnDispatcherListChanged() { |
262 if (!hotplug_event_handler_) { | 265 if (!hotplug_event_handler_) { |
263 hotplug_event_handler_.reset(new X11HotplugEventHandler()); | 266 hotplug_event_handler_.reset(new X11HotplugEventHandler()); |
264 // Force the initial device query to have an update list of active devices. | 267 // Force the initial device query to have an update list of active devices. |
265 hotplug_event_handler_->OnHotplugEvent(); | 268 hotplug_event_handler_->OnHotplugEvent(); |
266 } | 269 } |
267 } | 270 } |
268 | 271 |
269 } // namespace ui | 272 } // namespace ui |
OLD | NEW |