From 4a43e4fda6c47cec0fd951b2e2ede5373d7779c6 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Tue, 2 Mar 2010 15:16:10 -0800 Subject: [PATCH 01/12] Overhaul of the key/main window status, esp. with respect to assigning new values after a window closes or after a window is minimized, and with app activation/deactivation. --- AppKit/CPApplication.j | 138 +++++++++++++++++++++ AppKit/CPCursor.j | 2 - AppKit/CPWindow/CPWindow.j | 135 ++++++++++++++++---- AppKit/Platform/CPPlatform.j | 4 + AppKit/Platform/DOM/CPPlatform.j | 6 + AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 52 ++++---- 6 files changed, 287 insertions(+), 50 deletions(-) diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index f276ebd74..7e5b948f1 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -40,6 +40,10 @@ CPApp = nil; CPApplicationWillFinishLaunchingNotification = @"CPApplicationWillFinishLaunchingNotification"; CPApplicationDidFinishLaunchingNotification = @"CPApplicationDidFinishLaunchingNotification"; CPApplicationWillTerminateNotification = @"CPApplicationWillTerminateNotification"; +CPApplicationWillBecomeActiveNotification = @"CPApplicationWillBecomeActiveNotification"; +CPApplicationDidBecomeActiveNotification = @"CPApplicationDidBecomeActiveNotification"; +CPApplicationWillResignActiveNotification = @"CPApplicationWillResignActiveNotification"; +CPApplicationDidResignActiveNotification = @"CPApplicationDidResignActiveNotification"; CPTerminateNow = YES; CPTerminateCancel = NO; @@ -83,6 +87,8 @@ CPRunContinuesResponse = -1002; CPArray _windows; CPWindow _keyWindow; CPWindow _mainWindow; + CPWindow _previousKeyWindow; + CPWindow _previousMainWindow; CPMenu _mainMenu; CPDocumentController _documentController; @@ -92,6 +98,7 @@ CPRunContinuesResponse = -1002; // id _delegate; BOOL _finishedLaunching; + BOOL _isActive; CPDictionary _namedArgs; CPArray _args; @@ -219,6 +226,26 @@ CPRunContinuesResponse = -1002; removeObserver:_delegate name:CPApplicationDidFinishLaunchingNotification object:self]; + + [defaultCenter + removeObserver:_delegate + name:CPApplicationWillBecomeActiveNotification + object:self]; + + [defaultCenter + removeObserver:_delegate + name:CPApplicationDidBecomeActiveNotification + object:self]; + + [defaultCenter + removeObserver:_delegate + name:CPApplicationWillResignActiveNotification + object:self]; + + [defaultCenter + removeObserver:_delegate + name:CPApplicationDidResignActiveNotification + object:self]; } _delegate = aDelegate; @@ -236,6 +263,34 @@ CPRunContinuesResponse = -1002; selector:@selector(applicationDidFinishLaunching:) name:CPApplicationDidFinishLaunchingNotification object:self]; + + if ([_delegate respondsToSelector:@selector(applicationWillBecomeActive:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(applicationWillBecomeActive:) + name:CPApplicationWillBecomeActiveNotification + object:self]; + + if ([_delegate respondsToSelector:@selector(applicationDidBecomeActive:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(applicationDidBecomeActive:) + name:CPApplicationDidBecomeActiveNotification + object:self]; + + if ([_delegate respondsToSelector:@selector(applicationWillResignActive:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(applicationWillResignActive:) + name:CPApplicationWillResignActiveNotification + object:self]; + + if ([_delegate respondsToSelector:@selector(applicationDidResignActive:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(applicationDidResignActive:) + name:CPApplicationDidResignActiveNotification + object:self]; } /*! @@ -419,7 +474,27 @@ CPRunContinuesResponse = -1002; - (void)activateIgnoringOtherApps:(BOOL)shouldIgnoreOtherApps { + [self _willBecomeActive]; + [CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps]; + _isActive = YES; + + [self _willResignActive]; +} + +- (void)deactivate +{ + [self _willResignActive]; + + [CPPlatform deactivate]; + _isActive = NO; + + [self _didResignActive]; +} + +- (void)isActive +{ + return _isActive; } - (void)hideOtherApplications:(id)aSender @@ -624,6 +699,14 @@ CPRunContinuesResponse = -1002; return _windows; } +/*! + Returns an array of visible CPWindow objects, ordered by their front to back order on the screen. +*/ +- (CPArray)orderedWindows +{ + return CPWindowObjectList(); +} + - (void)hide:(id)aSender { [CPPlatform hide:self]; @@ -953,10 +1036,65 @@ CPRunContinuesResponse = -1002; return !![_documentController openDocumentWithContentsOfURL:aURL display:YES error:NULL]; } +- (void)_willBecomeActive +{ + [[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillBecomeActiveNotification + object:self + userInfo:nil]; +} + +- (void)_didBecomeActive +{ + if (![self keyWindow] && _previousKeyWindow && + [[self windows] indexOfObjectIdenticalTo:_previousKeyWindow] !== CPNotFound) + [_previousKeyWindow makeKeyWindow]; + + if (![self mainWindow] && _previousMainWindow && + [[self windows] indexOfObjectIdenticalTo:_previousMainWindow] !== CPNotFound) + [_previousMainWindow makeMainWindow]; + + if ([self keyWindow]) + [[self keyWindow] orderFront:self]; + else if ([self mainWindow]) + [[self mainWindow] makeKeyAndOrderFront:self]; + else + [[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work + + _previousKeyWindow = nil; + _previousMainWindow = nil; + + [[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidBecomeActiveNotification + object:self + userInfo:nil]; +} + +- (void)_willResignActive +{ + [[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationWillResignActiveNotification + object:self + userInfo:nil]; +} + - (void)_didResignActive { if (self._activeMenu) [self._activeMenu cancelTracking]; + + if ([self keyWindow]) + { + _previousKeyWindow = [self keyWindow]; + [_previousKeyWindow resignKeyWindow]; + } + + if ([self mainWindow]) + { + _previousMainWindow = [self mainWindow]; + [_previousMainWindow resignMainWindow]; + } + + [[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidResignActiveNotification + object:self + userInfo:nil]; } + (CPString)defaultThemeName diff --git a/AppKit/CPCursor.j b/AppKit/CPCursor.j index f5e67f692..95b1dc79a 100755 --- a/AppKit/CPCursor.j +++ b/AppKit/CPCursor.j @@ -230,8 +230,6 @@ var currentCursor = nil, + (void)_setCursorCSS:(CPString)aString { #if PLATFORM(DOM) - [CPPlatformWindow primaryPlatformWindow]._DOMBodyElement.style.cursor = aString; - var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects]; for (var i = 0, count = [platformWindows count]; i < count; i++) platformWindows[i]._DOMBodyElement.style.cursor = aString; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 3f506889d..aec63bb13 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -175,6 +175,8 @@ CPWindowBelow = 2; CPWindowWillCloseNotification = @"CPWindowWillCloseNotification"; CPWindowDidBecomeMainNotification = @"CPWindowDidBecomeMainNotification"; CPWindowDidResignMainNotification = @"CPWindowDidResignMainNotification"; +CPWindowDidBecomeKeyNotification = @"CPWindowDidBecomeKeyNotification"; +CPWindowDidResignKeyNotification = @"CPWindowDidResignKeyNotification"; CPWindowDidResizeNotification = @"CPWindowDidResizeNotification"; CPWindowDidMoveNotification = @"CPWindowDidMoveNotification"; CPWindowWillBeginSheetNotification = @"CPWindowWillBeginSheetNotification"; @@ -762,12 +764,7 @@ CPTexturedBackgroundWindowMask [_platformWindow order:CPWindowOut window:self relativeTo:nil]; - if ([CPApp keyWindow] == self) - { - [self resignKeyWindow]; - - CPApp._keyWindow = nil; - } + [self _updateMainAndKeyWindows]; } /*! @@ -1066,13 +1063,31 @@ CPTexturedBackgroundWindowMask */ - (void)setDelegate:(id)aDelegate { - // FIXME: Unregister for notifications! + var defaultCenter = [CPNotificationCenter defaultCenter]; + + [defaultCenter removeObserver:_delegate name:CPWindowDidResignKeyNotification object:self]; + [defaultCenter removeObserver:_delegate name:CPWindowDidBecomeKeyNotification object:self]; + [defaultCenter removeObserver:_delegate name:CPWindowDidBecomeMainNotification object:self]; + [defaultCenter removeObserver:_delegate name:CPWindowDidResignMainNotification object:self]; + [defaultCenter removeObserver:_delegate name:CPWindowDidMoveNotification object:self]; + [defaultCenter removeObserver:_delegate name:CPWindowDidResizeNotification object:self]; _delegate = aDelegate; - _delegateRespondsToWindowWillReturnUndoManagerSelector = [_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)]; - var defaultCenter = [CPNotificationCenter defaultCenter]; + if ([_delegate respondsToSelector:@selector(windowDidResignKey:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(windowDidResignKey:) + name:CPWindowDidResignKeyNotification + object:self]; + + if ([_delegate respondsToSelector:@selector(windowDidBecomeKey:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(windowDidBecomeKey:) + name:CPWindowDidBecomeKeyNotification + object:self]; if ([_delegate respondsToSelector:@selector(windowDidBecomeMain:)]) [defaultCenter @@ -1418,8 +1433,14 @@ CPTexturedBackgroundWindowMask */ - (void)becomeKeyWindow { - if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)]) + CPApp._keyWindow = self; + + if (_firstResponder !== self && [_firstResponder respondsToSelector:@selector(becomeKeyWindow)]) [_firstResponder becomeKeyWindow]; + + [[CPNotificationCenter defaultCenter] + postNotificationName:CPWindowDidBecomeKeyNotification + object:self]; } /*! @@ -1456,13 +1477,10 @@ CPTexturedBackgroundWindowMask */ - (void)makeKeyWindow { - if (![self canBecomeKeyWindow]) + if ([CPApp keyWindow] === self || ![self canBecomeKeyWindow]) return; - [CPApp._keyWindow resignKeyWindow]; - - CPApp._keyWindow = self; - + [[CPApp keyWindow] resignKeyWindow]; [self becomeKeyWindow]; } @@ -1473,9 +1491,12 @@ CPTexturedBackgroundWindowMask { if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)]) [_firstResponder resignKeyWindow]; - - if ([_delegate respondsToSelector:@selector(windowDidResignKey:)]) - [_delegate windowDidResignKey:self]; + + CPApp._keyWindow = nil; + + [[CPNotificationCenter defaultCenter] + postNotificationName:CPWindowDidResignKeyNotification + object:self]; } /*! @@ -1664,6 +1685,8 @@ CPTexturedBackgroundWindowMask [[self platformWindow] miniaturize:sender]; + [self _lossOfKeyOrMainWindow]; + [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidMiniaturizeNotification object:self]; _isMiniaturized = YES; @@ -1799,13 +1822,10 @@ CPTexturedBackgroundWindowMask */ - (void)makeMainWindow { - if (CPApp._mainWindow === self || ![self canBecomeMainWindow]) + if ([CPApp mainWindow] === self || ![self canBecomeMainWindow]) return; - [CPApp._mainWindow resignMainWindow]; - - CPApp._mainWindow = self; - + [[CPApp mainWindow] resignMainWindow]; [self becomeMainWindow]; } @@ -1816,7 +1836,9 @@ CPTexturedBackgroundWindowMask { [self _synchronizeMenuBarTitleWithWindowTitle]; [self _synchronizeSaveMenuWithDocumentSaving]; - + + CPApp._mainWindow = self; + [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidBecomeMainNotification object:self]; @@ -1830,6 +1852,71 @@ CPTexturedBackgroundWindowMask [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidResignMainNotification object:self]; + + CPApp._mainWindow = nil; +} + +- (void)_updateMainAndKeyWindows +{ + var allWindows = [CPApp orderedWindows], + windowCount = [allWindows count]; + + if (!windowCount) + return; + + if ([self isKeyWindow]) + { + var keyWindow = [CPApp keyWindow]; + [self resignKeyWindow]; + + if (keyWindow && keyWindow !== self && [keyWindow canBecomeKeyWindow]) + [keyWindow makeKeyWindow]; + else + { + var menuWindow = [CPApp mainMenu]._menuWindow; + for (var i = 0; i < windowCount; i++) + { + var currentWindow = allWindows[i]; + if (currentWindow === self || currentWindow === menuWindow) + continue; + + if ([currentWindow isVisible] && [currentWindow canBecomeKeyWindow]) + { + [currentWindow makeKeyWindow]; + break; + } + } + + if (![CPApp keyWindow]) + [keyWindow makeKeyWindow]; + } + } + + + if ([self isMainWindow]) + { + var mainWindow = [CPApp mainWindow]; + [self resignMainWindow]; + + if (mainWindow && mainWindow !== self && [mainWindow canBecomeMainWindow]) + [mainWindow makeMainWindow]; + else + { + var menuWindow = [CPApp mainMenu]._menuWindow; + for (var i = 0; i < windowCount; i++) + { + var currentWindow = allWindows[i]; + if (currentWindow === self || currentWindow === menuWindow) + continue; + + if ([currentWindow isVisible] && [currentWindow canBecomeMainWindow]) + { + [currentWindow makeMainWindow]; + break; + } + } + } + } } // Managing Toolbars diff --git a/AppKit/Platform/CPPlatform.j b/AppKit/Platform/CPPlatform.j index 8bf37856e..db2128810 100644 --- a/AppKit/Platform/CPPlatform.j +++ b/AppKit/Platform/CPPlatform.j @@ -58,6 +58,10 @@ { } ++ (void)deactivate +{ +} + + (void)hideOtherApplications:(id)aSender { } diff --git a/AppKit/Platform/DOM/CPPlatform.j b/AppKit/Platform/DOM/CPPlatform.j index 96c7a30bf..98d7ca02e 100644 --- a/AppKit/Platform/DOM/CPPlatform.j +++ b/AppKit/Platform/DOM/CPPlatform.j @@ -69,6 +69,12 @@ var screenNeedsInitialization = NO, window.cpActivateIgnoringOtherApps(!!shouldIgnoreOtherApps); } ++ (void)deactivate +{ + if (typeof window["cpDeactivate"] === "function") + window.cpDeactivate(); +} + + (void)hideOtherApplications:(id)aSender { if (typeof window["cpHideOtherApplications"] === "function") diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index e6cff4912..1e7f8d835 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -426,7 +426,14 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop]; + (CPSet)visiblePlatformWindows { - return PlatformWindows; + if ([[CPPlatformWindow primaryPlatformWindow] isVisible]) + { + var set = [CPSet setWithSet:PlatformWindows]; + [set addObject:[CPPlatformWindow primaryPlatformWindow]]; + return set; + } + else + return PlatformWindows; } - (void)orderFront:(id)aSender @@ -1374,19 +1381,25 @@ var CPDOMEventStop = function(aDOMEvent, aPlatformWindow) function CPWindowObjectList() { - var platformWindow = [CPPlatformWindow primaryPlatformWindow], - levels = platformWindow._windowLevels, - layers = platformWindow._windowLayers, - levelCount = levels.length, + var platformWindows = [CPPlatformWindow visiblePlatformWindows], + platformWindowEnumerator = [platformWindows objectEnumerator], + platformWindow = nil, windowObjects = []; - while (levelCount--) + while (platformWindow = [platformWindowEnumerator nextObject]) { - var windows = [layers objectForKey:levels[levelCount]]._windows, - windowCount = windows.length; + var levels = platformWindow._windowLevels, + layers = platformWindow._windowLayers, + levelCount = levels.length; - while (windowCount--) - windowObjects.push(windows[windowCount]); + while (levelCount--) + { + var windows = [layers objectForKey:levels[levelCount]]._windows, + windowCount = windows.length; + + while (windowCount--) + windowObjects.push(windows[windowCount]); + } } return windowObjects; @@ -1394,20 +1407,11 @@ function CPWindowObjectList() function CPWindowList() { - var platformWindow = [CPPlatformWindow primaryPlatformWindow], - levels = platformWindow._windowLevels, - layers = platformWindow._windowLayers, - levelCount = levels.length, - windowNumbers = []; + var windowObjectList = CPWindowObjectList(), + windowList = []; - while (levelCount--) - { - var windows = [layers objectForKey:levels[levelCount]]._windows, - windowCount = windows.length; + for (var i = 0, count = [windowObjectList count]; i < count; i++) + windowList.push([windowObjectList[i] windowNumber]); - while (windowCount--) - windowNumbers.push([windows[windowCount] windowNumber]); - } - - return windowNumbers; + return windowList; } From 398d61097c10b109eff7f54f5b360d8867755229 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Tue, 2 Mar 2010 15:27:40 -0800 Subject: [PATCH 02/12] Typo in miniaturize: --- AppKit/CPWindow/CPWindow.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index aec63bb13..b3275ee6c 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1685,7 +1685,7 @@ CPTexturedBackgroundWindowMask [[self platformWindow] miniaturize:sender]; - [self _lossOfKeyOrMainWindow]; + [self _updateMainAndKeyWindows]; [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidMiniaturizeNotification object:self]; From 149308bc89e92405983d4648e766bb24d2681233 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 3 Mar 2010 14:42:15 -0800 Subject: [PATCH 03/12] Revert "fix for scrollviews being drawn below window resize indicator." This reverts commit 18a0deb67860deb4afe3d7589ca43981f8738693. --- AppKit/CPScrollView.j | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 55955a4da..73cae512e 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -229,19 +229,6 @@ if (shouldShowHorizontalScroller) contentFrame.size.height -= horizontalScrollerHeight; - var _window = [self window], - forceCornerSpace = NO; - - if (_window && [_window contentView]) - { - var windowIsResizable = !!(([_window styleMask] & CPResizableWindowMask) || ([_window styleMask] & CPBorderlessBridgeWindowMask)), - relativeFrame = [self convertRect:[[_window contentView] frame] fromView:nil], - maxPoint = CGPointMake(CGRectGetMaxX([self bounds]), CGRectGetMaxY([self bounds])), - isInWindowCorner = CGRectGetMaxX(relativeFrame) >= maxPoint.x && CGRectGetMaxY(relativeFrame) >= maxPoint.y; - - forceCornerSpace = windowIsResizable && isInWindowCorner; - } - var scrollPoint = [_contentView bounds].origin, wasShowingVerticalScroller = ![_verticalScroller isHidden], wasShowingHorizontalScroller = ![_horizontalScroller isHidden]; @@ -251,7 +238,7 @@ var verticalScrollerY = MAX(_CGRectGetHeight([self _cornerViewFrame]), headerClipViewHeight), verticalScrollerHeight = _CGRectGetHeight([self bounds]) - verticalScrollerY; - if (forceCornerSpace || shouldShowHorizontalScroller) + if (shouldShowHorizontalScroller) verticalScrollerHeight -= horizontalScrollerHeight; [_verticalScroller setFloatValue:(difference.height <= 0.0) ? 0.0 : scrollPoint.y / difference.height]; @@ -268,7 +255,7 @@ { [_horizontalScroller setFloatValue:(difference.width <= 0.0) ? 0.0 : scrollPoint.x / difference.width]; [_horizontalScroller setKnobProportion:_CGRectGetWidth(contentFrame) / _CGRectGetWidth(documentFrame)]; - [_horizontalScroller setFrame:_CGRectMake(0.0, _CGRectGetMaxY(contentFrame), _CGRectGetWidth(contentFrame) - ((!shouldShowVerticalScroller && forceCornerSpace) ? verticalScrollerWidth : 0), horizontalScrollerHeight)]; + [_horizontalScroller setFrame:_CGRectMake(0.0, _CGRectGetMaxY(contentFrame), _CGRectGetWidth(contentFrame), horizontalScrollerHeight)]; } else if (wasShowingHorizontalScroller) { @@ -806,4 +793,4 @@ var CPScrollViewContentViewKey = "CPScrollViewContentView", [aCoder encodeObject:_cornerView forKey:CPScrollViewCornerViewKey]; } -@end \ No newline at end of file +@end From 628488f7aa8d1b7aa7353329034c3a06535db59b Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 3 Mar 2010 14:42:29 -0800 Subject: [PATCH 04/12] Revert "fix for scroller still being drawn below resize indicator on the first reflect of the clipview." This reverts commit fa63551b42bf41c33537d6ebd7f8fadf434c2903. --- AppKit/CPScrollView.j | 5 ----- 1 file changed, 5 deletions(-) diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 73cae512e..6406c96fb 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -720,11 +720,6 @@ [_headerClipView scrollToPoint:CGPointMake(contentBounds.origin, 0)]; } -- (void)viewDidMoveToWindow -{ - [self reflectScrolledClipView:_contentView]; -} - @end var CPScrollViewContentViewKey = "CPScrollViewContentView", From 9537a62ab12927d43691007815557233255959de Mon Sep 17 00:00:00 2001 From: saikat Date: Sun, 28 Feb 2010 00:22:47 -0800 Subject: [PATCH 05/12] Fixes calling selectText in the text field's delegate's controlTextDidFocus: method. --- AppKit/CPTextField.j | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 762e4c9b3..b3c452cc0 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -483,6 +483,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); window.setTimeout(function() { element.focus(); + [self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]]; CPTextFieldInputOwner = self; }, 0.0); @@ -500,8 +501,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [[self window] platformWindow]._DOMBodyElement.ondrag = function () {}; [[self window] platformWindow]._DOMBodyElement.onselectstart = function () {}; } - - [self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]]; #endif return YES; From ad5f574fb71e1783a0b2e5475302b2c35f907fc6 Mon Sep 17 00:00:00 2001 From: saikat Date: Sun, 28 Feb 2010 00:52:51 -0800 Subject: [PATCH 06/12] Fix for issue #511 - disabling a menu item in the menu item's action --- AppKit/CPMenuItem/_CPMenuItemMenuBarView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j b/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j index 6e232fef8..6342ef99e 100644 --- a/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j +++ b/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j @@ -155,7 +155,7 @@ var SelectionColor = nil, { // FIXME: This should probably be even throw. if (![_menuItem isEnabled]) - return; + shouldHighlight = NO; if (shouldHighlight) { From 47bc7e812dcf71ed6271aca3c0f878b64d791dae Mon Sep 17 00:00:00 2001 From: saikat Date: Sun, 28 Feb 2010 00:52:51 -0800 Subject: [PATCH 07/12] Fix for issue #511 - disabling a menu item in the menu item's action --- AppKit/CPMenuItem/_CPMenuItemMenuBarView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j b/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j index 6e232fef8..6342ef99e 100644 --- a/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j +++ b/AppKit/CPMenuItem/_CPMenuItemMenuBarView.j @@ -155,7 +155,7 @@ var SelectionColor = nil, { // FIXME: This should probably be even throw. if (![_menuItem isEnabled]) - return; + shouldHighlight = NO; if (shouldHighlight) { From 50b5c21fcfe725dbbee9553382441c13dce332e5 Mon Sep 17 00:00:00 2001 From: saikat Date: Sun, 28 Feb 2010 00:22:47 -0800 Subject: [PATCH 08/12] Fixes calling selectText in the text field's delegate's controlTextDidFocus: method. --- AppKit/CPTextField.j | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 762e4c9b3..b3c452cc0 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -483,6 +483,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); window.setTimeout(function() { element.focus(); + [self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]]; CPTextFieldInputOwner = self; }, 0.0); @@ -500,8 +501,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [[self window] platformWindow]._DOMBodyElement.ondrag = function () {}; [[self window] platformWindow]._DOMBodyElement.onselectstart = function () {}; } - - [self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]]; #endif return YES; From ab196e75c1bcd2af86e46aab6023f81e8dad9b8e Mon Sep 17 00:00:00 2001 From: Paul Baumgart Date: Fri, 5 Mar 2010 02:07:13 -0800 Subject: [PATCH 09/12] Fix missing throw in Preprocessor to report an error on unmatched brackets. Closes gh-524 --- Objective-J/Preprocessor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objective-J/Preprocessor.js b/Objective-J/Preprocessor.js index e07ccf75a..51bcd4bae 100644 --- a/Objective-J/Preprocessor.js +++ b/Objective-J/Preprocessor.js @@ -855,7 +855,7 @@ Preprocessor.prototype.preprocess = function(tokens, /*StringBuffer*/ aStringBuf // If we get this far and we're parsing an objj_msgSend (or array), then we have a problem. if (tuple) - new SyntaxError(this.error_message("*** Expected ']' - Unterminated message send or array.")); + throw new SyntaxError(this.error_message("*** Expected ']' - Unterminated message send or array.")); if (!aStringBuffer) return buffer; From c478afee0fa0f8f19080be7738fb89efe7d5d76a Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Fri, 5 Mar 2010 12:38:59 -0800 Subject: [PATCH 10/12] Add a missing import to CPTheme. Closes #527. --- AppKit/CPTheme.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index 499aaa8f7..77bac886d 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -22,7 +22,7 @@ @import @import - +@import var CPThemesByName = { }, CPThemeDefaultTheme = nil; From 7d1c7b2907dd373e817c5a8d8b4cff43e389545a Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Fri, 5 Mar 2010 13:46:41 -0800 Subject: [PATCH 11/12] Add missing accessor to CPImageView, and fix nib2cib support for image scaling. Closes #523. --- AppKit/CPImageView.j | 19 +++++-------------- Tools/nib2cib/NSImageView.j | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j index ed6eeea42..817ffbd0b 100644 --- a/AppKit/CPImageView.j +++ b/AppKit/CPImageView.j @@ -31,24 +31,10 @@ #include "CoreGraphics/CGGeometry.h" - -/* - @global - @group CPImageScaling -*/ CPScaleProportionally = 0; -/* - @global - @group CPImageScaling -*/ CPScaleToFit = 1; -/* - @global - @group CPImageScaling -*/ CPScaleNone = 2; - var CPImageViewShadowBackgroundColor = nil; var LEFT_SHADOW_INSET = 3.0, @@ -225,6 +211,11 @@ var LEFT_SHADOW_INSET = 3.0, [self setNeedsDisplay:YES]; } +- (unsigned)imageScaling +{ + return [self currentValueForThemeAttribute:@"image-scaling"]; +} + /*! Toggles the display of the image view. */ diff --git a/Tools/nib2cib/NSImageView.j b/Tools/nib2cib/NSImageView.j index 62eb55fe0..2624c2582 100644 --- a/Tools/nib2cib/NSImageView.j +++ b/Tools/nib2cib/NSImageView.j @@ -33,7 +33,7 @@ { var cell = [aCoder decodeObjectForKey:@"NSCell"]; - _imageScaling = [cell imageScaling]; + [self setImageScaling:[cell imageScaling]]; _isEditable = [cell isEditable]; } From 29a0de3636e3745ebeed2503ffd6e503bf6b80fa Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Fri, 5 Mar 2010 20:09:23 -0800 Subject: [PATCH 12/12] Fix document title's not being synced properly. --- AppKit/CPWindow/CPWindow.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index b3275ee6c..e68c33174 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1834,11 +1834,11 @@ CPTexturedBackgroundWindowMask */ - (void)becomeMainWindow { + CPApp._mainWindow = self; + [self _synchronizeMenuBarTitleWithWindowTitle]; [self _synchronizeSaveMenuWithDocumentSaving]; - CPApp._mainWindow = self; - [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidBecomeMainNotification object:self];