Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: ui/base/wayland/events_wayland.cc

Issue 8378005: wayland: define base:NativeEvent for Wayland (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per reviewer feedback. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
oshima 2011/11/11 20:36:53 remove extra line
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698