| 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 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" | 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 #endif // MAC_OS_X_VERSION_10_6 | 70 #endif // MAC_OS_X_VERSION_10_6 |
| 71 | 71 |
| 72 @interface PanelWindowControllerCocoa (PanelsCanBecomeKey) | 72 @interface PanelWindowControllerCocoa (PanelsCanBecomeKey) |
| 73 // Internal helper method for extracting the total number of panel windows | 73 // Internal helper method for extracting the total number of panel windows |
| 74 // from the panel manager. Used to decide if panel can become the key window. | 74 // from the panel manager. Used to decide if panel can become the key window. |
| 75 - (int)numPanels; | 75 - (int)numPanels; |
| 76 @end | 76 @end |
| 77 | 77 |
| 78 @interface PanelWindowCocoaImpl : ChromeBrowserWindow { | |
| 79 // Panel windows use a higher priority NSWindowLevel to ensure they are always | |
| 80 // visible, causing the OS to prefer panel windows when selecting a window | |
| 81 // to make the key window. To counter this preference, we override | |
| 82 // -[NSWindow:canBecomeKeyWindow] to restrict when the panel can become the | |
| 83 // key window to a limited set of scenarios, such as when cycling through | |
| 84 // windows, when panels are the only remaining windows, when an event | |
| 85 // triggers window activation, etc. The panel may also be prevented from | |
| 86 // becoming the key window, regardless of the above scenarios, such as when | |
| 87 // a panel is minimized. | |
| 88 BOOL canBecomeKey_; // Defaults to NO. | |
| 89 } | |
| 90 @end | |
| 91 | |
| 92 @implementation PanelWindowCocoaImpl | 78 @implementation PanelWindowCocoaImpl |
| 93 // The panels cannot be reduced to 3-px windows on the edge of the screen | 79 // The panels cannot be reduced to 3-px windows on the edge of the screen |
| 94 // active area (above Dock). Default constraining logic makes at least a height | 80 // active area (above Dock). Default constraining logic makes at least a height |
| 95 // of the titlebar visible, so the user could still grab it. We do 'restore' | 81 // of the titlebar visible, so the user could still grab it. We do 'restore' |
| 96 // differently, and minimize panels to 3 px. Hence the need to override the | 82 // differently, and minimize panels to 3 px. Hence the need to override the |
| 97 // constraining logic. | 83 // constraining logic. |
| 98 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen { | 84 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen { |
| 99 return frameRect; | 85 return frameRect; |
| 100 } | 86 } |
| 101 | 87 |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 if (![self isWindowLoaded]) | 1060 if (![self isWindowLoaded]) |
| 1075 return; | 1061 return; |
| 1076 [[self window] invalidateCursorRectsForView:overlayView_]; | 1062 [[self window] invalidateCursorRectsForView:overlayView_]; |
| 1077 } | 1063 } |
| 1078 | 1064 |
| 1079 - (BOOL)isActivationByClickingTitlebarEnabled { | 1065 - (BOOL)isActivationByClickingTitlebarEnabled { |
| 1080 return !windowShim_->panel()->always_on_top(); | 1066 return !windowShim_->panel()->always_on_top(); |
| 1081 } | 1067 } |
| 1082 | 1068 |
| 1083 @end | 1069 @end |
| OLD | NEW |