| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/events_test_utils_x11.h" | 5 #include "ui/events/test/events_test_utils_x11.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XI2.h> | 7 #include <X11/extensions/XI2.h> |
| 8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
| 9 #include <X11/X.h> | 9 #include <X11/X.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // The button release X events for mouse wheels are dropped by Aura. | 52 // The button release X events for mouse wheels are dropped by Aura. |
| 53 return XI_ButtonPress; | 53 return XI_ButtonPress; |
| 54 case ui::ET_MOUSE_RELEASED: | 54 case ui::ET_MOUSE_RELEASED: |
| 55 return XI_ButtonRelease; | 55 return XI_ButtonRelease; |
| 56 default: | 56 default: |
| 57 NOTREACHED(); | 57 NOTREACHED(); |
| 58 return 0; | 58 return 0; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Converts KeyboardCode to XKeyEvent keycode. | |
| 63 unsigned int XKeyEventKeyCode(ui::KeyboardCode key_code, | |
| 64 int flags, | |
| 65 XDisplay* display) { | |
| 66 // XKeyEvent keycode is hardware keycode which doesn't consider SHIFT state. | |
| 67 // There are bugs in XKeysymToKeycode that it returns wrong keycode for keysym | |
| 68 // with SHIFT state. e.g. XK_less should return 59 but returns 94; | |
| 69 // XK_parenright should return 19 but returns 188; etc. | |
| 70 return XKeysymToKeycode(display, XKeysymForWindowsKeyCode(key_code, false)); | |
| 71 } | |
| 72 | |
| 73 // Converts Aura event type and flag to X button event. | 62 // Converts Aura event type and flag to X button event. |
| 74 unsigned int XButtonEventButton(ui::EventType type, | 63 unsigned int XButtonEventButton(ui::EventType type, |
| 75 int flags) { | 64 int flags) { |
| 76 // Aura events don't keep track of mouse wheel button, so just return | 65 // Aura events don't keep track of mouse wheel button, so just return |
| 77 // the first mouse wheel button. | 66 // the first mouse wheel button. |
| 78 if (type == ui::ET_MOUSEWHEEL) | 67 if (type == ui::ET_MOUSEWHEEL) |
| 79 return Button4; | 68 return Button4; |
| 80 | 69 |
| 81 if (flags & ui::EF_LEFT_MOUSE_BUTTON) | 70 if (flags & ui::EF_LEFT_MOUSE_BUTTON) |
| 82 return Button1; | 71 return Button1; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); | 266 manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list); |
| 278 } | 267 } |
| 279 | 268 |
| 280 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { | 269 void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) { |
| 281 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); | 270 TouchFactory::GetInstance()->SetTouchDeviceForTest(devices); |
| 282 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); | 271 ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance(); |
| 283 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); | 272 manager->SetDeviceListForTest(devices, std::vector<unsigned int>()); |
| 284 } | 273 } |
| 285 | 274 |
| 286 } // namespace ui | 275 } // namespace ui |
| OLD | NEW |