OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 7 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
8 | 8 |
9 // Basically, there are two kinds of keyboard shortcuts: Ones that should work | 9 // Basically, there are two kinds of keyboard shortcuts: Ones that should work |
10 // only if the tab contents is focused (BrowserKeyboardShortcut), and ones that | 10 // only if the tab contents is focused (BrowserKeyboardShortcut), and ones that |
11 // should work in all other cases (WindowKeyboardShortcut). In the latter case, | 11 // should work in all other cases (WindowKeyboardShortcut). In the latter case, |
12 // we differentiate between shortcuts that are checked before any other view | 12 // we differentiate between shortcuts that are checked before any other view |
13 // gets the chance to handle them (WindowKeyboardShortcut) or after all views | 13 // gets the chance to handle them (WindowKeyboardShortcut) or after all views |
14 // had a chance but did not handle the keypress event | 14 // had a chance but did not handle the keypress event |
15 // (DelayedWindowKeyboardShortcut). | 15 // (DelayedWindowKeyboardShortcut). |
16 | 16 |
17 const std::vector<KeyboardShortcutData>& GetWindowKeyboardShortcutTable() { | 17 const std::vector<KeyboardShortcutData>& GetWindowKeyboardShortcutTable() { |
18 // clang-format off | 18 // clang-format off |
19 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({ | 19 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({ |
20 //cmd shift cntrl option vkeycode char command | 20 //cmd shift cntrl option vkeycode char command |
21 //--- ----- ----- ------ -------- ---- ------- | 21 //--- ----- ----- ------ -------- ---- ------- |
22 // '{' / '}' characters should be matched earlier than virtual key codes | 22 // '{' / '}' characters should be matched earlier than virtual key codes |
23 // (so we can match alt-8 as '{' on German keyboards). | 23 // (so we can match alt-8 as '{' on German keyboards). |
24 {true, false, false, false, 0, '}', IDC_SELECT_NEXT_TAB}, | 24 {true, false, false, false, 0, '}', IDC_SELECT_NEXT_TAB
}, |
25 {true, false, false, false, 0, '{', IDC_SELECT_PREVIOUS_TAB}, | 25 {true, false, false, false, 0, '{', IDC_SELECT_PREVIOUS
_TAB}, |
26 {false, false, true, false, kVK_PageDown, 0, IDC_SELECT_NEXT_TAB}, | 26 {true, true, false, false, kVK_ANSI_RightBracket, 0, IDC_SELECT_NEXT_TAB
}, |
27 {false, false, true, false, kVK_Tab, 0, IDC_SELECT_NEXT_TAB}, | 27 {true, true, false, false, kVK_ANSI_LeftBracket, 0, IDC_SELECT_PREVIOUS
_TAB}, |
28 {false, false, true, false, kVK_PageUp, 0, IDC_SELECT_PREVIOUS_TAB}, | 28 {false, false, true, false, kVK_PageDown, 0, IDC_SELECT_NEXT_TAB
}, |
29 {false, true, true, false, kVK_Tab, 0, IDC_SELECT_PREVIOUS_TAB}, | 29 {false, false, true, false, kVK_Tab, 0, IDC_SELECT_NEXT_TAB
}, |
| 30 {false, false, true, false, kVK_PageUp, 0, IDC_SELECT_PREVIOUS
_TAB}, |
| 31 {false, true, true, false, kVK_Tab, 0, IDC_SELECT_PREVIOUS
_TAB}, |
30 | 32 |
31 //cmd shift cntrl option vkeycode char command | 33 //cmd shift cntrl option vkeycode char command |
32 //--- ----- ----- ------ -------- ---- ------- | 34 //--- ----- ----- ------ -------- ---- ------- |
33 // Cmd-0..8 select the nth tab, with cmd-9 being "last tab". | 35 // Cmd-0..8 select the nth tab, with cmd-9 being "last tab". |
34 {true, false, false, false, kVK_ANSI_1, 0, IDC_SELECT_TAB_0}, | 36 {true, false, false, false, kVK_ANSI_1, 0, IDC_SELECT_TAB_0}, |
35 {true, false, false, false, kVK_ANSI_Keypad1, 0, IDC_SELECT_TAB_0}, | 37 {true, false, false, false, kVK_ANSI_Keypad1, 0, IDC_SELECT_TAB_0}, |
36 {true, false, false, false, kVK_ANSI_2, 0, IDC_SELECT_TAB_1}, | 38 {true, false, false, false, kVK_ANSI_2, 0, IDC_SELECT_TAB_1}, |
37 {true, false, false, false, kVK_ANSI_Keypad2, 0, IDC_SELECT_TAB_1}, | 39 {true, false, false, false, kVK_ANSI_Keypad2, 0, IDC_SELECT_TAB_1}, |
38 {true, false, false, false, kVK_ANSI_3, 0, IDC_SELECT_TAB_2}, | 40 {true, false, false, false, kVK_ANSI_3, 0, IDC_SELECT_TAB_2}, |
39 {true, false, false, false, kVK_ANSI_Keypad3, 0, IDC_SELECT_TAB_2}, | 41 {true, false, false, false, kVK_ANSI_Keypad3, 0, IDC_SELECT_TAB_2}, |
40 {true, false, false, false, kVK_ANSI_4, 0, IDC_SELECT_TAB_3}, | 42 {true, false, false, false, kVK_ANSI_4, 0, IDC_SELECT_TAB_3}, |
41 {true, false, false, false, kVK_ANSI_Keypad4, 0, IDC_SELECT_TAB_3}, | 43 {true, false, false, false, kVK_ANSI_Keypad4, 0, IDC_SELECT_TAB_3}, |
42 {true, false, false, false, kVK_ANSI_5, 0, IDC_SELECT_TAB_4}, | 44 {true, false, false, false, kVK_ANSI_5, 0, IDC_SELECT_TAB_4}, |
43 {true, false, false, false, kVK_ANSI_Keypad5, 0, IDC_SELECT_TAB_4}, | 45 {true, false, false, false, kVK_ANSI_Keypad5, 0, IDC_SELECT_TAB_4}, |
44 {true, false, false, false, kVK_ANSI_6, 0, IDC_SELECT_TAB_5}, | 46 {true, false, false, false, kVK_ANSI_6, 0, IDC_SELECT_TAB_5}, |
45 {true, false, false, false, kVK_ANSI_Keypad6, 0, IDC_SELECT_TAB_5}, | 47 {true, false, false, false, kVK_ANSI_Keypad6, 0, IDC_SELECT_TAB_5}, |
46 {true, false, false, false, kVK_ANSI_7, 0, IDC_SELECT_TAB_6}, | 48 {true, false, false, false, kVK_ANSI_7, 0, IDC_SELECT_TAB_6}, |
47 {true, false, false, false, kVK_ANSI_Keypad7, 0, IDC_SELECT_TAB_6}, | 49 {true, false, false, false, kVK_ANSI_Keypad7, 0, IDC_SELECT_TAB_6}, |
48 {true, false, false, false, kVK_ANSI_8, 0, IDC_SELECT_TAB_7}, | 50 {true, false, false, false, kVK_ANSI_8, 0, IDC_SELECT_TAB_7}, |
49 {true, false, false, false, kVK_ANSI_Keypad8, 0, IDC_SELECT_TAB_7}, | 51 {true, false, false, false, kVK_ANSI_Keypad8, 0, IDC_SELECT_TAB_7}, |
50 {true, false, false, false, kVK_ANSI_9, 0, IDC_SELECT_LAST_TAB}, | 52 {true, false, false, false, kVK_ANSI_9, 0, IDC_SELECT_LAST_TAB
}, |
51 {true, false, false, false, kVK_ANSI_Keypad9, 0, IDC_SELECT_LAST_TAB}, | 53 {true, false, false, false, kVK_ANSI_Keypad9, 0, IDC_SELECT_LAST_TAB
}, |
52 {true, true, false, false, kVK_ANSI_M, 0, IDC_SHOW_AVATAR_MENU}, | 54 {true, true, false, false, kVK_ANSI_M, 0, IDC_SHOW_AVATAR_MEN
U}, |
53 {true, false, false, true, kVK_ANSI_L, 0, IDC_SHOW_DOWNLOADS}, | 55 {true, false, false, true, kVK_ANSI_L, 0, IDC_SHOW_DOWNLOADS}
, |
54 })); | 56 })); |
55 // clang-format on | 57 // clang-format on |
56 return result; | 58 return result; |
57 } | 59 } |
58 | 60 |
59 const std::vector<KeyboardShortcutData>& | 61 const std::vector<KeyboardShortcutData>& |
60 GetDelayedWindowKeyboardShortcutTable() { | 62 GetDelayedWindowKeyboardShortcutTable() { |
61 // clang-format off | 63 // clang-format off |
62 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({ | 64 CR_DEFINE_STATIC_LOCAL(std::vector<KeyboardShortcutData>, result, ({ |
63 //cmd shift cntrl option vkeycode char command | 65 //cmd shift cntrl option vkeycode char command |
(...skipping 11 matching lines...) Expand all Loading... |
75 //--- ----- ----- ------ -------- ---- ------- | 77 //--- ----- ----- ------ -------- ---- ------- |
76 {true, false, false, false, kVK_LeftArrow, 0, IDC_BACK}, | 78 {true, false, false, false, kVK_LeftArrow, 0, IDC_BACK}, |
77 {true, false, false, false, kVK_RightArrow, 0, IDC_FORWARD}, | 79 {true, false, false, false, kVK_RightArrow, 0, IDC_FORWARD}, |
78 {false, false, false, false, kVK_Delete, 0, IDC_BACKSPACE_BACK}, | 80 {false, false, false, false, kVK_Delete, 0, IDC_BACKSPACE_BACK}, |
79 {false, true, false, false, kVK_Delete, 0, IDC_BACKSPACE_FORWARD}, | 81 {false, true, false, false, kVK_Delete, 0, IDC_BACKSPACE_FORWARD}, |
80 {true, true, false, false, 0, 'c', IDC_DEV_TOOLS_INSPECT}, | 82 {true, true, false, false, 0, 'c', IDC_DEV_TOOLS_INSPECT}, |
81 })); | 83 })); |
82 // clang-format on | 84 // clang-format on |
83 return result; | 85 return result; |
84 } | 86 } |
OLD | NEW |