| 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/events/devices/x11/device_data_manager_x11.h" | 14 #include "ui/events/devices/x11/device_data_manager_x11.h" |
| 14 #include "ui/events/devices/x11/touch_factory_x11.h" | 15 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 15 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/platform/platform_event_dispatcher.h" | 17 #include "ui/events/platform/platform_event_dispatcher.h" |
| 17 #include "ui/events/platform/x11/x11_hotplug_event_handler.h" | 18 #include "ui/events/platform/x11/x11_hotplug_event_handler.h" |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 154 } |
| 154 | 155 |
| 155 Time X11EventSource::GetCurrentServerTime() { | 156 Time X11EventSource::GetCurrentServerTime() { |
| 156 DCHECK(display_); | 157 DCHECK(display_); |
| 157 | 158 |
| 158 if (!dummy_initialized_) { | 159 if (!dummy_initialized_) { |
| 159 // Create a new Window and Atom that will be used for the property change. | 160 // Create a new Window and Atom that will be used for the property change. |
| 160 dummy_window_ = XCreateSimpleWindow(display_, DefaultRootWindow(display_), | 161 dummy_window_ = XCreateSimpleWindow(display_, DefaultRootWindow(display_), |
| 161 0, 0, 1, 1, 0, 0, 0); | 162 0, 0, 1, 1, 0, 0, 0); |
| 162 dummy_atom_ = XInternAtom(display_, "CHROMIUM_TIMESTAMP", False); | 163 dummy_atom_ = XInternAtom(display_, "CHROMIUM_TIMESTAMP", False); |
| 163 XSelectInput(display_, dummy_window_, PropertyChangeMask); | 164 dummy_window_events_.reset( |
| 165 new XScopedEventSelector(dummy_window_, PropertyChangeMask)); |
| 164 dummy_initialized_ = true; | 166 dummy_initialized_ = true; |
| 165 } | 167 } |
| 166 | 168 |
| 167 base::TimeTicks start = base::TimeTicks::Now(); | 169 base::TimeTicks start = base::TimeTicks::Now(); |
| 168 | 170 |
| 169 // Make a no-op property change on |dummy_window_|. | 171 // Make a no-op property change on |dummy_window_|. |
| 170 XChangeProperty(display_, dummy_window_, dummy_atom_, XA_STRING, 8, | 172 XChangeProperty(display_, dummy_window_, dummy_atom_, XA_STRING, 8, |
| 171 PropModeAppend, nullptr, 0); | 173 PropModeAppend, nullptr, 0); |
| 172 | 174 |
| 173 // Observe the resulting PropertyNotify event to obtain the timestamp. | 175 // Observe the resulting PropertyNotify event to obtain the timestamp. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 260 |
| 259 void X11EventSource::OnDispatcherListChanged() { | 261 void X11EventSource::OnDispatcherListChanged() { |
| 260 if (!hotplug_event_handler_) { | 262 if (!hotplug_event_handler_) { |
| 261 hotplug_event_handler_.reset(new X11HotplugEventHandler()); | 263 hotplug_event_handler_.reset(new X11HotplugEventHandler()); |
| 262 // Force the initial device query to have an update list of active devices. | 264 // Force the initial device query to have an update list of active devices. |
| 263 hotplug_event_handler_->OnHotplugEvent(); | 265 hotplug_event_handler_->OnHotplugEvent(); |
| 264 } | 266 } |
| 265 } | 267 } |
| 266 | 268 |
| 267 } // namespace ui | 269 } // namespace ui |
| OLD | NEW |