diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 9b6dde66b..4bef16ced 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -2060,6 +2060,7 @@ CPTexturedBackgroundWindowMask [self _setupFirstResponder]; _hasBecomeKeyWindow = YES; + _platformWindow._currentKeyWindow = self; [_windowView noteKeyWindowStateChanged]; [_contentView _notifyWindowDidBecomeKey]; diff --git a/AppKit/Platform/CPPlatformWindow.j b/AppKit/Platform/CPPlatformWindow.j index cd17fa4a6..41818b13f 100644 --- a/AppKit/Platform/CPPlatformWindow.j +++ b/AppKit/Platform/CPPlatformWindow.j @@ -75,6 +75,9 @@ var PrimaryPlatformWindow = NULL; CPPlatformPasteboard _platformPasteboard; CPString _overriddenEventType; + + CPWindow _currentKeyWindow; + CPWindow _previousKeyWindow; #endif } diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index 52a1484ed..6a54d78e7 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -1057,10 +1057,10 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio */ - (void)blurEvent:(DOMEvent)aDOMEvent { - var location = _lastMouseEventLocation || CGPointMakeZero(), - theWindow = [self _hitTest:location withTest:@selector(_isValidMousePoint:) returnsDefaultWindowIfNull:YES]; + _previousKeyWindow = _currentKeyWindow; + [_previousKeyWindow resignKeyWindow]; - [theWindow resignKeyWindow]; + [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; } /*! @@ -1068,10 +1068,14 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio */ - (void)focusEvent:(DOMEvent)aDOMEvent { - var location = _lastMouseEventLocation || CGPointMakeZero(), - theWindow = [self _hitTest:location withTest:@selector(_isValidMousePoint:) returnsDefaultWindowIfNull:YES]; + var theWindow = _previousKeyWindow; + + if (!theWindow) + theWindow = [[[_windowLayers objectForKey:[_windowLevels firstObject]] orderedWindows] firstObject]; [theWindow makeKeyAndOrderFront:self]; + + [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; } - (void)touchEvent:(DOMEvent)aDOMEvent @@ -1560,11 +1564,6 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio } - (CPWindow)_hitTest:(CGPoint)location withTest:(SEL)aTest -{ - return [self _hitTest:location withTest:aTest returnsDefaultWindowIfNull:NO]; -} - -- (CPWindow)_hitTest:(CGPoint)location withTest:(SEL)aTest returnsDefaultWindowIfNull:(BOOL)returnsDefaultWindowIfNull { if (self._only) return self._only; @@ -1588,9 +1587,6 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio } } - if (!theWindow && returnsDefaultWindowIfNull) - theWindow = [[[layers objectForKey:[levels firstObject]] orderedWindows] firstObject]; - return theWindow; }