Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/browser/cocoa/chrome_event_processing_window.mm

Issue 503080: Make cmd-{/} shortcut keys work on any keyboard layouts on Mac (Closed)
Patch Set: rename fix Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import "chrome/browser/cocoa/chrome_event_processing_window.h" 5 #import "chrome/browser/cocoa/chrome_event_processing_window.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/cocoa/browser_command_executor.h" 8 #import "chrome/browser/cocoa/browser_command_executor.h"
9 #import "chrome/browser/cocoa/browser_frame_view.h" 9 #import "chrome/browser/cocoa/browser_frame_view.h"
10 #import "chrome/browser/cocoa/tab_strip_controller.h" 10 #import "chrome/browser/cocoa/tab_strip_controller.h"
11 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" 11 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h"
12 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 12 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
13 13
14 typedef int (*KeyToCommandMapper)(bool, bool, bool, bool, int); 14 typedef int (*KeyToCommandMapper)(bool, bool, bool, bool, int, unichar);
15 15
16 @implementation ChromeEventProcessingWindow 16 @implementation ChromeEventProcessingWindow
17 17
18 - (BOOL)handleExtraKeyboardShortcut:(NSEvent*)event fromTable: 18 - (BOOL)handleExtraKeyboardShortcut:(NSEvent*)event fromTable:
19 (KeyToCommandMapper)commandForKeyboardShortcut { 19 (KeyToCommandMapper)commandForKeyboardShortcut {
20 // Extract info from |event|. 20 // Extract info from |event|.
21 NSUInteger modifers = [event modifierFlags]; 21 NSUInteger modifers = [event modifierFlags];
22 const bool cmdKey = modifers & NSCommandKeyMask; 22 const bool cmdKey = modifers & NSCommandKeyMask;
23 const bool shiftKey = modifers & NSShiftKeyMask; 23 const bool shiftKey = modifers & NSShiftKeyMask;
24 const bool cntrlKey = modifers & NSControlKeyMask; 24 const bool cntrlKey = modifers & NSControlKeyMask;
25 const bool optKey = modifers & NSAlternateKeyMask; 25 const bool optKey = modifers & NSAlternateKeyMask;
26 const int keyCode = [event keyCode]; 26 const unichar keyCode = [event keyCode];
27 const unichar keyChar = KeyCharacterForEvent(event);
27 28
28 int cmdNum = commandForKeyboardShortcut(cmdKey, shiftKey, cntrlKey, optKey, 29 int cmdNum = commandForKeyboardShortcut(cmdKey, shiftKey, cntrlKey, optKey,
29 keyCode); 30 keyCode, keyChar);
30 31
31 if (cmdNum != -1) { 32 if (cmdNum != -1) {
32 id executor = [self delegate]; 33 id executor = [self delegate];
33 // A bit of sanity. 34 // A bit of sanity.
34 DCHECK([executor conformsToProtocol:@protocol(BrowserCommandExecutor)]); 35 DCHECK([executor conformsToProtocol:@protocol(BrowserCommandExecutor)]);
35 DCHECK([executor respondsToSelector:@selector(executeCommand:)]); 36 DCHECK([executor respondsToSelector:@selector(executeCommand:)]);
36 [executor executeCommand:cmdNum]; 37 [executor executeCommand:cmdNum];
37 return YES; 38 return YES;
38 } 39 }
39 return NO; 40 return NO;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 95
95 - (void)sendEvent:(NSEvent*)event { 96 - (void)sendEvent:(NSEvent*)event {
96 if (!redispatchingEvent_) 97 if (!redispatchingEvent_)
97 [super sendEvent:event]; 98 [super sendEvent:event];
98 else 99 else
99 eventHandled_ = NO; 100 eventHandled_ = NO;
100 } 101 }
101 102
102 @end // ChromeEventProcessingWindow 103 @end // ChromeEventProcessingWindow
103 104
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/global_keyboard_shortcuts_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698