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 #include "app/l10n_util_mac.h" | 5 #include "app/l10n_util_mac.h" |
6 #include "base/gfx/rect.h" | 6 #include "base/gfx/rect.h" |
7 #include "base/keyboard_codes.h" | 7 #include "base/keyboard_codes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 if (item && [item action] == @selector(terminate:)) | 445 if (item && [item action] == @selector(terminate:)) |
446 return IDC_EXIT; | 446 return IDC_EXIT; |
447 | 447 |
448 // Look in secondary keyboard shortcuts. | 448 // Look in secondary keyboard shortcuts. |
449 NSUInteger modifiers = [event.os_event modifierFlags]; | 449 NSUInteger modifiers = [event.os_event modifierFlags]; |
450 const bool cmdKey = (modifiers & NSCommandKeyMask) != 0; | 450 const bool cmdKey = (modifiers & NSCommandKeyMask) != 0; |
451 const bool shiftKey = (modifiers & NSShiftKeyMask) != 0; | 451 const bool shiftKey = (modifiers & NSShiftKeyMask) != 0; |
452 const bool cntrlKey = (modifiers & NSControlKeyMask) != 0; | 452 const bool cntrlKey = (modifiers & NSControlKeyMask) != 0; |
453 const bool optKey = (modifiers & NSAlternateKeyMask) != 0; | 453 const bool optKey = (modifiers & NSAlternateKeyMask) != 0; |
454 const int keyCode = [event.os_event keyCode]; | 454 const int keyCode = [event.os_event keyCode]; |
| 455 const unichar keyChar = KeyCharacterForEvent(event.os_event); |
455 | 456 |
456 int cmdNum = CommandForWindowKeyboardShortcut( | 457 int cmdNum = CommandForWindowKeyboardShortcut( |
457 cmdKey, shiftKey, cntrlKey, optKey, keyCode); | 458 cmdKey, shiftKey, cntrlKey, optKey, keyCode, keyChar); |
458 if (cmdNum != -1) | 459 if (cmdNum != -1) |
459 return cmdNum; | 460 return cmdNum; |
460 | 461 |
461 cmdNum = CommandForBrowserKeyboardShortcut( | 462 cmdNum = CommandForBrowserKeyboardShortcut( |
462 cmdKey, shiftKey, cntrlKey, optKey, keyCode); | 463 cmdKey, shiftKey, cntrlKey, optKey, keyCode, keyChar); |
463 if (cmdNum != -1) | 464 if (cmdNum != -1) |
464 return cmdNum; | 465 return cmdNum; |
465 | 466 |
466 return -1; | 467 return -1; |
467 } | 468 } |
468 | 469 |
469 bool BrowserWindowCocoa::HandleKeyboardEventInternal(NSEvent* event) { | 470 bool BrowserWindowCocoa::HandleKeyboardEventInternal(NSEvent* event) { |
470 ChromeEventProcessingWindow* event_window = | 471 ChromeEventProcessingWindow* event_window = |
471 static_cast<ChromeEventProcessingWindow*>(window_); | 472 static_cast<ChromeEventProcessingWindow*>(window_); |
472 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); | 473 DCHECK([event_window isKindOfClass:[ChromeEventProcessingWindow class]]); |
473 | 474 |
474 // Do not fire shortcuts on key up. | 475 // Do not fire shortcuts on key up. |
475 if ([event type] == NSKeyDown) { | 476 if ([event type] == NSKeyDown) { |
476 // Send the event to the menu before sending it to the browser/window | 477 // Send the event to the menu before sending it to the browser/window |
477 // shortcut handling, so that if a user configures cmd-left to mean | 478 // shortcut handling, so that if a user configures cmd-left to mean |
478 // "previous tab", it takes precedence over the built-in "history back" | 479 // "previous tab", it takes precedence over the built-in "history back" |
479 // binding. Other than that, the |redispatchEvent| call would take care of | 480 // binding. Other than that, the |redispatchEvent| call would take care of |
480 // invoking the original menu item shortcut as well. | 481 // invoking the original menu item shortcut as well. |
| 482 |
481 if ([[NSApp mainMenu] performKeyEquivalent:event]) | 483 if ([[NSApp mainMenu] performKeyEquivalent:event]) |
482 return true; | 484 return true; |
483 | 485 |
484 if ([event_window handleExtraBrowserKeyboardShortcut:event]) | 486 if ([event_window handleExtraBrowserKeyboardShortcut:event]) |
485 return true; | 487 return true; |
486 | 488 |
487 if ([event_window handleExtraWindowKeyboardShortcut:event]) | 489 if ([event_window handleExtraWindowKeyboardShortcut:event]) |
488 return true; | 490 return true; |
489 | 491 |
490 if ([event_window handleDelayedWindowKeyboardShortcut:event]) | 492 if ([event_window handleDelayedWindowKeyboardShortcut:event]) |
(...skipping 21 matching lines...) Expand all Loading... |
512 break; | 514 break; |
513 } | 515 } |
514 } | 516 } |
515 | 517 |
516 void BrowserWindowCocoa::DestroyBrowser() { | 518 void BrowserWindowCocoa::DestroyBrowser() { |
517 [controller_ destroyBrowser]; | 519 [controller_ destroyBrowser]; |
518 | 520 |
519 // at this point the controller is dead (autoreleased), so | 521 // at this point the controller is dead (autoreleased), so |
520 // make sure we don't try to reference it any more. | 522 // make sure we don't try to reference it any more. |
521 } | 523 } |
OLD | NEW |