aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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]);