| 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 "ui/views/widget/native_widget_win.h" | 5 #include "ui/views/widget/native_widget_win.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be | 1568 // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be |
| 1569 // sent by the applicable button's ButtonListener. We _have_ to do this | 1569 // sent by the applicable button's ButtonListener. We _have_ to do this |
| 1570 // way rather than letting Windows just send the syscommand itself (as | 1570 // way rather than letting Windows just send the syscommand itself (as |
| 1571 // would happen if we never did this dance) because for some insane | 1571 // would happen if we never did this dance) because for some insane |
| 1572 // reason DefWindowProc for WM_NCLBUTTONDOWN also renders the pressed | 1572 // reason DefWindowProc for WM_NCLBUTTONDOWN also renders the pressed |
| 1573 // window control button appearance, in the Windows classic style, over | 1573 // window control button appearance, in the Windows classic style, over |
| 1574 // our view! Ick! By handling this message we prevent Windows from | 1574 // our view! Ick! By handling this message we prevent Windows from |
| 1575 // doing this undesirable thing, but that means we need to roll the | 1575 // doing this undesirable thing, but that means we need to roll the |
| 1576 // sys-command handling ourselves. | 1576 // sys-command handling ourselves. |
| 1577 // Combine |w_param| with common key state message flags. | 1577 // Combine |w_param| with common key state message flags. |
| 1578 w_param |= ((GetKeyState(VK_CONTROL) & 0x80) == 0x80)? MK_CONTROL : 0; | 1578 w_param |= base::win::IsCtrlPressed() ? MK_CONTROL : 0; |
| 1579 w_param |= ((GetKeyState(VK_SHIFT) & 0x80) == 0x80)? MK_SHIFT : 0; | 1579 w_param |= base::win::IsShiftPressed() ? MK_SHIFT : 0; |
| 1580 } | 1580 } |
| 1581 } | 1581 } |
| 1582 } else if (message == WM_NCRBUTTONDOWN && | 1582 } else if (message == WM_NCRBUTTONDOWN && |
| 1583 (w_param == HTCAPTION || w_param == HTSYSMENU)) { | 1583 (w_param == HTCAPTION || w_param == HTSYSMENU)) { |
| 1584 is_right_mouse_pressed_on_caption_ = true; | 1584 is_right_mouse_pressed_on_caption_ = true; |
| 1585 // We SetCapture() to ensure we only show the menu when the button | 1585 // We SetCapture() to ensure we only show the menu when the button |
| 1586 // down and up are both on the caption. Note: this causes the button up to | 1586 // down and up are both on the caption. Note: this causes the button up to |
| 1587 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP. | 1587 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP. |
| 1588 SetCapture(); | 1588 SetCapture(); |
| 1589 } | 1589 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 // resize or move modal loop to get continuous sizing/moving feedback. | 2028 // resize or move modal loop to get continuous sizing/moving feedback. |
| 2029 SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | WS_VISIBLE); | 2029 SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | WS_VISIBLE); |
| 2030 } | 2030 } |
| 2031 } | 2031 } |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 // Handle SC_KEYMENU, which means that the user has pressed the ALT | 2034 // Handle SC_KEYMENU, which means that the user has pressed the ALT |
| 2035 // key and released it, so we should focus the menu bar. | 2035 // key and released it, so we should focus the menu bar. |
| 2036 if ((notification_code & sc_mask) == SC_KEYMENU && click.x == 0) { | 2036 if ((notification_code & sc_mask) == SC_KEYMENU && click.x == 0) { |
| 2037 int modifiers = ui::EF_NONE; | 2037 int modifiers = ui::EF_NONE; |
| 2038 if (!!(GetKeyState(VK_SHIFT) & 0x8000)) | 2038 if (base::win::IsShiftPressed()) |
| 2039 modifiers |= ui::EF_SHIFT_DOWN; | 2039 modifiers |= ui::EF_SHIFT_DOWN; |
| 2040 if (!!(GetKeyState(VK_CONTROL) & 0x8000)) | 2040 if (base::win::IsCtrlPressed()) |
| 2041 modifiers |= ui::EF_CONTROL_DOWN; | 2041 modifiers |= ui::EF_CONTROL_DOWN; |
| 2042 // Retrieve the status of shift and control keys to prevent consuming | 2042 // Retrieve the status of shift and control keys to prevent consuming |
| 2043 // shift+alt keys, which are used by Windows to change input languages. | 2043 // shift+alt keys, which are used by Windows to change input languages. |
| 2044 ui::Accelerator accelerator(ui::KeyboardCodeForWindowsKeyCode(VK_MENU), | 2044 ui::Accelerator accelerator(ui::KeyboardCodeForWindowsKeyCode(VK_MENU), |
| 2045 modifiers); | 2045 modifiers); |
| 2046 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator); | 2046 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator); |
| 2047 return; | 2047 return; |
| 2048 } | 2048 } |
| 2049 | 2049 |
| 2050 // If the delegate can't handle it, the system implementation will be called. | 2050 // If the delegate can't handle it, the system implementation will be called. |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2719 return (GetKeyState(VK_LBUTTON) & 0x80) || | 2719 return (GetKeyState(VK_LBUTTON) & 0x80) || |
| 2720 (GetKeyState(VK_RBUTTON) & 0x80) || | 2720 (GetKeyState(VK_RBUTTON) & 0x80) || |
| 2721 (GetKeyState(VK_MBUTTON) & 0x80) || | 2721 (GetKeyState(VK_MBUTTON) & 0x80) || |
| 2722 (GetKeyState(VK_XBUTTON1) & 0x80) || | 2722 (GetKeyState(VK_XBUTTON1) & 0x80) || |
| 2723 (GetKeyState(VK_XBUTTON2) & 0x80); | 2723 (GetKeyState(VK_XBUTTON2) & 0x80); |
| 2724 } | 2724 } |
| 2725 | 2725 |
| 2726 } // namespace internal | 2726 } // namespace internal |
| 2727 | 2727 |
| 2728 } // namespace views | 2728 } // namespace views |
| OLD | NEW |