OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ | 5 #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ |
6 #define CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ | 6 #define CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ |
7 | 7 |
8 #include <Carbon/Carbon.h> // For unichar. | 8 #include <Carbon/Carbon.h> // For unichar. |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, | 58 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, |
59 int vkey_code, unichar key_char); | 59 int vkey_code, unichar key_char); |
60 | 60 |
61 // This returns shortcuts that should work only if the tab contents have focus | 61 // This returns shortcuts that should work only if the tab contents have focus |
62 // (e.g. cmd-left, which shouldn't do history navigation if e.g. the omnibox has | 62 // (e.g. cmd-left, which shouldn't do history navigation if e.g. the omnibox has |
63 // focus). | 63 // focus). |
64 int CommandForBrowserKeyboardShortcut( | 64 int CommandForBrowserKeyboardShortcut( |
65 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, | 65 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, |
66 int vkey_code, unichar key_char); | 66 int vkey_code, unichar key_char); |
67 | 67 |
| 68 // This returns shortcuts that should work no matter what component of the |
| 69 // browser is focused. They are executed by the window, after any view has the |
| 70 // opportunity to override the shortcut. |
| 71 // Only handles shortcuts that are impossible to migrate to accelerator_table.cc |
| 72 // (crbug.com/25946). |
| 73 int CommandForMacViewsKeyboardShortcut( |
| 74 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, |
| 75 int vkey_code, unichar key_char); |
| 76 |
68 // Returns the Chrome command associated with |event|, or -1 if not found. | 77 // Returns the Chrome command associated with |event|, or -1 if not found. |
| 78 // Internally consults WindowKeyboardShortcutTable and |
| 79 // BrowserKeyboardShortcutTable, which are not appropriate for MacViews. |
69 int CommandForKeyEvent(NSEvent* event); | 80 int CommandForKeyEvent(NSEvent* event); |
70 | 81 |
| 82 // Returns the Chrome command associated with |event|, or -1 if not found. |
| 83 // Only appropriate for use on MacViews. |
| 84 int CommandForKeyEventOnMacViews(NSEvent* event); |
| 85 |
71 // Returns a keyboard event character for the given |event|. In most cases | 86 // Returns a keyboard event character for the given |event|. In most cases |
72 // this returns the first character of [NSEvent charactersIgnoringModifiers], | 87 // this returns the first character of [NSEvent charactersIgnoringModifiers], |
73 // but when [NSEvent character] has different printable ascii character | 88 // but when [NSEvent character] has different printable ascii character |
74 // we may return the first character of [NSEvent characters] instead. | 89 // we may return the first character of [NSEvent characters] instead. |
75 // (E.g. for dvorak-qwerty layout we want [NSEvent characters] rather than | 90 // (E.g. for dvorak-qwerty layout we want [NSEvent characters] rather than |
76 // [charactersIgnoringModifiers] for command keys. Similarly, on german | 91 // [charactersIgnoringModifiers] for command keys. Similarly, on german |
77 // layout we want '{' character rather than '8' for opt-8.) | 92 // layout we want '{' character rather than '8' for opt-8.) |
78 unichar KeyCharacterForEvent(NSEvent* event); | 93 unichar KeyCharacterForEvent(NSEvent* event); |
79 | 94 |
80 // For testing purposes. | 95 // For testing purposes. |
81 const KeyboardShortcutData* GetWindowKeyboardShortcutTable(size_t* num_entries); | 96 const KeyboardShortcutData* GetWindowKeyboardShortcutTable(size_t* num_entries); |
82 const KeyboardShortcutData* | 97 const KeyboardShortcutData* |
83 GetDelayedWindowKeyboardShortcutTable(size_t* num_entries); | 98 GetDelayedWindowKeyboardShortcutTable(size_t* num_entries); |
84 const KeyboardShortcutData* | 99 const KeyboardShortcutData* GetBrowserKeyboardShortcutTable( |
85 GetBrowserKeyboardShortcutTable(size_t* num_entries); | 100 size_t* num_entries); |
| 101 const KeyboardShortcutData* GetMacViewsKeyboardShortcutTable( |
| 102 size_t* num_entries); |
86 | 103 |
87 #endif // #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ | 104 #endif // #ifndef CHROME_BROWSER_GLOBAL_KEYBOARD_SHORTCUTS_MAC_H_ |
OLD | NEW |