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

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

Issue 1135083004: Revert of Remove EF_FUNCTION_KEY and EF_NUMPAD_KEY. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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) |
194 ime_fabricated_flag; 197 ime_fabricated_flag;
195 } 198 }
196 199
197 int GetEventFlagsFromXGenericEvent(XEvent* xevent) { 200 int GetEventFlagsFromXGenericEvent(XEvent* xevent) {
198 DCHECK(xevent->type == GenericEvent); 201 DCHECK(xevent->type == GenericEvent);
199 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); 202 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data);
200 DCHECK((xievent->evtype == XI_KeyPress) || 203 DCHECK((xievent->evtype == XI_KeyPress) ||
201 (xievent->evtype == XI_KeyRelease)); 204 (xievent->evtype == XI_KeyRelease));
202 return GetEventFlagsFromXState(xievent->mods.effective) | 205 return GetEventFlagsFromXState(xievent->mods.effective) |
203 (xevent->xkey.send_event ? ui::EF_FINAL : 0); 206 (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);
204 } 211 }
205 212
206 // Get the event flag for the button in XButtonEvent. During a ButtonPress 213 // Get the event flag for the button in XButtonEvent. During a ButtonPress
207 // event, |state| in XButtonEvent does not include the button that has just been 214 // event, |state| in XButtonEvent does not include the button that has just been
208 // pressed. Instead |state| contains flags for the buttons (if any) that had 215 // pressed. Instead |state| contains flags for the buttons (if any) that had
209 // already been pressed before the current button, and |button| stores the most 216 // already been pressed before the current button, and |button| stores the most
210 // current pressed button. So, if you press down left mouse button, and while 217 // current pressed button. So, if you press down left mouse button, and while
211 // pressing it down, press down the right mouse button, then for the latter 218 // pressing it down, press down the right mouse button, then for the latter
212 // event, |state| would have Button1Mask set but not Button3Mask, and |button| 219 // event, |state| would have Button1Mask set but not Button3Mask, and |button|
213 // would be 3. 220 // would be 3.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 int ui; 301 int ui;
295 int x; 302 int x;
296 } flags[] = { 303 } flags[] = {
297 {ui::EF_CONTROL_DOWN, ControlMask}, 304 {ui::EF_CONTROL_DOWN, ControlMask},
298 {ui::EF_SHIFT_DOWN, ShiftMask}, 305 {ui::EF_SHIFT_DOWN, ShiftMask},
299 {ui::EF_ALT_DOWN, Mod1Mask}, 306 {ui::EF_ALT_DOWN, Mod1Mask},
300 {ui::EF_CAPS_LOCK_DOWN, LockMask}, 307 {ui::EF_CAPS_LOCK_DOWN, LockMask},
301 {ui::EF_ALTGR_DOWN, Mod5Mask}, 308 {ui::EF_ALTGR_DOWN, Mod5Mask},
302 {ui::EF_COMMAND_DOWN, Mod4Mask}, 309 {ui::EF_COMMAND_DOWN, Mod4Mask},
303 {ui::EF_MOD3_DOWN, Mod3Mask}, 310 {ui::EF_MOD3_DOWN, Mod3Mask},
311 {ui::EF_NUMPAD_KEY, Mod2Mask},
304 {ui::EF_LEFT_MOUSE_BUTTON, Button1Mask}, 312 {ui::EF_LEFT_MOUSE_BUTTON, Button1Mask},
305 {ui::EF_MIDDLE_MOUSE_BUTTON, Button2Mask}, 313 {ui::EF_MIDDLE_MOUSE_BUTTON, Button2Mask},
306 {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask}, 314 {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask},
307 }; 315 };
308 unsigned int new_x_flags = old_x_flags; 316 unsigned int new_x_flags = old_x_flags;
309 for (size_t i = 0; i < arraysize(flags); ++i) { 317 for (size_t i = 0; i < arraysize(flags); ++i) {
310 if (ui_flags & flags[i].ui) 318 if (ui_flags & flags[i].ui)
311 new_x_flags |= flags[i].x; 319 new_x_flags |= flags[i].x;
312 else 320 else
313 new_x_flags &= ~flags[i].x; 321 new_x_flags &= ~flags[i].x;
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 xievent->detail = 908 xievent->detail =
901 UpdateX11EventButton(event->changed_button_flags(), xievent->detail); 909 UpdateX11EventButton(event->changed_button_flags(), xievent->detail);
902 break; 910 break;
903 } 911 }
904 default: 912 default:
905 break; 913 break;
906 } 914 }
907 } 915 }
908 916
909 } // namespace ui 917 } // 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