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 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "ui/base/x/x11_window_event_manager.h" | 13 #include "ui/base/x/x11_window_event_manager.h" |
14 #include "ui/events/devices/x11/device_data_manager_x11.h" | 14 #include "ui/events/devices/x11/device_data_manager_x11.h" |
15 #include "ui/events/devices/x11/touch_factory_x11.h" | 15 #include "ui/events/devices/x11/touch_factory_x11.h" |
16 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
17 #include "ui/events/platform/platform_event_dispatcher.h" | 17 #include "ui/events/platform/platform_event_dispatcher.h" |
18 #include "ui/events/platform/x11/x11_hotplug_event_handler.h" | 18 #include "ui/events/platform/x11/x11_hotplug_event_handler.h" |
| 19 #include "ui/gfx/x/x11_atom_cache.h" |
19 | 20 |
20 namespace ui { | 21 namespace ui { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 bool InitializeXkb(XDisplay* display) { | 25 bool InitializeXkb(XDisplay* display) { |
25 if (!display) | 26 if (!display) |
26 return false; | 27 return false; |
27 | 28 |
28 int opcode, event, error; | 29 int opcode, event, error; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 BlockOnWindowStructureEvent(window, MapNotify); | 150 BlockOnWindowStructureEvent(window, MapNotify); |
150 } | 151 } |
151 | 152 |
152 Time X11EventSource::GetCurrentServerTime() { | 153 Time X11EventSource::GetCurrentServerTime() { |
153 DCHECK(display_); | 154 DCHECK(display_); |
154 | 155 |
155 if (!dummy_initialized_) { | 156 if (!dummy_initialized_) { |
156 // Create a new Window and Atom that will be used for the property change. | 157 // Create a new Window and Atom that will be used for the property change. |
157 dummy_window_ = XCreateSimpleWindow(display_, DefaultRootWindow(display_), | 158 dummy_window_ = XCreateSimpleWindow(display_, DefaultRootWindow(display_), |
158 0, 0, 1, 1, 0, 0, 0); | 159 0, 0, 1, 1, 0, 0, 0); |
159 dummy_atom_ = XInternAtom(display_, "CHROMIUM_TIMESTAMP", False); | 160 dummy_atom_ = X11AtomCache::GetInstance()->GetAtom("CHROMIUM_TIMESTAMP"); |
160 dummy_window_events_.reset( | 161 dummy_window_events_.reset( |
161 new XScopedEventSelector(dummy_window_, PropertyChangeMask)); | 162 new XScopedEventSelector(dummy_window_, PropertyChangeMask)); |
162 dummy_initialized_ = true; | 163 dummy_initialized_ = true; |
163 } | 164 } |
164 | 165 |
165 base::TimeTicks start = base::TimeTicks::Now(); | 166 base::TimeTicks start = base::TimeTicks::Now(); |
166 | 167 |
167 // Make a no-op property change on |dummy_window_|. | 168 // Make a no-op property change on |dummy_window_|. |
168 XChangeProperty(display_, dummy_window_, dummy_atom_, XA_STRING, 8, | 169 XChangeProperty(display_, dummy_window_, dummy_atom_, XA_STRING, 8, |
169 PropModeAppend, nullptr, 0); | 170 PropModeAppend, nullptr, 0); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 295 |
295 void X11EventSource::OnDispatcherListChanged() { | 296 void X11EventSource::OnDispatcherListChanged() { |
296 if (!hotplug_event_handler_) { | 297 if (!hotplug_event_handler_) { |
297 hotplug_event_handler_.reset(new X11HotplugEventHandler()); | 298 hotplug_event_handler_.reset(new X11HotplugEventHandler()); |
298 // Force the initial device query to have an update list of active devices. | 299 // Force the initial device query to have an update list of active devices. |
299 hotplug_event_handler_->OnHotplugEvent(); | 300 hotplug_event_handler_->OnHotplugEvent(); |
300 } | 301 } |
301 } | 302 } |
302 | 303 |
303 } // namespace ui | 304 } // namespace ui |
OLD | NEW |