| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/x/events_x_utils.h" | 5 #include "ui/events/x/events_x_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <X11/extensions/XInput.h> | 9 #include <X11/extensions/XInput.h> |
| 10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
| 11 #include <X11/XKBlib.h> | 11 #include <X11/XKBlib.h> |
| 12 #include <X11/Xlib.h> | 12 #include <X11/Xlib.h> |
| 13 #include <X11/Xutil.h> | 13 #include <X11/Xutil.h> |
| 14 #include <cmath> | 14 #include <cmath> |
| 15 | 15 |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "ui/events/devices/x11/device_data_manager_x11.h" | 20 #include "ui/events/devices/x11/device_data_manager_x11.h" |
| 21 #include "ui/events/devices/x11/device_list_cache_x11.h" | 21 #include "ui/events/devices/x11/device_list_cache_x11.h" |
| 22 #include "ui/events/devices/x11/touch_factory_x11.h" | 22 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 23 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 23 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 24 #include "ui/gfx/display.h" | 24 #include "ui/gfx/display.h" |
| 25 #include "ui/gfx/geometry/point.h" | 25 #include "ui/gfx/geometry/point.h" |
| 26 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 27 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
| 28 #include "ui/gfx/x/x11_atom_cache.h" | 28 #include "ui/gfx/x/x11_atom_cache.h" |
| 29 #include "ui/gfx/x/x11_types.h" | |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. | 32 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. |
| 34 const int kWheelScrollAmount = 53; | 33 const int kWheelScrollAmount = 53; |
| 35 | 34 |
| 36 const int kMinWheelButton = 4; | 35 const int kMinWheelButton = 4; |
| 37 const int kMaxWheelButton = 7; | 36 const int kMaxWheelButton = 7; |
| 38 | 37 |
| 39 // A class to track current modifier state on master device. Only track ctrl, | 38 // A class to track current modifier state on master device. Only track ctrl, |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 if (g_last_seen_timestamp_ms_ - timestamp_64 > (UINT32_MAX >> 1)) | 316 if (g_last_seen_timestamp_ms_ - timestamp_64 > (UINT32_MAX >> 1)) |
| 318 g_rollover_ms_ += static_cast<int64_t>(UINT32_MAX) + 1; // ~49.7 days. | 317 g_rollover_ms_ += static_cast<int64_t>(UINT32_MAX) + 1; // ~49.7 days. |
| 319 g_last_seen_timestamp_ms_ = timestamp_64; | 318 g_last_seen_timestamp_ms_ = timestamp_64; |
| 320 return base::TimeDelta::FromMilliseconds(g_rollover_ms_ + timestamp_64); | 319 return base::TimeDelta::FromMilliseconds(g_rollover_ms_ + timestamp_64); |
| 321 } | 320 } |
| 322 | 321 |
| 323 } // namespace | 322 } // namespace |
| 324 | 323 |
| 325 namespace ui { | 324 namespace ui { |
| 326 | 325 |
| 326 XID XWindowFromXEvent(const XEvent& xev) { |
| 327 XID target = xev.xany.window; |
| 328 if (xev.type == GenericEvent) |
| 329 target = static_cast<XIDeviceEvent*>(xev.xcookie.data)->event; |
| 330 return target; |
| 331 } |
| 332 |
| 327 EventType EventTypeFromXEvent(const XEvent& xev) { | 333 EventType EventTypeFromXEvent(const XEvent& xev) { |
| 328 // Allow the DeviceDataManager to block the event. If blocked return | 334 // Allow the DeviceDataManager to block the event. If blocked return |
| 329 // ET_UNKNOWN as the type so this event will not be further processed. | 335 // ET_UNKNOWN as the type so this event will not be further processed. |
| 330 // NOTE: During some events unittests there is no device data manager. | 336 // NOTE: During some events unittests there is no device data manager. |
| 331 if (DeviceDataManager::HasInstance() && | 337 if (DeviceDataManager::HasInstance() && |
| 332 static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance()) | 338 static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance()) |
| 333 ->IsEventBlocked(xev)) { | 339 ->IsEventBlocked(xev)) { |
| 334 return ET_UNKNOWN; | 340 return ET_UNKNOWN; |
| 335 } | 341 } |
| 336 | 342 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 vy_ordinal, is_cancel); | 776 vy_ordinal, is_cancel); |
| 771 return true; | 777 return true; |
| 772 } | 778 } |
| 773 | 779 |
| 774 void ResetTimestampRolloverCountersForTesting() { | 780 void ResetTimestampRolloverCountersForTesting() { |
| 775 g_last_seen_timestamp_ms_ = 0; | 781 g_last_seen_timestamp_ms_ = 0; |
| 776 g_rollover_ms_ = 0; | 782 g_rollover_ms_ = 0; |
| 777 } | 783 } |
| 778 | 784 |
| 779 } // namespace ui | 785 } // namespace ui |
| OLD | NEW |