From 85b332e0954af4afc9225eb84d758bee834dc497 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 15 Jan 2020 02:24:25 +0100 Subject: Bug 1421: NEWT OSX Invisible: Implement 'Fake invisible child window' 'Fake invisible child window' is implemented by simply moving the window out of sight (viewport). - orderOut0 needs to use '[mWin orderWindow: NSWindowBelow relativeTo:..' parentWindow instead of '[mWin orderBack:..', otherwise the whole parent application gets invisible w/ SWT ;-) - NewtNSWindow may also needs to use parent's Screen instance if moved offscreen, as the own Screen is invalid (zero size) in this case. - WindowDriver: Adding special treatment for 'Fake invisible child window' (tagged as such): -- reconfigureWindowImpl: setWindowClientTopLeftPointAndSize0(..) will be called using the viewport's max position -> out of sight. -- screenPositionChanged: ignore the 'new' position -- sizeChanged: ignore the 'new' size This sensitive NEWT change set shall benefit other toolkits being used as parentWindow besides SWT, as this behavior is the same across MacOS. --- src/newt/native/MacNewtNSWindow.m | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/newt/native/MacNewtNSWindow.m') diff --git a/src/newt/native/MacNewtNSWindow.m b/src/newt/native/MacNewtNSWindow.m index ae2b4d748..eef3278b9 100644 --- a/src/newt/native/MacNewtNSWindow.m +++ b/src/newt/native/MacNewtNSWindow.m @@ -1007,7 +1007,9 @@ NS_ENDHANDLER NS_DURING // this causes troubles w/ SWT toolkit // exception 'NSInvalidArgumentException', reason: '-[SWTCanvasView addChildWindow:ordered:]: unrecognized selector sent to instance 0x7fc198f66580' - [parent addChildWindow: self ordered: NSWindowAbove]; + // if( ![[parent childWindows] containsObject: self] ) { + [parent addChildWindow: self ordered: NSWindowAbove]; + // } NS_HANDLER NS_ENDHANDLER DBG_PRINT( "attachToParent.2\n"); @@ -1055,14 +1057,19 @@ NS_ENDHANDLER DBG_PRINT( "newtTLScreenPos2BLScreenPos: point-in[%d/%d], size-in[%dx%d], insets bottom %d -> totalHeight %d\n", (int)p.x, (int)p.y, (int)nsz.width, (int)nsz.height, cachedInsets[3], totalHeight); - NSScreen* screen = [self screen]; - - CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); + NSScreen* _screen = [self screen]; + NSWindow* pWin = [self parentWindow]; + NSRect frameBL = [_screen frame]; // origin bottom-left + if( frameBL.size.width <= 0 && frameBL.size.height <= 0 && NULL != pWin ) { + // Fake invisible child window: Own NSScreen instance could be invalid if moved off viewport + _screen = [pWin screen]; + frameBL = [_screen frame]; // origin bottom-left + } + CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(_screen); CGRect frameTL = CGDisplayBounds (display); // origin top-left - NSRect frameBL = [screen frame]; // origin bottom-left NSPoint r = NSMakePoint(p.x, frameBL.origin.y + frameBL.size.height - ( p.y - frameTL.origin.y ) - totalHeight); // y-flip from TL-screen -> BL-screen - DBG_PRINT( "newtTLScreenPos2BLScreenPos: screen tl[%d/%d %dx%d] bl[%d/%d %dx%d -> %d/%d\n", + DBG_PRINT( "newtTLScreenPos2BLScreenPos: screen tl[%d/%d %dx%d] bl[%d/%d %dx%d] -> %d/%d\n", (int)frameTL.origin.x, (int)frameTL.origin.y, (int)frameTL.size.width, (int)frameTL.size.height, (int)frameBL.origin.x, (int)frameBL.origin.y, (int)frameBL.size.width, (int)frameBL.size.height, (int)r.x, (int)r.y); -- cgit v1.2.3