diff options
author | Sven Gothel <sgothel@jausoft.com> | 2011-10-06 05:51:48 +0200 |
---|---|---|
committer | Sven Gothel <sgothel@jausoft.com> | 2011-10-06 05:51:48 +0200 |
commit | fa7627f623141c6fa15856c74d26c8ffe82550d0 (patch) | |
tree | ea9b5f64c3a879f2c6078dd81cbdd739b1a871a2 /src/newt/classes | |
parent | 51f84125beb4ac50fedab9fe691225b234b12bc6 (diff) |
NEWT/Android: respect isUndecorated() and custom window size.
TODO: custom position and change position ?!
Diffstat (limited to 'src/newt/classes')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index 2c7031dae..cd3cb489f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -175,13 +175,23 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { // statement if back-porting this code to older SDKs. // sh.setType(SurfaceHolder.SURFACE_TYPE_GPU); // sh.setType(SurfaceHolder.SURFACE_TYPE_NORMAL); + + // default size -> TBD ! + this.width = 0; + this.height = 0; } public SurfaceView getAndroidView() { return androidView; } public void setAndroidWindow(android.view.Window window) { + System.err.println("setandroidWindow: "+window+", "+width+"x"+height); androidWindow = window; - androidSetupFullscreen(); + androidWindowConfigurationPreCreate(); + if(width>0 && height>0 && !isFullscreen()) { + if(null != androidWindow) { + androidWindow.setLayout(width, height); + } + } } public android.view.Window getAndroidWindow() { return androidWindow; } @@ -249,11 +259,15 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { protected void requestFocusImpl(boolean reparented) { } - protected void androidSetupFullscreen() { - if( null != androidWindow && isFullscreen() ) { - androidWindow.requestFeature(Window.FEATURE_NO_TITLE); - androidWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); + protected void androidWindowConfigurationPreCreate() { + if( null != androidWindow) { + if( isFullscreen() || isUndecorated() ) { + androidWindow.requestFeature(Window.FEATURE_NO_TITLE); + } + if( isFullscreen() ) { + androidWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + } } } @@ -315,8 +329,6 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { public void surfaceCreated(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceCreated: "+x+"/"+y+" "+width+"x"+height); - // surfaceRealized(holder); - Log.d(MD.TAG, "surfaceCreated: X"); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { @@ -333,43 +345,34 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { } getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event + if(0>x || 0>y) { + x = 0; + y = 0; + positionChanged(false, 0, 0); + } + if(0 == surfaceHandle) { - surfaceRealized(holder); - } else { - if(0>x || 0>y) { - x = 0; - y = 0; - positionChanged(false, 0, 0); + surface = holder.getSurface(); + surfaceHandle = getSurfaceHandle0(surface); + acquire0(surfaceHandle); + format = getSurfaceVisualID0(surfaceHandle); + capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); + sizeChanged(false, getWidth0(surfaceHandle), getHeight0(surfaceHandle), false); + + Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ + ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+ + ", "+x+"/"+y+" "+width+"x"+height+", visible: "+isVisible()); + + if(isVisible()) { + setVisible(true); } + } else { sizeChanged(false, width, height, false); } windowRepaint(0, 0, width, height); Log.d(MD.TAG, "surfaceChanged: X"); } - private void surfaceRealized(SurfaceHolder holder) { - surface = holder.getSurface(); - surfaceHandle = getSurfaceHandle0(surface); - acquire0(surfaceHandle); - format = getSurfaceVisualID0(surfaceHandle); - capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); - if(0>x || 0>y) { - x = 0; - y = 0; - positionChanged(false, 0, 0); - } - sizeChanged(false, getWidth0(surfaceHandle), getHeight0(surfaceHandle), false); - - Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ - ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+ - ", "+x+"/"+y+" "+width+"x"+height); - - if(isVisible()) { - setVisible(true); - } - Log.d(MD.TAG, "surfaceRealized: X"); - } - public void surfaceDestroyed(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceDestroyed"); windowDestroyNotify(); |