Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <Carbon/Carbon.h> | |
| 6 | |
| 5 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" | 7 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" |
| 6 | 8 |
| 7 #include <string> | 9 #include <string> |
| 8 | 10 |
| 9 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. | 11 #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. |
| 10 #import "chrome/browser/cocoa/focus_tracker.h" | 12 #import "chrome/browser/cocoa/focus_tracker.h" |
| 11 #import "chrome/browser/cocoa/chrome_browser_window.h" | 13 #import "chrome/browser/cocoa/chrome_browser_window.h" |
| 12 #import "chrome/browser/cocoa/browser_window_controller.h" | 14 #import "chrome/browser/cocoa/browser_window_controller.h" |
| 13 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 15 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 14 #include "chrome/browser/cocoa/sad_tab_view.h" | 16 #include "chrome/browser/cocoa/sad_tab_view.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 [sad_tab_.get() removeFromSuperview]; | 254 [sad_tab_.get() removeFromSuperview]; |
| 253 sad_tab_.reset(); | 255 sad_tab_.reset(); |
| 254 } | 256 } |
| 255 break; | 257 break; |
| 256 } | 258 } |
| 257 default: | 259 default: |
| 258 NOTREACHED() << "Got a notification we didn't register for."; | 260 NOTREACHED() << "Got a notification we didn't register for."; |
| 259 } | 261 } |
| 260 } | 262 } |
| 261 | 263 |
| 264 @interface NSApplication(SPI) | |
| 265 - (void)_cycleWindowsReversed:(BOOL)reversed; | |
|
James Su
2009/10/15 08:00:49
Is it ok for us to depend on a private method? It
Nico
2009/10/15 15:40:00
I think it's ok for often-used stuff as long as we
| |
| 266 @end | |
| 267 | |
| 262 @implementation TabContentsViewCocoa | 268 @implementation TabContentsViewCocoa |
| 263 | 269 |
| 264 - (id)initWithTabContentsViewMac:(TabContentsViewMac*)w { | 270 - (id)initWithTabContentsViewMac:(TabContentsViewMac*)w { |
| 265 self = [super initWithFrame:NSZeroRect]; | 271 self = [super initWithFrame:NSZeroRect]; |
| 266 if (self != nil) { | 272 if (self != nil) { |
| 267 tabContentsView_ = w; | 273 tabContentsView_ = w; |
| 268 dropTarget_.reset( | 274 dropTarget_.reset( |
| 269 [[WebDropTarget alloc] initWithTabContents:[self tabContents]]); | 275 [[WebDropTarget alloc] initWithTabContents:[self tabContents]]); |
| 270 [self registerDragTypes]; | 276 [self registerDragTypes]; |
| 271 } | 277 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 296 | 302 |
| 297 - (void)processKeyboardEvent:(NativeWebKeyboardEvent*)wkEvent { | 303 - (void)processKeyboardEvent:(NativeWebKeyboardEvent*)wkEvent { |
| 298 NSEvent* event = wkEvent->os_event; | 304 NSEvent* event = wkEvent->os_event; |
| 299 | 305 |
| 300 if ([event type] == NSKeyDown && ([event modifierFlags] & NSCommandKeyMask)) { | 306 if ([event type] == NSKeyDown && ([event modifierFlags] & NSCommandKeyMask)) { |
| 301 // We need to dispatch this to the menu. | 307 // We need to dispatch this to the menu. |
| 302 if ([[NSApp mainMenu] performKeyEquivalent:event]) | 308 if ([[NSApp mainMenu] performKeyEquivalent:event]) |
| 303 return; | 309 return; |
| 304 } | 310 } |
| 305 | 311 |
| 312 // Cmd-` is not in the menu and it's apparently handled by |NSApp sendEvent| | |
| 313 // if the application doesn't swallow it. We do, so we need to handle this | |
| 314 // key ourself. On foreign keyboards, the "switch windows" key is not the | |
| 315 // ` key, so do this by keycode instead of |event characters|. | |
|
James Su
2009/10/15 08:00:49
Is Cmd-` the only key handled by |NSApp sendEvent|
Nico
2009/10/15 15:40:00
Experimental evidence suggests that it really is t
| |
| 316 if ([event type] == NSKeyDown && | |
| 317 [event keyCode] == kVK_ANSI_Grave && | |
| 318 [NSApp respondsToSelector:@selector(_cycleWindowsReversed:)]) { | |
| 319 const NSUInteger kModifierMask = NSShiftKeyMask | | |
| 320 NSControlKeyMask | | |
| 321 NSAlternateKeyMask | | |
| 322 NSCommandKeyMask; | |
| 323 if (([event modifierFlags] & kModifierMask) == NSCommandKeyMask) | |
| 324 [NSApp _cycleWindowsReversed:NO]; | |
| 325 else if (([event modifierFlags] & kModifierMask) == | |
| 326 (NSCommandKeyMask | NSShiftKeyMask) && | |
| 327 [NSApp respondsToSelector:@selector(_cycleWindowsReversed:)]) | |
| 328 [NSApp _cycleWindowsReversed:YES]; | |
| 329 } | |
| 330 | |
| 306 // If this tab is no longer active, it's window will be |nil|. In that case, | 331 // If this tab is no longer active, it's window will be |nil|. In that case, |
| 307 // best ignore the event. | 332 // best ignore the event. |
| 308 if (![self window]) | 333 if (![self window]) |
| 309 return; | 334 return; |
| 310 | 335 |
| 311 // Do not fire shortcuts on key up. | 336 // Do not fire shortcuts on key up. |
| 312 if ([event type] == NSKeyDown) { | 337 if ([event type] == NSKeyDown) { |
| 313 ChromeBrowserWindow* window = (ChromeBrowserWindow*)[self window]; | 338 ChromeBrowserWindow* window = (ChromeBrowserWindow*)[self window]; |
| 314 DCHECK([window isKindOfClass:[ChromeBrowserWindow class]]); | 339 DCHECK([window isKindOfClass:[ChromeBrowserWindow class]]); |
| 315 if ([window handleExtraBrowserKeyboardShortcut:event]) | 340 if ([window handleExtraBrowserKeyboardShortcut:event]) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 } | 454 } |
| 430 | 455 |
| 431 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { | 456 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { |
| 432 return [dropTarget_ performDragOperation:sender view:self]; | 457 return [dropTarget_ performDragOperation:sender view:self]; |
| 433 } | 458 } |
| 434 | 459 |
| 435 // Tons of stuff goes here, where we grab events going on in Cocoaland and send | 460 // Tons of stuff goes here, where we grab events going on in Cocoaland and send |
| 436 // them into the C++ system. TODO(avi): all that jazz | 461 // them into the C++ system. TODO(avi): all that jazz |
| 437 | 462 |
| 438 @end | 463 @end |
| OLD | NEW |