Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <windowsx.h> | 5 #include <windowsx.h> |
| 6 | 6 |
| 7 #include "ui/base/events.h" | 7 #include "ui/base/events.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 native_event.message == WM_SYSKEYDOWN || | 77 native_event.message == WM_SYSKEYDOWN || |
| 78 native_event.message == WM_CHAR || | 78 native_event.message == WM_CHAR || |
| 79 native_event.message == WM_KEYUP || | 79 native_event.message == WM_KEYUP || |
| 80 native_event.message == WM_SYSKEYUP; | 80 native_event.message == WM_SYSKEYUP; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Returns a mask corresponding to the set of pressed modifier keys. | 83 // Returns a mask corresponding to the set of pressed modifier keys. |
| 84 // Checks the current global state and the state sent by client mouse messages. | 84 // Checks the current global state and the state sent by client mouse messages. |
| 85 int KeyStateFlagsFromNative(const base::NativeEvent& native_event) { | 85 int KeyStateFlagsFromNative(const base::NativeEvent& native_event) { |
| 86 int flags = 0; | 86 int flags = 0; |
| 87 flags |= (GetKeyState(VK_MENU) & 0x80) ? ui::EF_ALT_DOWN : 0; | 87 flags |= base::win::IsAltPressed() ? ui::EF_ALT_DOWN : ui::EF_NONE; |
|
tfarina
2012/05/30 00:04:29
this code is duplicated with GetModifiersFromKeySt
| |
| 88 flags |= (GetKeyState(VK_SHIFT) & 0x80) ? ui::EF_SHIFT_DOWN : 0; | 88 flags |= base::win::IsShiftPressed() ? ui::EF_SHIFT_DOWN : ui::EF_NONE; |
| 89 flags |= (GetKeyState(VK_CONTROL) & 0x80) ? ui::EF_CONTROL_DOWN : 0; | 89 flags |= base::win::IsCtrlPressed() ? ui::EF_CONTROL_DOWN : ui::EF_NONE; |
| 90 | 90 |
| 91 // Check key messages for the extended key flag. | 91 // Check key messages for the extended key flag. |
| 92 if (IsKeyEvent(native_event)) | 92 if (IsKeyEvent(native_event)) |
| 93 flags |= (HIWORD(native_event.lParam) & KF_EXTENDED) ? ui::EF_EXTENDED : 0; | 93 flags |= (HIWORD(native_event.lParam) & KF_EXTENDED) ? ui::EF_EXTENDED : 0; |
| 94 | 94 |
| 95 // Most client mouse messages include key state information. | 95 // Most client mouse messages include key state information. |
| 96 if (IsClientMouseEvent(native_event)) { | 96 if (IsClientMouseEvent(native_event)) { |
| 97 int win_flags = GET_KEYSTATE_WPARAM(native_event.wParam); | 97 int win_flags = GET_KEYSTATE_WPARAM(native_event.wParam); |
| 98 flags |= (win_flags & MK_SHIFT) ? ui::EF_SHIFT_DOWN : 0; | 98 flags |= (win_flags & MK_SHIFT) ? ui::EF_SHIFT_DOWN : 0; |
| 99 flags |= (win_flags & MK_CONTROL) ? ui::EF_CONTROL_DOWN : 0; | 99 flags |= (win_flags & MK_CONTROL) ? ui::EF_CONTROL_DOWN : 0; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 if (accel.fVirt & FSHIFT) | 305 if (accel.fVirt & FSHIFT) |
| 306 modifiers |= ui::EF_SHIFT_DOWN; | 306 modifiers |= ui::EF_SHIFT_DOWN; |
| 307 if (accel.fVirt & FCONTROL) | 307 if (accel.fVirt & FCONTROL) |
| 308 modifiers |= ui::EF_CONTROL_DOWN; | 308 modifiers |= ui::EF_CONTROL_DOWN; |
| 309 if (accel.fVirt & FALT) | 309 if (accel.fVirt & FALT) |
| 310 modifiers |= ui::EF_ALT_DOWN; | 310 modifiers |= ui::EF_ALT_DOWN; |
| 311 return modifiers; | 311 return modifiers; |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace ui | 314 } // namespace ui |
| OLD | NEW |