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

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

Issue 1559163002: Clean up event flags a bit: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 4 years, 11 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
« no previous file with comments | « ui/events/win/events_win.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (!ui::DeviceDataManagerX11::GetInstance()->GetDataRange( 137 if (!ui::DeviceDataManagerX11::GetInstance()->GetDataRange(
138 deviceid, ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, &min, &max)) { 138 deviceid, ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, &min, &max)) {
139 return false; 139 return false;
140 } 140 }
141 141
142 return radius * 2 == max; 142 return radius * 2 == max;
143 } 143 }
144 144
145 int GetEventFlagsFromXState(unsigned int state) { 145 int GetEventFlagsFromXState(unsigned int state) {
146 int flags = 0; 146 int flags = 0;
147 if (state & ShiftMask)
148 flags |= ui::EF_SHIFT_DOWN;
149 if (state & LockMask)
150 flags |= ui::EF_CAPS_LOCK_ON;
147 if (state & ControlMask) 151 if (state & ControlMask)
148 flags |= ui::EF_CONTROL_DOWN; 152 flags |= ui::EF_CONTROL_DOWN;
149 if (state & ShiftMask)
150 flags |= ui::EF_SHIFT_DOWN;
151 if (state & Mod1Mask) 153 if (state & Mod1Mask)
152 flags |= ui::EF_ALT_DOWN; 154 flags |= ui::EF_ALT_DOWN;
153 if (state & LockMask)
154 flags |= ui::EF_CAPS_LOCK_DOWN;
155 if (state & Mod2Mask) 155 if (state & Mod2Mask)
156 flags |= ui::EF_NUM_LOCK_DOWN; 156 flags |= ui::EF_NUM_LOCK_ON;
157 if (state & Mod3Mask) 157 if (state & Mod3Mask)
158 flags |= ui::EF_MOD3_DOWN; 158 flags |= ui::EF_MOD3_DOWN;
159 if (state & Mod4Mask) 159 if (state & Mod4Mask)
160 flags |= ui::EF_COMMAND_DOWN; 160 flags |= ui::EF_COMMAND_DOWN;
161 if (state & Mod5Mask) 161 if (state & Mod5Mask)
162 flags |= ui::EF_ALTGR_DOWN; 162 flags |= ui::EF_ALTGR_DOWN;
163 if (state & Button1Mask) 163 if (state & Button1Mask)
164 flags |= ui::EF_LEFT_MOUSE_BUTTON; 164 flags |= ui::EF_LEFT_MOUSE_BUTTON;
165 if (state & Button2Mask) 165 if (state & Button2Mask)
166 flags |= ui::EF_MIDDLE_MOUSE_BUTTON; 166 flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data); 292 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
293 ui::DeviceDataManagerX11::GetInstance()->ApplyTouchRadiusScale( 293 ui::DeviceDataManagerX11::GetInstance()->ApplyTouchRadiusScale(
294 xiev->sourceid, radius); 294 xiev->sourceid, radius);
295 } 295 }
296 296
297 unsigned int UpdateX11EventFlags(int ui_flags, unsigned int old_x_flags) { 297 unsigned int UpdateX11EventFlags(int ui_flags, unsigned int old_x_flags) {
298 static struct { 298 static struct {
299 int ui; 299 int ui;
300 int x; 300 int x;
301 } flags[] = { 301 } flags[] = {
302 {ui::EF_SHIFT_DOWN, ShiftMask},
303 {ui::EF_CAPS_LOCK_ON, LockMask},
302 {ui::EF_CONTROL_DOWN, ControlMask}, 304 {ui::EF_CONTROL_DOWN, ControlMask},
303 {ui::EF_SHIFT_DOWN, ShiftMask},
304 {ui::EF_ALT_DOWN, Mod1Mask}, 305 {ui::EF_ALT_DOWN, Mod1Mask},
305 {ui::EF_CAPS_LOCK_DOWN, LockMask}, 306 {ui::EF_NUM_LOCK_ON, Mod2Mask},
307 {ui::EF_MOD3_DOWN, Mod3Mask},
308 {ui::EF_COMMAND_DOWN, Mod4Mask},
306 {ui::EF_ALTGR_DOWN, Mod5Mask}, 309 {ui::EF_ALTGR_DOWN, Mod5Mask},
307 {ui::EF_COMMAND_DOWN, Mod4Mask},
308 {ui::EF_MOD3_DOWN, Mod3Mask},
309 {ui::EF_LEFT_MOUSE_BUTTON, Button1Mask}, 310 {ui::EF_LEFT_MOUSE_BUTTON, Button1Mask},
310 {ui::EF_MIDDLE_MOUSE_BUTTON, Button2Mask}, 311 {ui::EF_MIDDLE_MOUSE_BUTTON, Button2Mask},
311 {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask}, 312 {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask},
312 }; 313 };
313 unsigned int new_x_flags = old_x_flags; 314 unsigned int new_x_flags = old_x_flags;
314 for (size_t i = 0; i < arraysize(flags); ++i) { 315 for (size_t i = 0; i < arraysize(flags); ++i) {
315 if (ui_flags & flags[i].ui) 316 if (ui_flags & flags[i].ui)
316 new_x_flags |= flags[i].x; 317 new_x_flags |= flags[i].x;
317 else 318 else
318 new_x_flags &= ~flags[i].x; 319 new_x_flags &= ~flags[i].x;
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 xievent->detail = 884 xievent->detail =
884 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); 885 UpdateX11EventButton(event->changed_button_flags(), xievent->detail);
885 break; 886 break;
886 } 887 }
887 default: 888 default:
888 break; 889 break;
889 } 890 }
890 } 891 }
891 892
892 } // namespace ui 893 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/win/events_win.cc ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698