diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index e8fd603dc..b749b8768 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -569,6 +569,9 @@ CPTexturedBackgroundWindowMask var fullPlatformWindowViewClass = [[self class] _windowViewClassForFullPlatformWindowStyleMask:_styleMask], windowView = [[fullPlatformWindowViewClass alloc] initWithFrame:CGRectMakeZero() styleMask:_styleMask]; + if (_platformWindow != [CPPlatformWindow primaryPlatformWindow]) + [_platformWindow setContentRect:[self frame]]; + [self _setWindowView:windowView]; [self setLevel:CPBackgroundWindowLevel]; @@ -753,6 +756,9 @@ CPTexturedBackgroundWindowMask if (originMoved) [self _moveChildWindows:delta]; } + + if ([_platformWindow _shouldUpdateContentRect] && _isFullPlatformWindow && _platformWindow != [CPPlatformWindow primaryPlatformWindow]) + [_platformWindow setContentRect:aFrame]; } /* @@ -904,6 +910,10 @@ CPTexturedBackgroundWindowMask [[self contentView] _addObservers]; #if PLATFORM(DOM) + + if (!_isVisible) + [_platformWindow _setShouldUpdateContentRect:NO]; + // -dw- if a sheet is clicked, the parent window should come up too if (_isSheet) [_parentView orderFront:self]; @@ -923,6 +933,8 @@ CPTexturedBackgroundWindowMask if (!CPApp._mainWindow) [self makeMainWindow]; + + [_platformWindow _setShouldUpdateContentRect:YES]; } /* diff --git a/AppKit/Platform/CPPlatformWindow.j b/AppKit/Platform/CPPlatformWindow.j index 628293117..e88a1ebf3 100644 --- a/AppKit/Platform/CPPlatformWindow.j +++ b/AppKit/Platform/CPPlatformWindow.j @@ -40,6 +40,8 @@ var PrimaryPlatformWindow = NULL; BOOL _hasShadow; unsigned _shadowStyle; CPString _title; + BOOL _shouldUpdateContentRect; + BOOL _hasInitializeInstanceWithWindow; #if PLATFORM(DOM) DOMWindow _DOMWindow; @@ -116,6 +118,17 @@ var PrimaryPlatformWindow = NULL; return self; } +- (id)initWithWindow:(CPWindow)aWindow +{ + self = [self initWithContentRect:CGRectMakeCopy([aWindow frame])]; + + [aWindow setPlatformWindow:self]; + [aWindow setFullPlatformWindow:YES]; + _hasInitializeInstanceWithWindow = YES; + + return self; +} + - (id)init { return [self initWithContentRect:CGRectMake(0.0, 0.0, 400.0, 500.0)]; @@ -281,6 +294,17 @@ var PrimaryPlatformWindow = NULL; return _title; } +- (BOOL)_shouldUpdateContentRect +{ + // We onyl update the contentRect with the frame of the bridgeless window if we have initialized the platform with the method initWithWindow: + return _shouldUpdateContentRect && _hasInitializeInstanceWithWindow; +} + +- (void)_setShouldUpdateContentRect:(BOOL)aBoolean +{ + _shouldUpdateContentRect = aBoolean; +} + @end #if PLATFORM(BROWSER) diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index 31b1810ef..cf83be2d6 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -988,6 +988,7 @@ var PreventScroll = true; - (void)_actualResizeEvent { + _shouldUpdateContentRect = NO; resizeTimer = nil; // FIXME: This is not the right way to do this. @@ -1021,6 +1022,8 @@ var PreventScroll = true; //window.liveResize = NO; [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; + + _shouldUpdateContentRect = YES; } - (void)touchEvent:(DOMEvent)aDOMEvent diff --git a/Tests/Manual/CPPlatformWindow/AppController.j b/Tests/Manual/CPPlatformWindow/AppController.j index 002edfeba..568b97345 100644 --- a/Tests/Manual/CPPlatformWindow/AppController.j +++ b/Tests/Manual/CPPlatformWindow/AppController.j @@ -22,12 +22,7 @@ - (void)applicationDidFinishLaunching:(CPNotification)aNotification { // This is called when the application is done loading. - - platformWindow = [[CPPlatformWindow alloc] init]; - [platformWindow setContentRect:[windowPlatformWindow contentRectForFrameRect:[windowPlatformWindow frame]]]; - - [windowPlatformWindow setPlatformWindow:platformWindow]; - [windowPlatformWindow setFullPlatformWindow:YES] + [[CPPlatformWindow alloc] initWithWindow:windowPlatformWindow]; } - (void)awakeFromCib @@ -52,7 +47,7 @@ - (IBAction)changeFrame:(id)sender { - [platformWindow setContentRect:CGRectMake(50, 50, 200, 200)]; + [windowPlatformWindow setFrame:CGRectMake(250, 250, 200, 200)]; } - (IBAction)showAlert:(id)sender