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