| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/chrome_browser_window.h" | 5 #import "chrome/browser/ui/cocoa/chrome_browser_window.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
| 9 #import "chrome/browser/ui/cocoa/themed_window.h" | 9 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 10 #include "ui/base/theme_provider.h" | 10 #include "ui/base/theme_provider.h" |
| 11 | 11 |
| 12 @interface NSWindow (Private) |
| 13 - (BOOL)hasKeyAppearance; |
| 14 @end |
| 15 |
| 12 @implementation ChromeBrowserWindow | 16 @implementation ChromeBrowserWindow |
| 13 | 17 |
| 14 - (const ui::ThemeProvider*)themeProvider { | 18 - (const ui::ThemeProvider*)themeProvider { |
| 15 id delegate = [self delegate]; | 19 id delegate = [self delegate]; |
| 16 if (![delegate respondsToSelector:@selector(themeProvider)]) | 20 if (![delegate respondsToSelector:@selector(themeProvider)]) |
| 17 return NULL; | 21 return NULL; |
| 18 return [delegate themeProvider]; | 22 return [delegate themeProvider]; |
| 19 } | 23 } |
| 20 | 24 |
| 21 - (ThemedWindowStyle)themedWindowStyle { | 25 - (ThemedWindowStyle)themedWindowStyle { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 theColor = | 77 theColor = |
| 74 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace]; | 78 [theColor colorUsingColorSpaceName:NSCalibratedWhiteColorSpace]; |
| 75 if (theColor != nil) { | 79 if (theColor != nil) { |
| 76 return [theColor whiteComponent] >= 0.7; | 80 return [theColor whiteComponent] >= 0.7; |
| 77 } | 81 } |
| 78 } | 82 } |
| 79 | 83 |
| 80 return NO; | 84 return NO; |
| 81 } | 85 } |
| 82 | 86 |
| 87 - (BOOL)hasKeyAppearance { |
| 88 // If not key, but a non-main child window without its own traffic lights _is_ |
| 89 // key, then show this window with key appearance to keep the traffic lights |
| 90 // lit. This does not currently handle WebModal dialogs, since they are |
| 91 // children of an overlay window. But WebModals also temporarily lose key |
| 92 // status while animating closed, so extra logic is needed to avoid flicker. |
| 93 // Start with an early exit, since this is called for every mouseMove and |
| 94 // every cursor blink in an NSTextField. |
| 95 if (![self isKeyWindow]) { |
| 96 for (NSWindow* child in [self childWindows]) { |
| 97 if ([child isKeyWindow] && ![child isMainWindow] && |
| 98 ([child styleMask] & NSClosableWindowMask) == 0) |
| 99 return YES; |
| 100 } |
| 101 } |
| 102 return [super hasKeyAppearance]; |
| 103 } |
| 104 |
| 83 @end | 105 @end |
| OLD | NEW |