From 69bda9427a7d71260f773bfb79b3810e71d582fe Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Tue, 12 Mar 2013 15:00:26 -0400 Subject: [PATCH] Fixed: some window subclasses should not be constrained to the usable screen content Previously, all window subclasses were constrained to the usable screen content. Unfortunately that included the menu bar window, which ended up appearing below itself! This commit introduces an ivar that indicates whether instances of the window subclass should be constrained or not. --- AppKit/CPMenu/_CPMenuBarWindow.j | 2 ++ AppKit/CPMenu/_CPMenuWindow.j | 2 ++ AppKit/CPWindow/CPWindow.j | 5 +++++ AppKit/_CPAutocompleteMenu.j | 8 ++++++++ AppKit/_CPPopUpList.j | 8 ++++++++ AppKit/_CPToolTip.j | 2 ++ 6 files changed, 27 insertions(+) diff --git a/AppKit/CPMenu/_CPMenuBarWindow.j b/AppKit/CPMenu/_CPMenuBarWindow.j index 60cc01b72..bd6c781fe 100644 --- a/AppKit/CPMenu/_CPMenuBarWindow.j +++ b/AppKit/CPMenu/_CPMenuBarWindow.j @@ -67,6 +67,8 @@ if (self) { + _constrainsToUsableScreen = NO; + [self setLevel:CPMainMenuWindowLevel]; [self setAutoresizingMask:CPWindowWidthSizable]; diff --git a/AppKit/CPMenu/_CPMenuWindow.j b/AppKit/CPMenu/_CPMenuWindow.j index ddd697051..3b5fad84f 100644 --- a/AppKit/CPMenu/_CPMenuWindow.j +++ b/AppKit/CPMenu/_CPMenuWindow.j @@ -87,6 +87,8 @@ _CPMenuWindowAttachedMenuBackgroundStyle = 2; if (self) { + _constrainsToUsableScreen = NO; + [self setLevel:CPPopUpMenuWindowLevel]; [self setHasShadow:YES]; [self setShadowStyle:CPMenuWindowShadowStyle]; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index c3f0572b5..2980d8958 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -144,6 +144,7 @@ var CPWindowActionMessageKeys = [ BOOL _hasShadow; BOOL _isMovableByWindowBackground; BOOL _isMovable; + BOOL _constrainsToUsableScreen; unsigned _shadowStyle; BOOL _showsResizeIndicator; @@ -253,6 +254,7 @@ CPTexturedBackgroundWindowMask var windowViewClass = [[self class] _windowViewClassForStyleMask:aStyleMask]; _frame = [windowViewClass frameRectForContentRect:aContentRect]; + _constrainsToUsableScreen = YES; [self _setSharesChromeWithPlatformWindow:![CPPlatform isBrowser]]; @@ -729,6 +731,9 @@ CPTexturedBackgroundWindowMask - (CGRect)_pinFrame:(CGRect)aFrame toUsableScreenWidth:(BOOL)pinWidth andHeight:(BOOL)pinHeight { + if (!_constrainsToUsableScreen) + return CGRectMakeCopy(aFrame); + var usableRect = [_platformWindow usableContentFrame], frame = _CGRectMakeCopy(aFrame); diff --git a/AppKit/_CPAutocompleteMenu.j b/AppKit/_CPAutocompleteMenu.j index ed9b4a8bc..165d34c79 100644 --- a/AppKit/_CPAutocompleteMenu.j +++ b/AppKit/_CPAutocompleteMenu.j @@ -270,6 +270,14 @@ var _CPAutocompleteMenuMaximumHeight = 307; @implementation _CPAutocompleteWindow : CPPanel +- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask +{ + if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask]) + _constrainsToUsableScreen = NO; + + return self; +} + - (BOOL)becomesKeyOnlyIfNeeded { return YES; diff --git a/AppKit/_CPPopUpList.j b/AppKit/_CPPopUpList.j index 024bc291a..2dfbce85e 100644 --- a/AppKit/_CPPopUpList.j +++ b/AppKit/_CPPopUpList.j @@ -852,6 +852,14 @@ var _CPPopUpListDataSourceKey = @"_CPPopUpListDataSourceKey", @implementation _CPPopUpPanel : CPPanel +- (id)initWithContentRect:(CGRect)aContentRect styleMask:(unsigned int)aStyleMask +{ + if (self = [super initWithContentRect:aContentRect styleMask:aStyleMask]) + _constrainsToUsableScreen = NO; + + return self; +} + - (void)sendEvent:(CPEvent)anEvent { var type = [anEvent type]; diff --git a/AppKit/_CPToolTip.j b/AppKit/_CPToolTip.j index 4f271cc0e..a669d4cf0 100644 --- a/AppKit/_CPToolTip.j +++ b/AppKit/_CPToolTip.j @@ -167,6 +167,8 @@ var _CPToolTipHeight = 24.0, if (self = [super initWithContentRect:toolTipFrame styleMask:aStyleMask]) { + _constrainsToUsableScreen = NO; + textFrameSize.height += 4; _content = [CPTextField labelWithTitle:aString];