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

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

Issue 1120813002: Remove EF_FUNCTION_KEY and EF_NUMPAD_KEY. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments (wez@) Created 5 years, 7 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/test/events_test_utils_x11.cc ('k') | ui/events/x/events_x_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 <string.h> 7 #include <string.h>
8 #include <X11/extensions/XInput.h> 8 #include <X11/extensions/XInput.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const unsigned int shift_lock_mask = ShiftMask | LockMask; 184 const unsigned int shift_lock_mask = ShiftMask | LockMask;
185 const bool fabricated_by_xim = 185 const bool fabricated_by_xim =
186 xevent->xkey.keycode == 0 && 186 xevent->xkey.keycode == 0 &&
187 (xevent->xkey.state & ~shift_lock_mask) == 0; 187 (xevent->xkey.state & ~shift_lock_mask) == 0;
188 const int ime_fabricated_flag = 188 const int ime_fabricated_flag =
189 fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0; 189 fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0;
190 #endif 190 #endif
191 191
192 return GetEventFlagsFromXState(xevent->xkey.state) | 192 return GetEventFlagsFromXState(xevent->xkey.state) |
193 (xevent->xkey.send_event ? ui::EF_FINAL : 0) | 193 (xevent->xkey.send_event ? ui::EF_FINAL : 0) |
194 (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0) |
195 (IsFunctionKey(XLookupKeysym(&xevent->xkey, 0)) ?
196 ui::EF_FUNCTION_KEY : 0) |
197 ime_fabricated_flag; 194 ime_fabricated_flag;
198 } 195 }
199 196
200 int GetEventFlagsFromXGenericEvent(XEvent* xevent) { 197 int GetEventFlagsFromXGenericEvent(XEvent* xevent) {
201 DCHECK(xevent->type == GenericEvent); 198 DCHECK(xevent->type == GenericEvent);
202 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); 199 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data);
203 DCHECK((xievent->evtype == XI_KeyPress) || 200 DCHECK((xievent->evtype == XI_KeyPress) ||
204 (xievent->evtype == XI_KeyRelease)); 201 (xievent->evtype == XI_KeyRelease));
205 return GetEventFlagsFromXState(xievent->mods.effective) | 202 return GetEventFlagsFromXState(xievent->mods.effective) |
206 (xevent->xkey.send_event ? ui::EF_FINAL : 0) | 203 (xevent->xkey.send_event ? ui::EF_FINAL : 0);
207 (IsKeypadKey(
208 XkbKeycodeToKeysym(xievent->display, xievent->detail, 0, 0))
209 ? ui::EF_NUMPAD_KEY
210 : 0);
211 } 204 }
212 205
213 // Get the event flag for the button in XButtonEvent. During a ButtonPress 206 // Get the event flag for the button in XButtonEvent. During a ButtonPress
214 // event, |state| in XButtonEvent does not include the button that has just been 207 // event, |state| in XButtonEvent does not include the button that has just been
215 // pressed. Instead |state| contains flags for the buttons (if any) that had 208 // pressed. Instead |state| contains flags for the buttons (if any) that had
216 // already been pressed before the current button, and |button| stores the most 209 // already been pressed before the current button, and |button| stores the most
217 // current pressed button. So, if you press down left mouse button, and while 210 // current pressed button. So, if you press down left mouse button, and while
218 // pressing it down, press down the right mouse button, then for the latter 211 // pressing it down, press down the right mouse button, then for the latter
219 // event, |state| would have Button1Mask set but not Button3Mask, and |button| 212 // event, |state| would have Button1Mask set but not Button3Mask, and |button|
220 // would be 3. 213 // would be 3.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 int ui; 294 int ui;
302 int x; 295 int x;
303 } flags[] = { 296 } flags[] = {
304 {ui::EF_CONTROL_DOWN, ControlMask}, 297 {ui::EF_CONTROL_DOWN, ControlMask},
305 {ui::EF_SHIFT_DOWN, ShiftMask}, 298 {ui::EF_SHIFT_DOWN, ShiftMask},
306 {ui::EF_ALT_DOWN, Mod1Mask}, 299 {ui::EF_ALT_DOWN, Mod1Mask},
307 {ui::EF_CAPS_LOCK_DOWN, LockMask}, 300 {ui::EF_CAPS_LOCK_DOWN, LockMask},
308 {ui::EF_ALTGR_DOWN, Mod5Mask}, 301 {ui::EF_ALTGR_DOWN, Mod5Mask},
309 {ui::EF_COMMAND_DOWN, Mod4Mask}, 302 {ui::EF_COMMAND_DOWN, Mod4Mask},
310 {ui::EF_MOD3_DOWN, Mod3Mask}, 303 {ui::EF_MOD3_DOWN, Mod3Mask},
311 {ui::EF_NUMPAD_KEY, Mod2Mask},
312 {ui::EF_LEFT_MOUSE_BUTTON, Button1Mask}, 304 {ui::EF_LEFT_MOUSE_BUTTON, Button1Mask},
313 {ui::EF_MIDDLE_MOUSE_BUTTON, Button2Mask}, 305 {ui::EF_MIDDLE_MOUSE_BUTTON, Button2Mask},
314 {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask}, 306 {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask},
315 }; 307 };
316 unsigned int new_x_flags = old_x_flags; 308 unsigned int new_x_flags = old_x_flags;
317 for (size_t i = 0; i < arraysize(flags); ++i) { 309 for (size_t i = 0; i < arraysize(flags); ++i) {
318 if (ui_flags & flags[i].ui) 310 if (ui_flags & flags[i].ui)
319 new_x_flags |= flags[i].x; 311 new_x_flags |= flags[i].x;
320 else 312 else
321 new_x_flags &= ~flags[i].x; 313 new_x_flags &= ~flags[i].x;
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 xievent->detail = 900 xievent->detail =
909 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); 901 UpdateX11EventButton(event->changed_button_flags(), xievent->detail);
910 break; 902 break;
911 } 903 }
912 default: 904 default:
913 break; 905 break;
914 } 906 }
915 } 907 }
916 908
917 } // namespace ui 909 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/test/events_test_utils_x11.cc ('k') | ui/events/x/events_x_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698