| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 {true, false, false, true, kVK_ANSI_L, 0, IDC_SHOW_DOWNLOADS}, |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 *num_entries = arraysize(keyboard_shortcuts); | 82 *num_entries = arraysize(keyboard_shortcuts); |
| 83 | 83 |
| 84 return keyboard_shortcuts; | 84 return keyboard_shortcuts; |
| 85 } | 85 } |
| 86 | 86 |
| 87 const KeyboardShortcutData* GetDelayedWindowKeyboardShortcutTable( | 87 const KeyboardShortcutData* GetDelayedWindowKeyboardShortcutTable( |
| 88 size_t* num_entries) { | 88 size_t* num_entries) { |
| 89 static const KeyboardShortcutData keyboard_shortcuts[] = { | 89 static const KeyboardShortcutData keyboard_shortcuts[] = { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 114 return keyboard_shortcuts; | 114 return keyboard_shortcuts; |
| 115 } | 115 } |
| 116 | 116 |
| 117 static bool MatchesEventForKeyboardShortcut( | 117 static bool MatchesEventForKeyboardShortcut( |
| 118 const KeyboardShortcutData& shortcut, | 118 const KeyboardShortcutData& shortcut, |
| 119 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, | 119 bool command_key, bool shift_key, bool cntrl_key, bool opt_key, |
| 120 int vkey_code, unichar key_char) { | 120 int vkey_code, unichar key_char) { |
| 121 // Expects that one of |key_char| or |vkey_code| is 0. | 121 // Expects that one of |key_char| or |vkey_code| is 0. |
| 122 DCHECK((shortcut.key_char == 0) ^ (shortcut.vkey_code == 0)); | 122 DCHECK((shortcut.key_char == 0) ^ (shortcut.vkey_code == 0)); |
| 123 if (shortcut.key_char) { | 123 if (shortcut.key_char) { |
| 124 // Shortcuts that have a |key_char| and have |opt_key| set are mistakes, |
| 125 // since |opt_key| is not checked when there is a |key_char|. |
| 126 DCHECK(!shortcut.opt_key); |
| 124 // The given shortcut key is to be matched by a keyboard character. | 127 // The given shortcut key is to be matched by a keyboard character. |
| 125 // In this case we ignore shift and opt (alt) key modifiers, because | 128 // In this case we ignore shift and opt (alt) key modifiers, because |
| 126 // the character may be generated by a combination with those keys. | 129 // the character may be generated by a combination with those keys. |
| 127 if (shortcut.command_key == command_key && | 130 if (shortcut.command_key == command_key && |
| 128 shortcut.cntrl_key == cntrl_key && | 131 shortcut.cntrl_key == cntrl_key && |
| 129 shortcut.key_char == key_char) | 132 shortcut.key_char == key_char) |
| 130 return true; | 133 return true; |
| 131 } else if (shortcut.vkey_code) { | 134 } else if (shortcut.vkey_code) { |
| 132 // The given shortcut key is to be matched by a virtual key code. | 135 // The given shortcut key is to be matched by a virtual key code. |
| 133 if (shortcut.command_key == command_key && | 136 if (shortcut.command_key == command_key && |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 } | 294 } |
| 292 } | 295 } |
| 293 | 296 |
| 294 // opt/alt modifier is set (e.g. on german layout we want '{' for opt-8). | 297 // opt/alt modifier is set (e.g. on german layout we want '{' for opt-8). |
| 295 if ([event modifierFlags] & NSAlternateKeyMask) | 298 if ([event modifierFlags] & NSAlternateKeyMask) |
| 296 return rawChar; | 299 return rawChar; |
| 297 } | 300 } |
| 298 | 301 |
| 299 return noModifiersChar; | 302 return noModifiersChar; |
| 300 } | 303 } |
| OLD | NEW |