summaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-01-15 02:24:25 +0100
committerSven Gothel <[email protected]>2020-01-15 02:24:25 +0100
commit85b332e0954af4afc9225eb84d758bee834dc497 (patch)
treee676dbc40a155d925e617b449fd77882bb4da570 /src/newt
parent6d341e110912f9085194cb94ba6f6c358104ee71 (diff)
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.
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java32
-rw-r--r--src/newt/native/MacNewtNSWindow.m19
-rw-r--r--src/newt/native/MacWindow.m2
3 files changed, 40 insertions, 13 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 9d93da3f0..76bb52cd7 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -45,6 +45,7 @@ import com.jogamp.nativewindow.ScalableSurface;
import com.jogamp.nativewindow.VisualIDHolder;
import com.jogamp.nativewindow.util.Point;
import com.jogamp.nativewindow.util.PointImmutable;
+import com.jogamp.nativewindow.util.RectangleImmutable;
import jogamp.nativewindow.SurfaceScaleUtils;
import jogamp.nativewindow.macosx.OSXUtil;
@@ -54,6 +55,7 @@ import jogamp.newt.WindowImpl;
import jogamp.newt.driver.DriverClearFocus;
import jogamp.newt.driver.DriverUpdatePosition;
+import com.jogamp.newt.Screen;
import com.jogamp.newt.event.InputEvent;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.MonitorEvent;
@@ -480,10 +482,19 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
OSXUtil.RunOnMainThread(true, false, new Runnable() {
@Override
public void run() {
- setWindowClientTopLeftPointAndSize0(oldWindowHandle,
- pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(),
- width, height, 0 != ( STATE_MASK_VISIBLE & flags));
- updateSizePosInsets0(oldWindowHandle, false); // calls: sizeScreenPosInsetsChanged(..)
+ if( useParent && 0 == ( STATE_MASK_VISIBLE & flags) ) {
+ // Fake invisible child window: We can't use true orderOut
+ final RectangleImmutable r = getScreen().getViewportInWindowUnits();
+ setWindowClientTopLeftPointAndSize0(oldWindowHandle,
+ r.getX()+r.getWidth(), r.getY()+r.getHeight(),
+ width, height, false /* no display */);
+ } else {
+ // Normal visibility
+ setWindowClientTopLeftPointAndSize0(oldWindowHandle,
+ pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(),
+ width, height, 0 != ( STATE_MASK_VISIBLE & flags));
+ updateSizePosInsets0(oldWindowHandle, false); // calls: sizeScreenPosInsetsChanged(..)
+ }
} } );
} else { // else offscreen size is realized via recreation
// no native event (fullscreen, some reparenting)
@@ -544,12 +555,19 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
// passed coordinates are in screen position of the client area
if( isNativeValid() ) {
final NativeWindow parent = getParent();
- if( !useParent(parent) || isOffscreenInstance ) {
+ final boolean useParent = useParent(parent);
+ if( !useParent || isOffscreenInstance ) {
if(DEBUG_IMPLEMENTATION) {
System.err.println("MacWindow.positionChanged.0 (Screen Pos - TOP): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY);
}
positionChanged(defer, newX, newY);
+ } else if( useParent && !isVisible() ) {
+ // Fake invisible child window: drop fake position update for fake invisibility
+ if(DEBUG_IMPLEMENTATION) {
+ System.err.println("MacWindow.positionChanged.1 (Screen Pos - invisible CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+", ignoring absPos "+newX+"/"+newY);
+ }
} else {
+ // visible childWindow or offscreen instance
final Runnable action = new Runnable() {
public void run() {
// screen position -> rel child window position
@@ -583,10 +601,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
@Override
protected void sizeChanged(final boolean defer, final int newWidth, final int newHeight, final boolean force) {
if(force || getWidth() != newWidth || getHeight() != newHeight) {
- if( isNativeValid() && !isOffscreenInstance ) {
+ if( isNativeValid() && isVisible() && !isOffscreenInstance ) {
final NativeWindow parent = getParent();
final boolean useParent = useParent(parent);
if( useParent ) {
+ // Visible child-windows: Reset position
+ // Fake invisible child window: These are ignored
final int x=getX(), y=getY();
final Point p0S = getLocationOnScreenByParent(x, y, parent);
if(DEBUG_IMPLEMENTATION) {
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);
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index a8f196fed..b3961b47a 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -1301,7 +1301,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderOut0
// NSWindowOut: The window is removed from the screen list and otherWin is ignored.
// This would remove this window from its parent -> AVOID!
// [mWin orderWindow: NSWindowOut relativeTo: [pWin windowNumber]];
- [mWin orderBack: mWin];
+ [mWin orderWindow: NSWindowBelow relativeTo: [pWin windowNumber]];
}
DBG_PRINT( "orderOut0 - window: (parent %p) %p visible %d (END)\n", pWin, mWin, [mWin isVisible]);