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 #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_window_controller.h" | 8 #import "chrome/browser/cocoa/browser_window_controller.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, int); |
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; | |
26 const int keyCode = [event keyCode]; | 25 const int keyCode = [event keyCode]; |
27 | 26 |
28 int cmdNum = commandForKeyboardShortcut(cmdKey, shiftKey, cntrlKey, optKey, | 27 int cmdNum = commandForKeyboardShortcut(cmdKey, shiftKey, cntrlKey, |
29 keyCode); | 28 keyCode); |
30 | 29 |
31 BrowserWindowController* controller = | 30 BrowserWindowController* controller = |
32 (BrowserWindowController*)[self delegate]; | 31 (BrowserWindowController*)[self delegate]; |
33 // A bit of sanity. | 32 // A bit of sanity. |
34 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); | 33 DCHECK([controller isKindOfClass:[BrowserWindowController class]]); |
35 DCHECK([controller respondsToSelector:@selector(executeCommand:)]); | 34 DCHECK([controller respondsToSelector:@selector(executeCommand:)]); |
36 | 35 |
37 if (cmdNum != -1) { | 36 if (cmdNum != -1) { |
38 [controller executeCommand:cmdNum]; | 37 [controller executeCommand:cmdNum]; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 redispatchingEvent_ = NO; | 94 redispatchingEvent_ = NO; |
96 } | 95 } |
97 | 96 |
98 - (void)sendEvent:(NSEvent*)event { | 97 - (void)sendEvent:(NSEvent*)event { |
99 if (!redispatchingEvent_) | 98 if (!redispatchingEvent_) |
100 [super sendEvent:event]; | 99 [super sendEvent:event]; |
101 } | 100 } |
102 | 101 |
103 @end // ChromeEventProcessingWindow | 102 @end // ChromeEventProcessingWindow |
104 | 103 |
OLD | NEW |