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