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

Side by Side Diff: ui/events/win/events_win.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/test/events_test_utils_x11.cc ('k') | ui/events/x/events_x.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 <stdint.h> 5 #include <stdint.h>
6 #include <windowsx.h> 6 #include <windowsx.h>
7 7
8 #include "ui/events/event_constants.h" 8 #include "ui/events/event_constants.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return native_event.message == WM_VSCROLL || 101 return native_event.message == WM_VSCROLL ||
102 native_event.message == WM_HSCROLL; 102 native_event.message == WM_HSCROLL;
103 } 103 }
104 104
105 // Returns a mask corresponding to the set of pressed modifier keys. 105 // Returns a mask corresponding to the set of pressed modifier keys.
106 // Checks the current global state and the state sent by client mouse messages. 106 // Checks the current global state and the state sent by client mouse messages.
107 int KeyStateFlagsFromNative(const base::NativeEvent& native_event) { 107 int KeyStateFlagsFromNative(const base::NativeEvent& native_event) {
108 int flags = GetModifiersFromKeyState(); 108 int flags = GetModifiersFromKeyState();
109 109
110 // Check key messages for the extended key flag. 110 // Check key messages for the extended key flag.
111 if (IsKeyEvent(native_event)) 111 if (IsKeyEvent(native_event) && (HIWORD(native_event.lParam) & KF_EXTENDED))
112 flags |= (HIWORD(native_event.lParam) & KF_EXTENDED) ? EF_EXTENDED : 0; 112 flags |= EF_IS_EXTENDED_KEY;
113 113
114 // Most client mouse messages include key state information. 114 // Most client mouse messages include key state information.
115 if (IsClientMouseEvent(native_event)) { 115 if (IsClientMouseEvent(native_event)) {
116 int win_flags = GET_KEYSTATE_WPARAM(native_event.wParam); 116 int win_flags = GET_KEYSTATE_WPARAM(native_event.wParam);
117 flags |= (win_flags & MK_SHIFT) ? EF_SHIFT_DOWN : 0; 117 flags |= (win_flags & MK_SHIFT) ? EF_SHIFT_DOWN : 0;
118 flags |= (win_flags & MK_CONTROL) ? EF_CONTROL_DOWN : 0; 118 flags |= (win_flags & MK_CONTROL) ? EF_CONTROL_DOWN : 0;
119 } 119 }
120 120
121 return flags; 121 return flags;
122 } 122 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 358 }
359 359
360 int GetModifiersFromKeyState() { 360 int GetModifiersFromKeyState() {
361 int modifiers = EF_NONE; 361 int modifiers = EF_NONE;
362 if (ui::win::IsShiftPressed()) 362 if (ui::win::IsShiftPressed())
363 modifiers |= EF_SHIFT_DOWN; 363 modifiers |= EF_SHIFT_DOWN;
364 if (ui::win::IsCtrlPressed()) 364 if (ui::win::IsCtrlPressed())
365 modifiers |= EF_CONTROL_DOWN; 365 modifiers |= EF_CONTROL_DOWN;
366 if (ui::win::IsAltPressed()) 366 if (ui::win::IsAltPressed())
367 modifiers |= EF_ALT_DOWN; 367 modifiers |= EF_ALT_DOWN;
368 if (ui::win::IsWindowsKeyPressed())
369 modifiers |= EF_COMMAND_DOWN;
368 if (ui::win::IsAltGrPressed()) 370 if (ui::win::IsAltGrPressed())
369 modifiers |= EF_ALTGR_DOWN; 371 modifiers |= EF_ALTGR_DOWN;
370 if (ui::win::IsWindowsKeyPressed()) 372 if (ui::win::IsNumLockOn())
371 modifiers |= EF_COMMAND_DOWN; 373 modifiers |= EF_NUM_LOCK_ON;
372 if (ui::win::IsCapsLockOn()) 374 if (ui::win::IsCapsLockOn())
373 modifiers |= EF_CAPS_LOCK_DOWN; 375 modifiers |= EF_CAPS_LOCK_ON;
374 if (ui::win::IsNumLockOn())
375 modifiers |= EF_NUM_LOCK_DOWN;
376 if (ui::win::IsScrollLockOn()) 376 if (ui::win::IsScrollLockOn())
377 modifiers |= EF_SCROLL_LOCK_DOWN; 377 modifiers |= EF_SCROLL_LOCK_ON;
378 return modifiers; 378 return modifiers;
379 } 379 }
380 380
381 // Windows emulates mouse messages for touch events. 381 // Windows emulates mouse messages for touch events.
382 bool IsMouseEventFromTouch(UINT message) { 382 bool IsMouseEventFromTouch(UINT message) {
383 return (message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST) && 383 return (message >= WM_MOUSEFIRST) && (message <= WM_MOUSELAST) &&
384 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == 384 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
385 MOUSEEVENTF_FROMTOUCH; 385 MOUSEEVENTF_FROMTOUCH;
386 } 386 }
387 387
(...skipping 15 matching lines...) Expand all
403 } 403 }
404 404
405 LPARAM GetLParamFromScanCode(uint16_t scan_code) { 405 LPARAM GetLParamFromScanCode(uint16_t scan_code) {
406 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; 406 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16;
407 if ((scan_code & 0xE000) == 0xE000) 407 if ((scan_code & 0xE000) == 0xE000)
408 l_param |= (1 << 24); 408 l_param |= (1 << 24);
409 return l_param; 409 return l_param;
410 } 410 }
411 411
412 } // namespace ui 412 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/test/events_test_utils_x11.cc ('k') | ui/events/x/events_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698