| 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" |
| 11 #include "base/win/win_util.h" |
| 11 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 12 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
| 12 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Get the native mouse key state from the native event message type. | 17 // Get the native mouse key state from the native event message type. |
| 17 int GetNativeMouseKey(const base::NativeEvent& native_event) { | 18 int GetNativeMouseKey(const base::NativeEvent& native_event) { |
| 18 switch (native_event.message) { | 19 switch (native_event.message) { |
| 19 case WM_LBUTTONDBLCLK: | 20 case WM_LBUTTONDBLCLK: |
| 20 case WM_LBUTTONDOWN: | 21 case WM_LBUTTONDOWN: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 native_event.message == WM_SYSKEYDOWN || | 78 native_event.message == WM_SYSKEYDOWN || |
| 78 native_event.message == WM_CHAR || | 79 native_event.message == WM_CHAR || |
| 79 native_event.message == WM_KEYUP || | 80 native_event.message == WM_KEYUP || |
| 80 native_event.message == WM_SYSKEYUP; | 81 native_event.message == WM_SYSKEYUP; |
| 81 } | 82 } |
| 82 | 83 |
| 83 // Returns a mask corresponding to the set of pressed modifier keys. | 84 // 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. | 85 // Checks the current global state and the state sent by client mouse messages. |
| 85 int KeyStateFlagsFromNative(const base::NativeEvent& native_event) { | 86 int KeyStateFlagsFromNative(const base::NativeEvent& native_event) { |
| 86 int flags = 0; | 87 int flags = 0; |
| 87 flags |= (GetKeyState(VK_MENU) & 0x80) ? ui::EF_ALT_DOWN : 0; | 88 flags |= base::win::IsAltPressed() ? ui::EF_ALT_DOWN : ui::EF_NONE; |
| 88 flags |= (GetKeyState(VK_SHIFT) & 0x80) ? ui::EF_SHIFT_DOWN : 0; | 89 flags |= base::win::IsShiftPressed() ? ui::EF_SHIFT_DOWN : ui::EF_NONE; |
| 89 flags |= (GetKeyState(VK_CONTROL) & 0x80) ? ui::EF_CONTROL_DOWN : 0; | 90 flags |= base::win::IsCtrlPressed() ? ui::EF_CONTROL_DOWN : ui::EF_NONE; |
| 90 | 91 |
| 91 // Check key messages for the extended key flag. | 92 // Check key messages for the extended key flag. |
| 92 if (IsKeyEvent(native_event)) | 93 if (IsKeyEvent(native_event)) |
| 93 flags |= (HIWORD(native_event.lParam) & KF_EXTENDED) ? ui::EF_EXTENDED : 0; | 94 flags |= (HIWORD(native_event.lParam) & KF_EXTENDED) ? ui::EF_EXTENDED : 0; |
| 94 | 95 |
| 95 // Most client mouse messages include key state information. | 96 // Most client mouse messages include key state information. |
| 96 if (IsClientMouseEvent(native_event)) { | 97 if (IsClientMouseEvent(native_event)) { |
| 97 int win_flags = GET_KEYSTATE_WPARAM(native_event.wParam); | 98 int win_flags = GET_KEYSTATE_WPARAM(native_event.wParam); |
| 98 flags |= (win_flags & MK_SHIFT) ? ui::EF_SHIFT_DOWN : 0; | 99 flags |= (win_flags & MK_SHIFT) ? ui::EF_SHIFT_DOWN : 0; |
| 99 flags |= (win_flags & MK_CONTROL) ? ui::EF_CONTROL_DOWN : 0; | 100 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) | 306 if (accel.fVirt & FSHIFT) |
| 306 modifiers |= ui::EF_SHIFT_DOWN; | 307 modifiers |= ui::EF_SHIFT_DOWN; |
| 307 if (accel.fVirt & FCONTROL) | 308 if (accel.fVirt & FCONTROL) |
| 308 modifiers |= ui::EF_CONTROL_DOWN; | 309 modifiers |= ui::EF_CONTROL_DOWN; |
| 309 if (accel.fVirt & FALT) | 310 if (accel.fVirt & FALT) |
| 310 modifiers |= ui::EF_ALT_DOWN; | 311 modifiers |= ui::EF_ALT_DOWN; |
| 311 return modifiers; | 312 return modifiers; |
| 312 } | 313 } |
| 313 | 314 |
| 314 } // namespace ui | 315 } // namespace ui |
| OLD | NEW |