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

Side by Side Diff: ui/events/x/events_x.cc

Issue 237363005: Convert chromeos::EventRewriter to a ui::EventRewriter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/event_constants.h" 5 #include "ui/events/event_constants.h"
6 6
7 #include <cmath> 7 #include <cmath>
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>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 int GetEventFlagsFromXState(unsigned int state) { 130 int GetEventFlagsFromXState(unsigned int state) {
131 int flags = 0; 131 int flags = 0;
132 if (state & ControlMask) 132 if (state & ControlMask)
133 flags |= ui::EF_CONTROL_DOWN; 133 flags |= ui::EF_CONTROL_DOWN;
134 if (state & ShiftMask) 134 if (state & ShiftMask)
135 flags |= ui::EF_SHIFT_DOWN; 135 flags |= ui::EF_SHIFT_DOWN;
136 if (state & Mod1Mask) 136 if (state & Mod1Mask)
137 flags |= ui::EF_ALT_DOWN; 137 flags |= ui::EF_ALT_DOWN;
138 if (state & LockMask) 138 if (state & LockMask)
139 flags |= ui::EF_CAPS_LOCK_DOWN; 139 flags |= ui::EF_CAPS_LOCK_DOWN;
140 if (state & Mod4Mask)
141 flags |= ui::EF_COMMAND_DOWN;
sadrul 2014/04/14 21:51:32 If we are going to use it here, we should update t
140 if (state & Mod5Mask) 142 if (state & Mod5Mask)
141 flags |= ui::EF_ALTGR_DOWN; 143 flags |= ui::EF_ALTGR_DOWN;
142 if (state & Button1Mask) 144 if (state & Button1Mask)
143 flags |= ui::EF_LEFT_MOUSE_BUTTON; 145 flags |= ui::EF_LEFT_MOUSE_BUTTON;
144 if (state & Button2Mask) 146 if (state & Button2Mask)
145 flags |= ui::EF_MIDDLE_MOUSE_BUTTON; 147 flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
146 if (state & Button3Mask) 148 if (state & Button3Mask)
147 flags |= ui::EF_RIGHT_MOUSE_BUTTON; 149 flags |= ui::EF_RIGHT_MOUSE_BUTTON;
148 return flags; 150 return flags;
149 } 151 }
150 152
153 int GetEventFlagsFromXKeyEvent(XEvent* xevent)
sadrul 2014/04/14 21:51:32 { in this line
154 {
155 return GetEventFlagsFromXState(xevent->xkey.state) |
156 ui::EventFlagsFromXKeysym(XLookupKeysym(&xevent->xkey, 0));
sadrul 2014/04/14 21:51:32 If we use the macro from Xutil.h, then perhaps we
157 }
158
151 // Get the event flag for the button in XButtonEvent. During a ButtonPress 159 // Get the event flag for the button in XButtonEvent. During a ButtonPress
152 // event, |state| in XButtonEvent does not include the button that has just been 160 // event, |state| in XButtonEvent does not include the button that has just been
153 // pressed. Instead |state| contains flags for the buttons (if any) that had 161 // pressed. Instead |state| contains flags for the buttons (if any) that had
154 // already been pressed before the current button, and |button| stores the most 162 // already been pressed before the current button, and |button| stores the most
155 // current pressed button. So, if you press down left mouse button, and while 163 // current pressed button. So, if you press down left mouse button, and while
156 // pressing it down, press down the right mouse button, then for the latter 164 // pressing it down, press down the right mouse button, then for the latter
157 // event, |state| would have Button1Mask set but not Button3Mask, and |button| 165 // event, |state| would have Button1Mask set but not Button3Mask, and |button|
158 // would be 3. 166 // would be 3.
159 int GetEventFlagsForButton(int button) { 167 int GetEventFlagsForButton(int button) {
160 switch (button) { 168 switch (button) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 break; 329 break;
322 } 330 }
323 return ET_UNKNOWN; 331 return ET_UNKNOWN;
324 } 332 }
325 333
326 int EventFlagsFromNative(const base::NativeEvent& native_event) { 334 int EventFlagsFromNative(const base::NativeEvent& native_event) {
327 switch (native_event->type) { 335 switch (native_event->type) {
328 case KeyPress: 336 case KeyPress:
329 case KeyRelease: { 337 case KeyRelease: {
330 XModifierStateWatcher::GetInstance()->UpdateStateFromEvent(native_event); 338 XModifierStateWatcher::GetInstance()->UpdateStateFromEvent(native_event);
331 return GetEventFlagsFromXState(native_event->xkey.state); 339 return GetEventFlagsFromXKeyEvent(native_event);
332 } 340 }
333 case ButtonPress: 341 case ButtonPress:
334 case ButtonRelease: { 342 case ButtonRelease: {
335 int flags = GetEventFlagsFromXState(native_event->xbutton.state); 343 int flags = GetEventFlagsFromXState(native_event->xbutton.state);
336 const EventType type = EventTypeFromNative(native_event); 344 const EventType type = EventTypeFromNative(native_event);
337 if (type == ET_MOUSE_PRESSED || type == ET_MOUSE_RELEASED) 345 if (type == ET_MOUSE_PRESSED || type == ET_MOUSE_RELEASED)
338 flags |= GetEventFlagsForButton(native_event->xbutton.button); 346 flags |= GetEventFlagsForButton(native_event->xbutton.button);
339 return flags; 347 return flags;
340 } 348 }
341 case EnterNotify: 349 case EnterNotify:
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 DeviceDataManager::GetInstance()->GetGestureTimes( 673 DeviceDataManager::GetInstance()->GetGestureTimes(
666 native_event, start_time, end_time); 674 native_event, start_time, end_time);
667 return true; 675 return true;
668 } 676 }
669 677
670 bool IsTouchpadEvent(const base::NativeEvent& event) { 678 bool IsTouchpadEvent(const base::NativeEvent& event) {
671 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event); 679 return DeviceDataManager::GetInstance()->IsTouchpadXInputEvent(event);
672 } 680 }
673 681
674 } // namespace ui 682 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698