diff options
Diffstat (limited to 'src/newt/classes/jogamp')
10 files changed, 278 insertions, 250 deletions
diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 2f893fb2c..7cdcfac9a 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -85,11 +85,6 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { return surfaceHandle; } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - sizeChanged(width, height, false); - visibleChanged(visible); - } - protected void requestFocusImpl(boolean reparented) { } @@ -108,8 +103,14 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { // nop return false; } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, boolean parentChange, int fullScreenChange, int decorationChange) { - shouldNotCallThis(); + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + sizeChanged(width, height, false); + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } else { + shouldNotCallThis(); + } return false; } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index faf4c1a50..611af3d21 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -393,31 +393,76 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected abstract void requestFocusImpl(boolean force); - /** - * The native implementation must invoke {@link #visibleChanged(boolean)} - * to change the visibility state. This may happen asynchronous within - * {@link #TIMEOUT_NATIVEWINDOW}. - */ - protected abstract void setVisibleImpl(boolean visible, int x, int y, int width, int height); + public static final int FLAG_CHANGE_PARENTING = 1 << 0; + public static final int FLAG_CHANGE_DECORATION = 1 << 1; + public static final int FLAG_CHANGE_FULLSCREEN = 1 << 2; + public static final int FLAG_CHANGE_VISIBILITY = 1 << 3; + public static final int FLAG_HAS_PARENT = 1 << 4; + public static final int FLAG_IS_UNDECORATED = 1 << 5; + public static final int FLAG_IS_FULLSCREEN = 1 << 6; + public static final int FLAG_IS_VISIBLE = 1 << 7; /** * The native implementation should invoke the referenced java state callbacks * to notify this Java object of state changes. * - * @param x -1 if no position change requested, otherwise greater than zero - * @param y -1 if no position change requested, otherwise greater than zero - * @param width 0 if no size change requested, otherwise greater than zero - * @param height 0 if no size change requested, otherwise greater than zero - * @param parentChange true if reparenting requested, otherwise false - * @param fullScreenChange 0 if unchanged, -1 fullscreen off, 1 fullscreen on - * @param decorationChange 0 if unchanged, -1 undecorated, 1 decorated + * <p> + * Implementations shall set x/y to 0, in case it's negative. This could happen due + * to insets and positioning a decorated window to 0/0, which would place the frame + * outside of the screen.</p> + * + * @param x client-area position + * @param y client-area position + * @param width client-area size + * @param height client-area size + * @param flags bitfield of change and status flags * * @see #sizeChanged(int,int) * @see #positionChanged(int,int) */ - protected abstract boolean reconfigureWindowImpl(int x, int y, int width, int height, - boolean parentChange, int fullScreenChange, int decorationChange); + protected abstract boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags); + + protected int getReconfigureFlags(int changeFlags, boolean visible) { + return changeFlags |= ( ( 0 != getParentWindowHandle() ) ? FLAG_HAS_PARENT : 0 ) | + ( isUndecorated() ? FLAG_IS_UNDECORATED : 0 ) | + ( isFullscreen() ? FLAG_IS_FULLSCREEN : 0 ) | + ( visible ? FLAG_IS_VISIBLE : 0 ) ; + } + protected static String getReconfigureFlagsAsString(StringBuffer sb, int flags) { + if(null == sb) { sb = new StringBuffer(); } + sb.append("["); + + if( 0 != ( FLAG_CHANGE_PARENTING & flags) ) { + sb.append("*"); + } + sb.append("PARENT_"); + sb.append(0 != ( FLAG_HAS_PARENT & flags)); + sb.append(", "); + + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + sb.append("*"); + } + sb.append("FS_"); + sb.append(0 != ( FLAG_IS_FULLSCREEN & flags)); + sb.append(", "); + if( 0 != ( FLAG_CHANGE_DECORATION & flags) ) { + sb.append("*"); + } + sb.append("UNDECOR_"); + sb.append(0 != ( FLAG_IS_UNDECORATED & flags)); + sb.append(", "); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + sb.append("*"); + } + sb.append("VISIBLE_"); + sb.append(0 != ( FLAG_IS_VISIBLE & flags)); + + sb.append("]"); + return sb.toString(); + } + protected void setTitleImpl(String title) {} /** @@ -679,7 +724,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer runOnEDTIfAvail(true, new VisibleAction(visible)); } } - + + protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); + } + private class SetSizeActionImpl implements Runnable { int width, height; @@ -706,7 +755,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.height = height; } else if ( 0 != windowHandle ) { // this width/height will be set by windowChanged, called by the native implementation - reconfigureWindowImpl(x, y, width, height, false, 0, 0); + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(0, isVisible())); } else { WindowImpl.this.width = width; WindowImpl.this.height = height; @@ -969,7 +1018,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Case: Top Window - if( 0 == getParentWindowHandle() ) { + if( 0 == parentWindowHandle ) { // Already Top Window reparentAction = ACTION_UNCHANGED; } else if( !isNativeValid() || DEBUG_TEST_REPARENT_INCOMPATIBLE || forceDestroyCreate ) { @@ -1024,12 +1073,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Lock parentWindow only during reparenting (attempt) - NativeWindow parentWindowLocked = null; + final NativeWindow parentWindowLocked; if( null != parentWindow ) { parentWindowLocked = parentWindow; if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); } + } else { + parentWindowLocked = null; } boolean ok = false; try { @@ -1038,36 +1089,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.y = y; WindowImpl.this.width = width; WindowImpl.this.height = height; - ok = reconfigureWindowImpl(x, y, width, height, true, 0, isUndecorated()?-1:1); + ok = reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_PARENTING | FLAG_CHANGE_DECORATION, isVisible())); } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface(); } } - // set visible again, and revalidate 'ok', - // since it has been experienced that in some cases the reparented window gets hidden + // set visible again if(ok) { display.dispatchMessagesNative(); // status up2date if(wasVisible) { setVisibleImpl(true, x, y, width, height); ok = WindowImpl.this.waitForVisible(true, false); display.dispatchMessagesNative(); // status up2date - if( ok && - ( WindowImpl.this.x != x || - WindowImpl.this.y != y || - WindowImpl.this.width != width || - WindowImpl.this.height != height ) ) - { - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent (reconfig)"); - } - // reset pos/size .. due to some native impl flakyness - reconfigureWindowImpl(x, y, width, height, false, 0, 0); - display.dispatchMessagesNative(); // status up2date - WindowImpl.this.waitForVisible(true, false); - display.dispatchMessagesNative(); // status up2date - } } } @@ -1086,7 +1121,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - // write back mirrored values, ensuring persitence + // write back mirrored values, ensuring persistence // and not relying on native messaging WindowImpl.this.x = x; WindowImpl.this.y = y; @@ -1184,10 +1219,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer windowLock.lock(); try { if(WindowImpl.this.undecorated != undecorated) { + final boolean nativeUndecorationChange = !fullscreen && isNativeValid() && + isUndecorated() != undecorated ; + // set current state WindowImpl.this.undecorated = undecorated; - if( !fullscreen && isNativeValid() ) { + if( nativeUndecorationChange) { // Change decoration on active window // Mirror pos/size so native change notification can get overwritten @@ -1199,28 +1237,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 != windowHandle ) { DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date - boolean wasVisible = isVisible(); - setVisibleImpl(false, x, y, width, height); - WindowImpl.this.waitForVisible(false, true); - display.dispatchMessagesNative(); // status up2date - reconfigureWindowImpl(x, y, width, height, false, 0, undecorated?-1:1); - display.dispatchMessagesNative(); // status up2date - if(wasVisible) { - setVisibleImpl(true, x, y, width, height); - WindowImpl.this.waitForVisible(true, true); - display.dispatchMessagesNative(); // status up2date - if( WindowImpl.this.x != x || - WindowImpl.this.y != y || - WindowImpl.this.width != width || - WindowImpl.this.height != height ) - { - // reset pos/size .. due to some native impl flakyness - reconfigureWindowImpl(x, y, width, height, false, 0, 0); - display.dispatchMessagesNative(); // status up2date - } - requestFocusImpl(true); - display.dispatchMessagesNative(); // status up2date - } + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_DECORATION, isVisible())); + display.dispatchMessagesNative(); // status up2date } } } @@ -1324,7 +1342,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // protected final long getParentWindowHandle() { - return parentWindowHandle; + return isFullscreen() ? 0 : parentWindowHandle; } @Override @@ -1431,7 +1449,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!fullscreen) { if(0!=windowHandle) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system - reconfigureWindowImpl(x, y, 0, 0, false, 0, 0); + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(0, isVisible())); } else { WindowImpl.this.x = x; WindowImpl.this.y = y; @@ -1468,13 +1486,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x,y,w,h; WindowImpl.this.fullscreen = fullscreen; if(fullscreen) { + nfs_x = WindowImpl.this.x; + nfs_y = WindowImpl.this.y; + nfs_width = WindowImpl.this.width; + nfs_height = WindowImpl.this.height; x = 0; y = 0; w = screen.getWidth(); h = screen.getHeight(); - nfs_width = width; - nfs_height = height; - nfs_x = x; - nfs_y = y; } else { x = nfs_x; y = nfs_y; @@ -1497,26 +1515,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.y = y; WindowImpl.this.width = w; WindowImpl.this.height = h; - reconfigureWindowImpl(x, y, w, h, getParentWindowHandle()!=0, fullscreen?1:-1, isUndecorated()?-1:1); + reconfigureWindowImpl(x, y, width, height, + getReconfigureFlags( ( ( 0 != parentWindowHandle ) ? FLAG_CHANGE_PARENTING : 0 ) | + FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); display.dispatchMessagesNative(); // status up2date if(wasVisible) { setVisibleImpl(true, x, y, w, h); - boolean ok = WindowImpl.this.waitForVisible(true, true, Screen.SCREEN_MODE_CHANGE_TIMEOUT); + WindowImpl.this.waitForVisible(true, true, Screen.SCREEN_MODE_CHANGE_TIMEOUT); display.dispatchMessagesNative(); // status up2date - if( ok && - ( WindowImpl.this.x != x || - WindowImpl.this.y != y || - WindowImpl.this.width != w || - WindowImpl.this.height != h ) ) - { - if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { - System.err.println("Window fs (reconfig): "+x+"/"+y+" "+w+"x"+h+", "+screen); - } - // reset pos/size .. due to some native impl flakyness - reconfigureWindowImpl(x, y, w, h, false, 0, 0); - display.dispatchMessagesNative(); // status up2date - } requestFocusImpl(true); display.dispatchMessagesNative(); // status up2date if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { @@ -2093,7 +2100,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - + /** Triggered by implementation's WM events to update the position. */ protected void positionChanged(int newX, int newY) { if( 0==parentWindowHandle && ( x != newX || y != newY ) ) { @@ -2113,16 +2120,21 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #updateInsetsImpl(Insets) */ protected void insetsChanged(int left, int right, int top, int bottom) { - if ( left >= 0 && right >= 0 && top >= 0 && bottom >= 0 && - (left != insets.getLeftWidth() || right != insets.getRightWidth() || - top != insets.getTopHeight() || bottom != insets.getBottomHeight() ) - ) { - insets.setLeftWidth(left); - insets.setRightWidth(right); - insets.setTopHeight(top); - insets.setBottomHeight(bottom); - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.insetsChanged: "+insets); + if ( left >= 0 && right >= 0 && top >= 0 && bottom >= 0 ) { + if(isUndecorated()) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.insetsChanged: skip insets change for undecoration mode"); + } + } else if ( (left != insets.getLeftWidth() || right != insets.getRightWidth() || + top != insets.getTopHeight() || bottom != insets.getBottomHeight() ) + ) { + insets.setLeftWidth(left); + insets.setRightWidth(right); + insets.setTopHeight(top); + insets.setBottomHeight(bottom); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.insetsChanged: "+insets); + } } } } diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index cbe343f2c..83f306b46 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -30,14 +30,12 @@ package jogamp.newt.driver.android; import java.nio.IntBuffer; -import jogamp.newt.WindowImpl; import jogamp.newt.driver.android.event.AndroidNewtEventFactory; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.egl.EGLGraphicsDevice; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLException; import com.jogamp.common.nio.Buffers; import com.jogamp.newt.event.MouseEvent; @@ -46,17 +44,13 @@ import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLGraphicsConfiguration; import android.content.Context; -import android.graphics.Canvas; import android.graphics.PixelFormat; import android.util.Log; -import android.view.MotionEvent; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback2; import android.view.SurfaceView; import android.view.View; -import android.view.View.OnClickListener; -import android.view.View.OnTouchListener; public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { static { @@ -156,18 +150,12 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { return eglSurface; } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - reconfigureWindowImpl(x, y, width, height, false, 0, 0); - visibleChanged(visible); - } - protected void requestFocusImpl(boolean reparented) { } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, - boolean parentChange, int fullScreenChange, int decorationChange) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if(0!=getWindowHandle()) { - if(0!=fullScreenChange) { - if( fullScreenChange > 0 ) { + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { System.err.println("reconfigureWindowImpl.setFullscreen n/a"); return false; } @@ -183,6 +171,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { System.err.println("reconfigureWindowImpl.setPos n/a"); return false; } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } return true; } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java index 3ed0c758d..4ab12bbc8 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java @@ -155,20 +155,6 @@ public class AWTWindow extends WindowImpl { return res; } - protected void setVisibleImpl(final boolean visible, int x, int y, int width, int height) { - container.setVisible(visible); - - reconfigureWindowImpl(x, y, width, height, false, 0, 0); - config = canvas.getAWTGraphicsConfiguration(); - - if (config == null) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - - updateDeviceData(); - visibleChanged(visible); - } - private void updateDeviceData() { // propagate new info .. ((AWTScreen)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)config.getScreen()); @@ -189,8 +175,12 @@ public class AWTWindow extends WindowImpl { insets.setBottomHeight(contInsets.bottom); } - protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final boolean parentChange, final int fullScreenChange, final int decorationChange) { - if(decorationChange!=0 && null!=frame) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); + } + + if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) { if(!container.isDisplayable()) { frame.setUndecorated(isUndecorated()); } else { @@ -199,15 +189,27 @@ public class AWTWindow extends WindowImpl { } } } - int _x=(x>=0)?x:AWTWindow.this.x; - int _y=(x>=0)?y:AWTWindow.this.y; - int _w=(width>0)?width:AWTWindow.this.width; - int _h=(height>0)?height:AWTWindow.this.height; + x=(x>=0)?x:AWTWindow.this.x; + y=(x>=0)?y:AWTWindow.this.y; + width=(width>0)?width:AWTWindow.this.width; + height=(height>0)?height:AWTWindow.this.height; - container.setLocation(_x, _y); + container.setLocation(x, y); Insets insets = container.getInsets(); - container.setSize(_w + insets.left + insets.right, - _h + insets.top + insets.bottom); + container.setSize(width + insets.left + insets.right, + height + insets.top + insets.bottom); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + config = canvas.getAWTGraphicsConfiguration(); + + if (config == null) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + + updateDeviceData(); + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; } diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java index 0a7f63a82..431ac934b 100644 --- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java +++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java @@ -72,11 +72,6 @@ public class Window extends jogamp.newt.WindowImpl { } } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - reconfigureWindowImpl(x, y, width, height, false, 0, 0); - visibleChanged(visible); - } - protected void requestFocusImpl(boolean reparented) { } protected void setSizeImpl(int width, int height) { @@ -89,11 +84,10 @@ public class Window extends jogamp.newt.WindowImpl { } } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, - boolean parentChange, int fullScreenChange, int decorationChange) { - if(0!=getWindowHandle()) { - if(0!=fullScreenChange) { - if( fullScreenChange > 0 ) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(0!=getWindowHandle()) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { // n/a in BroadcomEGL System.err.println("setFullscreen n/a in BroadcomEGL"); return false; @@ -112,6 +106,10 @@ public class Window extends jogamp.newt.WindowImpl { if(x>=0 || y>=0) { System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } return true; } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java index 5e312f24d..05833e93b 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java @@ -80,39 +80,38 @@ public class Window extends jogamp.newt.WindowImpl { } } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - reconfigureWindowImpl(x, y, width, height, false, 0, 0); - if(visible) { - ((Display)getScreen().getDisplay()).setFocus(this); - } - this.visibleChanged(visible); - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, boolean parentChange, int fullScreenChange, int decorationChange) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { Screen screen = (Screen) getScreen(); - int _x=(x>=0)?x:this.x; - int _y=(x>=0)?y:this.y; - int _w=(width>0)?width:this.width; - int _h=(height>0)?height:this.height; + x=(x>=0)?x:this.x; + y=(x>=0)?y:this.y; + width=(width>0)?width:this.width; + height=(height>0)?height:this.height; - if(_w>screen.getWidth()) { - _w=screen.getWidth(); + if(width>screen.getWidth()) { + width=screen.getWidth(); } - if(_h>screen.getHeight()) { - _h=screen.getHeight(); + if(height>screen.getHeight()) { + height=screen.getHeight(); } - if((_x+_w)>screen.getWidth()) { - _x=screen.getWidth()-_w; + if((x+width)>screen.getWidth()) { + x=screen.getWidth()-width; } - if((_y+_h)>screen.getHeight()) { - _y=screen.getHeight()-_h; + if((y+height)>screen.getHeight()) { + y=screen.getHeight()-height; } if(0!=surfaceHandle) { - SetBounds0(surfaceHandle, getScreen().getWidth(), getScreen().getHeight(), _x, _y, _w, _h); + SetBounds0(surfaceHandle, getScreen().getWidth(), getScreen().getHeight(), x, y, width, height); } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if(0 != ( FLAG_IS_VISIBLE & flags)) { + ((Display)getScreen().getDisplay()).setFocus(this); + } + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; } diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java index f63233b37..d94538545 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java +++ b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java @@ -34,6 +34,7 @@ package jogamp.newt.driver.kd; import jogamp.newt.*; +import jogamp.newt.driver.intel.gdl.Display; import jogamp.opengl.egl.*; import javax.media.nativewindow.*; import javax.media.nativewindow.util.Insets; @@ -82,19 +83,17 @@ public class KDWindow extends WindowImpl { } } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - setVisible0(eglWindowHandle, visible); - reconfigureWindowImpl(x, y, width, height, false, 0, 0); - visibleChanged(visible); - } - protected void requestFocusImpl(boolean reparented) { } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, - boolean parentChange, int fullScreenChange, int decorationChange) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } + if(0!=eglWindowHandle) { - if(0!=fullScreenChange) { - boolean fs = fullScreenChange > 0; + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; setFullScreen0(eglWindowHandle, fs); if(fs) { return true; @@ -102,15 +101,20 @@ public class KDWindow extends WindowImpl { } // int _x=(x>=0)?x:this.x; // int _y=(x>=0)?y:this.y; - int _w=(width>0)?width:this.width; - int _h=(height>0)?height:this.height; + width=(width>0)?width:this.width; + height=(height>0)?height:this.height; if(width>0 || height>0) { - setSize0(eglWindowHandle, _w, _h); + setSize0(eglWindowHandle, width, height); } if(x>=0 || y>=0) { System.err.println("setPosition n/a in KD"); } } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index c38c83972..433fc5e2c 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -183,25 +183,6 @@ public class MacWindow extends WindowImpl { nsViewLock.unlock(); } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - nsViewLock.lock(); - try { - if (visible) { - createWindow(false, x, y, width, height, isFullscreen()); - if (getWindowHandle() != 0) { - makeKeyAndOrderFront0(getWindowHandle()); - } - } else { - if (getWindowHandle() != 0) { - orderOut0(getWindowHandle()); - } - } - visibleChanged(visible); - } finally { - nsViewLock.unlock(); - } - } - @Override protected void setTitleImpl(final String title) { // FIXME: move nsViewLock up to window lock @@ -223,28 +204,41 @@ public class MacWindow extends WindowImpl { } } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, boolean parentChange, int fullScreenChange, int decorationChange) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { nsViewLock.lock(); try { - if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { - System.err.println("MacWindow reconfig: parentChange "+parentChange+", fullScreenChange "+fullScreenChange+", decorationChange "+decorationChange+" "+x+"/"+y+" "+width+"x"+height); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); } - int _x=(x>=0)?x:this.x; - int _y=(x>=0)?y:this.y; - int _w=(width>0)?width:this.width; - int _h=(height>0)?height:this.height; - - if(decorationChange!=0 || parentChange || fullScreenChange!=0) { - createWindow(true, _x, _y, _w, _h, fullScreenChange>0); - if (getWindowHandle() != 0) { - makeKeyAndOrderFront0(getWindowHandle()); - } - } else { - if(x>=0 || y>=0) { - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), _x, _y); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if (0 != ( FLAG_IS_VISIBLE & flags)) { + createWindow(false, x, y, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + if (getWindowHandle() != 0) { + makeKeyAndOrderFront0(getWindowHandle()); + } + } else { + if (getWindowHandle() != 0) { + orderOut0(getWindowHandle()); + } } - if(width>0 || height>0) { - setContentSize0(getWindowHandle(), _w, _h); + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } else { + if( 0 != ( FLAG_CHANGE_DECORATION & flags) || + 0 != ( FLAG_CHANGE_PARENTING & flags) || + 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + createWindow(true, x, y, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + if (getWindowHandle() != 0) { + makeKeyAndOrderFront0(getWindowHandle()); + } + } else { + if(x>=0 || y>=0) { + setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), x, y); + } + if(width>0 || height>0) { + setContentSize0(getWindowHandle(), width, height); + } } } } finally { @@ -353,12 +347,19 @@ public class MacWindow extends WindowImpl { super.enqueueKeyEvent(wait, eventType, modifiers, key, keyChar); } - private void createWindow(final boolean recreate, final int x, final int y, final int width, final int height, final boolean fullscreen) { + private void createWindow(final boolean recreate, + int x, int y, int width, int height, + final boolean fullscreen) { if(0!=getWindowHandle() && !recreate) { return; } + x=(x>=0)?x:this.x; + y=(x>=0)?y:this.y; + width=(width>0)?width:this.width; + height=(height>0)?height:this.height; + try { //runOnEDTIfAvail(true, new Runnable() { // public void run() { diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java index d6ca64d24..1b33900a4 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java @@ -39,6 +39,7 @@ import jogamp.newt.WindowImpl; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; public class WindowsWindow extends WindowImpl { @@ -109,7 +110,7 @@ public class WindowsWindow extends WindowImpl { throw new NativeWindowException("Error creating window"); } windowHandleClose = getWindowHandle(); - if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { + if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ " (Parent HWND "+toHexString(getParentWindowHandle())+ ") : HWND "+toHexString(getWindowHandle())+", "+Thread.currentThread()); @@ -145,15 +146,30 @@ public class WindowsWindow extends WindowImpl { } } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - setVisible0(getWindowHandle(), visible, (getParentWindowHandle()==0)?true:false, x, y, width, height); - visibleChanged(visible); - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, - boolean parentChange, int fullScreenChange, int decorationChange) { - reconfigureWindow0( (fullScreenChange>0)?0:getParentWindowHandle(), - getWindowHandle(), x, y, width, height, isVisible(), parentChange, fullScreenChange, decorationChange); + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); + } + + if(0 == ( FLAG_IS_UNDECORATED & flags)) { + final InsetsImmutable i = getInsets(); + + // client position -> top-level window position + x -= i.getLeftWidth() ; + y -= i.getTopHeight() ; + if( 0 > x ) { x = 0; } + if( 0 > y ) { y = 0; } + + // client size -> top-level window size + width += i.getTotalWidth(); + height += i.getTotalHeight(); + } + reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + } return true; } @@ -184,10 +200,8 @@ public class WindowsWindow extends WindowImpl { long parentWindowHandle, long visualID, boolean isUndecorated, int x, int y, int width, int height); private native long MonitorFromWindow0(long windowHandle); - private native void setVisible0(long windowHandle, boolean visible, boolean top, int x, int y, int width, int height); - private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, - int x, int y, int width, int height, boolean isVisible, - boolean parentChange, int fullScreenChange, int decorationChange); + private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, + int x, int y, int width, int height, int flags); private static native void setTitle0(long windowHandle, String title); private native void requestFocus0(long windowHandle, boolean force); diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java index 265bec898..8e2e823e4 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java @@ -38,6 +38,7 @@ import jogamp.newt.WindowImpl; import javax.media.nativewindow.*; import javax.media.nativewindow.x11.*; import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; public class X11Window extends WindowImpl { @@ -92,18 +93,26 @@ public class X11Window extends WindowImpl { } } - protected void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - setVisible0(getDisplayEDTHandle(), getWindowHandle(), visible, x, y, width, height); - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, - boolean parentChange, int fullScreenChange, int decorationChange) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); + } reparentHandle=0; reparentCount=0; - long reqNewParentHandle = ( fullScreenChange > 0 ) ? 0 : getParentWindowHandle() ; - reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), reqNewParentHandle, getWindowHandle(), - x, y, width, height, isVisible(), parentChange, fullScreenChange, decorationChange); + if(0 == ( FLAG_IS_UNDECORATED & flags)) { + final InsetsImmutable i = getInsets(); + + // client position -> top-level window position + x -= i.getLeftWidth() ; + y -= i.getTopHeight() ; + if( 0 > x ) { x = 0; } + if( 0 > y ) { y = 0; } + } + reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), getParentWindowHandle(), getWindowHandle(), + x, y, width, height, flags); + return true; } @@ -121,7 +130,7 @@ public class X11Window extends WindowImpl { } protected void updateInsetsImpl(Insets insets) { - // TODO !! + // nop - using event driven insetsChange(..) } //---------------------------------------------------------------------- @@ -137,13 +146,10 @@ public class X11Window extends WindowImpl { long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height, boolean undecorated); private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom); - private native void setVisible0(long display, long windowHandle, boolean visible, int x, int y, int width, int height); - private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, - int x, int y, int width, int height, boolean isVisible, - boolean parentChange, int fullScreenChange, int decorationChange); + private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, + int x, int y, int width, int height, int flags); private native void setTitle0(long display, long windowHandle, String title); private native void requestFocus0(long display, long windowHandle, boolean force); - private native Object getRelativeLocation0(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y); private void windowReparented(long gotParentHandle) { reparentHandle = gotParentHandle; |