summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
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/classes
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/classes')
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java32
1 files changed, 26 insertions, 6 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) {