OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/events.h" | 5 #include "ui/base/events.h" |
6 | 6 |
| 7 #include <linux/input.h> |
7 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
8 | 9 |
| 10 #include "base/event_types.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 12 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
11 #include "ui/wayland/events/wayland_event.h" | |
12 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
13 | 14 |
| 15 using namespace base::wayland; |
| 16 |
| 17 namespace ui { |
| 18 |
| 19 // These are the mouse events expected. The event type Wayland sends is an |
| 20 // evdev event. The following is the correct mapping from evdev to expected |
| 21 // events type. |
| 22 enum WaylandEventButtonType { |
| 23 LEFT_BUTTON = BTN_LEFT, |
| 24 MIDDLE_BUTTON = BTN_RIGHT, |
| 25 RIGHT_BUTTON = BTN_MIDDLE, |
| 26 SCROLL_UP = BTN_SIDE, |
| 27 SCROLL_DOWN = BTN_EXTRA, |
| 28 }; |
| 29 |
| 30 } // namespace ui |
| 31 |
14 namespace { | 32 namespace { |
15 | 33 |
16 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. | 34 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. |
17 static int kWheelScrollAmount = 53; | 35 static int kWheelScrollAmount = 53; |
18 | 36 |
19 int GetEventFlagsFromState(unsigned int state) { | 37 int GetEventFlagsFromState(unsigned int state) { |
20 int flags = 0; | 38 int flags = 0; |
21 if (state & ControlMask) | 39 if (state & ControlMask) |
22 flags |= ui::EF_CONTROL_DOWN; | 40 flags |= ui::EF_CONTROL_DOWN; |
23 if (state & ShiftMask) | 41 if (state & ShiftMask) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return KeyboardCodeFromXKeysym(native_event->key.sym); | 137 return KeyboardCodeFromXKeysym(native_event->key.sym); |
120 } | 138 } |
121 | 139 |
122 bool IsMouseEvent(const base::NativeEvent& native_event) { | 140 bool IsMouseEvent(const base::NativeEvent& native_event) { |
123 return native_event->type == WAYLAND_BUTTON || | 141 return native_event->type == WAYLAND_BUTTON || |
124 native_event->type == WAYLAND_MOTION || | 142 native_event->type == WAYLAND_MOTION || |
125 native_event->type == WAYLAND_POINTER_FOCUS; | 143 native_event->type == WAYLAND_POINTER_FOCUS; |
126 } | 144 } |
127 | 145 |
128 int GetMouseWheelOffset(const base::NativeEvent& native_event) { | 146 int GetMouseWheelOffset(const base::NativeEvent& native_event) { |
129 return native_event->button.button == ui::SCROLL_UP ? | 147 return native_event->button.button == SCROLL_UP ? |
130 kWheelScrollAmount : -kWheelScrollAmount; | 148 kWheelScrollAmount : -kWheelScrollAmount; |
131 } | 149 } |
132 | 150 |
133 } // namespace ui | 151 } // namespace ui |
OLD | NEW |