OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/global_keyboard_shortcuts_mac.h" | 5 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // only if the tab contents is focused (BrowserKeyboardShortcut), and ones that | 39 // only if the tab contents is focused (BrowserKeyboardShortcut), and ones that |
40 // should work in all other cases (WindowKeyboardShortcut). In the latter case, | 40 // should work in all other cases (WindowKeyboardShortcut). In the latter case, |
41 // we differentiate between shortcuts that are checked before any other view | 41 // we differentiate between shortcuts that are checked before any other view |
42 // gets the chance to handle them (WindowKeyboardShortcut) or after all views | 42 // gets the chance to handle them (WindowKeyboardShortcut) or after all views |
43 // had a chance but did not handle the keypress event | 43 // had a chance but did not handle the keypress event |
44 // (DelayedWindowKeyboardShortcut). | 44 // (DelayedWindowKeyboardShortcut). |
45 | 45 |
46 const KeyboardShortcutData* GetWindowKeyboardShortcutTable( | 46 const KeyboardShortcutData* GetWindowKeyboardShortcutTable( |
47 size_t* num_entries) { | 47 size_t* num_entries) { |
48 static const KeyboardShortcutData keyboard_shortcuts[] = { | 48 static const KeyboardShortcutData keyboard_shortcuts[] = { |
49 //cmd shift cntrl option | 49 // cmd shift cntrl option |
50 //--- ----- ----- ------ | 50 // --- ----- ----- ------ |
51 // '{' / '}' characters should be matched earlier than virtual key code | 51 // '{' / '}' characters should be matched earlier than virtual key code |
52 // (therefore we can match alt-8 as '{' on german keyboards). | 52 // (therefore we can match alt-8 as '{' on german keyboards). |
53 {true, false, false, false, 0, '}', IDC_SELECT_NEXT_TAB}, | 53 {true, false, false, false, 0, '}', IDC_SELECT_NEXT_TAB}, |
54 {true, false, false, false, 0, '{', IDC_SELECT_PREVIOUS_TAB}, | 54 {true, false, false, false, 0, '{', IDC_SELECT_PREVIOUS_TAB}, |
55 {false, false, true, false, kVK_PageDown, 0, IDC_SELECT_NEXT_TAB}, | 55 {false, false, true, false, kVK_PageDown, 0, IDC_SELECT_NEXT_TAB}, |
56 {false, false, true, false, kVK_Tab, 0, IDC_SELECT_NEXT_TAB}, | 56 {false, false, true, false, kVK_Tab, 0, IDC_SELECT_NEXT_TAB}, |
57 {false, false, true, false, kVK_PageUp, 0, IDC_SELECT_PREVIOUS_TAB}, | 57 {false, false, true, false, kVK_PageUp, 0, IDC_SELECT_PREVIOUS_TAB}, |
58 {false, true, true, false, kVK_Tab, 0, IDC_SELECT_PREVIOUS_TAB}, | 58 {false, true, true, false, kVK_Tab, 0, IDC_SELECT_PREVIOUS_TAB}, |
59 // Cmd-0..8 select the Nth tab, with cmd-9 being "last tab". | 59 // Cmd-0..8 select the Nth tab, with cmd-9 being "last tab". |
60 {true, false, false, false, kVK_ANSI_1, 0, IDC_SELECT_TAB_0}, | 60 {true, false, false, false, kVK_ANSI_1, 0, IDC_SELECT_TAB_0}, |
61 {true, false, false, false, kVK_ANSI_Keypad1, 0, IDC_SELECT_TAB_0}, | 61 {true, false, false, false, kVK_ANSI_Keypad1, 0, IDC_SELECT_TAB_0}, |
62 {true, false, false, false, kVK_ANSI_2, 0, IDC_SELECT_TAB_1}, | 62 {true, false, false, false, kVK_ANSI_2, 0, IDC_SELECT_TAB_1}, |
63 {true, false, false, false, kVK_ANSI_Keypad2, 0, IDC_SELECT_TAB_1}, | 63 {true, false, false, false, kVK_ANSI_Keypad2, 0, IDC_SELECT_TAB_1}, |
64 {true, false, false, false, kVK_ANSI_3, 0, IDC_SELECT_TAB_2}, | 64 {true, false, false, false, kVK_ANSI_3, 0, IDC_SELECT_TAB_2}, |
65 {true, false, false, false, kVK_ANSI_Keypad3, 0, IDC_SELECT_TAB_2}, | 65 {true, false, false, false, kVK_ANSI_Keypad3, 0, IDC_SELECT_TAB_2}, |
66 {true, false, false, false, kVK_ANSI_4, 0, IDC_SELECT_TAB_3}, | 66 {true, false, false, false, kVK_ANSI_4, 0, IDC_SELECT_TAB_3}, |
67 {true, false, false, false, kVK_ANSI_Keypad4, 0, IDC_SELECT_TAB_3}, | 67 {true, false, false, false, kVK_ANSI_Keypad4, 0, IDC_SELECT_TAB_3}, |
68 {true, false, false, false, kVK_ANSI_5, 0, IDC_SELECT_TAB_4}, | 68 {true, false, false, false, kVK_ANSI_5, 0, IDC_SELECT_TAB_4}, |
69 {true, false, false, false, kVK_ANSI_Keypad5, 0, IDC_SELECT_TAB_4}, | 69 {true, false, false, false, kVK_ANSI_Keypad5, 0, IDC_SELECT_TAB_4}, |
70 {true, false, false, false, kVK_ANSI_6, 0, IDC_SELECT_TAB_5}, | 70 {true, false, false, false, kVK_ANSI_6, 0, IDC_SELECT_TAB_5}, |
71 {true, false, false, false, kVK_ANSI_Keypad6, 0, IDC_SELECT_TAB_5}, | 71 {true, false, false, false, kVK_ANSI_Keypad6, 0, IDC_SELECT_TAB_5}, |
72 {true, false, false, false, kVK_ANSI_7, 0, IDC_SELECT_TAB_6}, | 72 {true, false, false, false, kVK_ANSI_7, 0, IDC_SELECT_TAB_6}, |
73 {true, false, false, false, kVK_ANSI_Keypad7, 0, IDC_SELECT_TAB_6}, | 73 {true, false, false, false, kVK_ANSI_Keypad7, 0, IDC_SELECT_TAB_6}, |
74 {true, false, false, false, kVK_ANSI_8, 0, IDC_SELECT_TAB_7}, | 74 {true, false, false, false, kVK_ANSI_8, 0, IDC_SELECT_TAB_7}, |
75 {true, false, false, false, kVK_ANSI_Keypad8, 0, IDC_SELECT_TAB_7}, | 75 {true, false, false, false, kVK_ANSI_Keypad8, 0, IDC_SELECT_TAB_7}, |
76 {true, false, false, false, kVK_ANSI_9, 0, IDC_SELECT_LAST_TAB}, | 76 {true, false, false, false, kVK_ANSI_9, 0, IDC_SELECT_LAST_TAB}, |
77 {true, false, false, false, kVK_ANSI_Keypad9, 0, IDC_SELECT_LAST_TAB}, | 77 {true, false, false, false, kVK_ANSI_Keypad9, 0, IDC_SELECT_LAST_TAB}, |
78 {true, true, false, false, kVK_ANSI_M, 0, IDC_SHOW_AVATAR_MENU}, | 78 {true, true, false, false, kVK_ANSI_M, 0, IDC_SHOW_AVATAR_MENU}, |
| 79 {true, false, false, true, 0, 'l', IDC_SHOW_DOWNLOADS}, |
79 }; | 80 }; |
80 | 81 |
81 *num_entries = arraysize(keyboard_shortcuts); | 82 *num_entries = arraysize(keyboard_shortcuts); |
82 | 83 |
83 return keyboard_shortcuts; | 84 return keyboard_shortcuts; |
84 } | 85 } |
85 | 86 |
86 const KeyboardShortcutData* GetDelayedWindowKeyboardShortcutTable( | 87 const KeyboardShortcutData* GetDelayedWindowKeyboardShortcutTable( |
87 size_t* num_entries) { | 88 size_t* num_entries) { |
88 static const KeyboardShortcutData keyboard_shortcuts[] = { | 89 static const KeyboardShortcutData keyboard_shortcuts[] = { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 291 } |
291 } | 292 } |
292 | 293 |
293 // opt/alt modifier is set (e.g. on german layout we want '{' for opt-8). | 294 // opt/alt modifier is set (e.g. on german layout we want '{' for opt-8). |
294 if ([event modifierFlags] & NSAlternateKeyMask) | 295 if ([event modifierFlags] & NSAlternateKeyMask) |
295 return rawChar; | 296 return rawChar; |
296 } | 297 } |
297 | 298 |
298 return noModifiersChar; | 299 return noModifiersChar; |
299 } | 300 } |
OLD | NEW |