mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-21 14:09:22 +00:00
Fixed: keyWindow and mainWindow did not work when jumping from window to window when popover were open
Previously, when jumping from a platformWindow to another platformWindow where popover where opened, the wrong windows became key and main. This things occurred weird behavior of the platformWindows. Now, it works as in cocoa, canBecomKeyWindow, becomeKeyWindow, becomeMainWindow, resignKeyWindow and resignMainWindow are called in the good order.
This commit is contained in:
1 parent
01ba6ddecd
commit
fd068443aa
4 files changed
+61
-4
No files matched your search
@@ -2131,6 +2131,7 @@ CPTexturedBackgroundWindowMask
|
||||
if (CPApp._keyWindow === self)
|
||||
CPApp._keyWindow = nil;
|
||||
|
||||
_platformWindow._currentKeyWindow = nil;
|
||||
[_windowView noteKeyWindowStateChanged];
|
||||
[_contentView _notifyWindowDidResignKey];
|
||||
|
||||
@@ -2514,6 +2515,7 @@ CPTexturedBackgroundWindowMask
|
||||
- (void)becomeMainWindow
|
||||
{
|
||||
CPApp._mainWindow = self;
|
||||
_platformWindow._currentMainWindow = self;
|
||||
|
||||
[self _synchronizeSaveMenuWithDocumentSaving];
|
||||
|
||||
@@ -2536,6 +2538,7 @@ CPTexturedBackgroundWindowMask
|
||||
if (CPApp._mainWindow === self)
|
||||
CPApp._mainWindow = nil;
|
||||
|
||||
_platformWindow._currentMainWindow = nil;
|
||||
[_windowView noteMainWindowStateChanged];
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ var PrimaryPlatformWindow = NULL;
|
||||
|
||||
CPWindow _currentKeyWindow;
|
||||
CPWindow _previousKeyWindow;
|
||||
|
||||
CPWindow _currentMainWindow;
|
||||
CPWindow _previousMainWindow;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1058,7 +1058,10 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio
|
||||
- (void)blurEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
_previousKeyWindow = _currentKeyWindow;
|
||||
_previousMainWindow = _currentMainWindow;
|
||||
|
||||
[_previousKeyWindow resignKeyWindow];
|
||||
[_previousMainWindow resignMainWindow];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
@@ -1068,16 +1071,53 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio
|
||||
*/
|
||||
- (void)focusEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
var theWindow = _previousKeyWindow;
|
||||
var keyWindow = _previousKeyWindow;
|
||||
|
||||
if (!theWindow)
|
||||
theWindow = [[[_windowLayers objectForKey:[_windowLevels firstObject]] orderedWindows] firstObject];
|
||||
if (!keyWindow)
|
||||
keyWindow = [[[_windowLayers objectForKey:[_windowLevels firstObject]] orderedWindows] firstObject];
|
||||
|
||||
[theWindow makeKeyAndOrderFront:self];
|
||||
[self _makeKeyWindow:keyWindow];
|
||||
|
||||
if ([keyWindow isKeyWindow] && ([keyWindow firstResponder] === keyWindow || ![keyWindow firstResponder]))
|
||||
[keyWindow makeFirstResponder:[keyWindow initialFirstResponder]];
|
||||
|
||||
[self _makeMainWindow:keyWindow];
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)_makeKeyWindow:(CPWindow)aWindow
|
||||
{
|
||||
if ([CPApp keyWindow] === aWindow || ![aWindow canBecomeKeyWindow])
|
||||
return;
|
||||
|
||||
[[CPApp keyWindow] resignKeyWindow];
|
||||
[aWindow becomeKeyWindow];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)_makeMainWindow:(CPWindow)aWindow
|
||||
{
|
||||
// Sheets cannot be main. Their parent window becomes main.
|
||||
if (aWindow._isSheet)
|
||||
{
|
||||
[self _makeMainWindow:aWindow._parentView];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([CPApp mainWindow] === aWindow || ![aWindow canBecomeMainWindow])
|
||||
return;
|
||||
|
||||
[[CPApp mainWindow] resignMainWindow];
|
||||
[aWindow becomeMainWindow];
|
||||
}
|
||||
|
||||
|
||||
- (void)touchEvent:(DOMEvent)aDOMEvent
|
||||
{
|
||||
if (aDOMEvent.touches && (aDOMEvent.touches.length == 1 || (aDOMEvent.touches.length == 0 && aDOMEvent.changedTouches.length == 1)))
|
||||
|
||||
@@ -668,6 +668,17 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4,
|
||||
[_delegate _popoverWindowDidClose];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Needed to be ignored to close a popover when a platform is closed.
|
||||
Because the animation, the popover is not properly closed.
|
||||
*/
|
||||
- (void)_didReceivePlatformWindowWillCloseNotification:(CPNotification)aNotification
|
||||
{
|
||||
[super _didReceivePlatformWindowWillCloseNotification:aNotification];
|
||||
[self _orderOutRecursively:YES];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Private
|
||||
|
||||
Reference in new issue
Block a user