From fb57c652fee6be133990cd7afbbd2fdfc084afaa Mon Sep 17 00:00:00 2001
From: Sven Gothel
* If no coverage is detected the first {@link MonitorDevice} is returned.
*
* Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()},
* however, some native toolkits may choose a different virtual screen area.
@@ -257,7 +258,7 @@ public abstract class Screen {
synchronized(screenList) {
int i = fromIndex >= 0 ? fromIndex : screenList.size() - 1 ;
while( ( incr > 0 ) ? i < screenList.size() : i >= 0 ) {
- final Screen screen = (Screen) screenList.get(i).get();
+ final Screen screen = screenList.get(i).get();
if( null == screen ) {
// Clear GC'ed dead reference entry!
screenList.remove(i);
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index 9cf67c56f..b733406e8 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -46,6 +46,7 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeWindow;
import javax.media.nativewindow.WindowClosingProtocol;
+import javax.media.nativewindow.util.Point;
import javax.media.nativewindow.util.RectangleImmutable;
/**
@@ -251,10 +252,37 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
* @param width of the window's client area in window units
* @param height of the window's client area in window units
*
+ * @see #setSurfaceSize(int, int)
+ * @see #setTopLevelSize(int, int)
* @see #getInsets()
*/
void setSize(int width, int height);
+ /**
+ * Sets the size of the window's surface in pixel units which claims the window's client area excluding decorations.
+ *
+ *
+ * Zero size semantics are respected, see {@link #setVisible(boolean)}:true
if given coordinates are contained by this {@link #getViewport() viewport}, otherwise false
. */
+ /**
+ * Returns true
if given screen coordinates in screen/window units
+ * are contained by this {@link #getViewport() viewport}, otherwise false
.
+ */
public final boolean contains(int x, int y) {
return x >= viewport.getX() &&
x < viewport.getX() + viewport.getWidth() &&
diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java
index 3b31861f0..4443c70c9 100644
--- a/src/newt/classes/com/jogamp/newt/NewtFactory.java
+++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java
@@ -296,7 +296,7 @@ public class NewtFactory {
}
final Window win = WindowImpl.create(parentWindow, 0, screen, caps);
- win.setSize(parentWindow.getSurfaceWidth(), parentWindow.getSurfaceHeight());
+ win.setSize(parentWindow.getWindowWidth(), parentWindow.getWindowHeight());
if ( null != newtParentWindow ) {
newtParentWindow.addChild(win);
win.setVisible(newtParentWindow.isVisible());
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index ef62ec95d..2a713c538 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -131,27 +131,27 @@ public abstract class Screen {
public abstract int getIndex();
/**
- * @return the x position of the virtual viewport's top-left origin.
+ * @return the x position of the virtual viewport's top-left origin in screen/window units.
*/
public abstract int getX();
/**
- * @return the y position of the virtual viewport's top-left origin.
+ * @return the y position of the virtual viewport's top-left origin in screen/window units.
*/
public abstract int getY();
/**
- * @return the rotated virtual viewport's width.
+ * @return the rotated virtual viewport's width in screen/window units.
*/
public abstract int getWidth();
/**
- * @return the rotated virtual viewport's height.
+ * @return the rotated virtual viewport's height in screen/window units.
*/
public abstract int getHeight();
/**
- * @return the rotated virtual viewport, i.e. origin and size.
+ * @return the rotated virtual viewport, i.e. origin and size in screen/window units.
*/
public abstract RectangleImmutable getViewport();
@@ -186,6 +186,7 @@ public abstract class Screen {
*
+ *
+ * if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) {
+ * setVisible(false);
+ * } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) {
+ * setVisible(true);
+ * } else {
+ * // as expected ..
+ * }
+ *
+ * This call is ignored if in fullscreen mode.
* Since the position reflects the client area, it does not include the insets. *
@@ -722,7 +722,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected abstract Point getLocationOnScreenImpl(int x, int y); - /** Triggered by user via {@link #getInsets()}.* This methods issues {@link android.view.Window#setContentView(android.view.View, android.view.ViewGroup.LayoutParams) androidWindow.setContenView(newtWindow.getAndroidView())} * and finally calls {@link #registerNEWTWindow(Window)}. - *
+ * * @param androidWindow * @param newtWindow * @throws IllegalArgumentException if thenewtWindow
's {@link Window#getDelegatedWindow() delegate} is not an AndroidDriver.
@@ -128,7 +128,7 @@ public class NewtBaseActivity extends Activity {
final WindowDriver newtAWindow = (WindowDriver)delegateWindow;
androidWindow.setContentView(newtAWindow.getAndroidView());
} else {
- throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass().getName());
+ throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass().getName());
}
registerNEWTWindow(newtWindow);
}
@@ -137,7 +137,7 @@ public class NewtBaseActivity extends Activity {
* * This methods issues {@link android.view.Window#addContentView(android.view.View, android.view.ViewGroup.LayoutParams) androidWindow.addContenView(newtWindow.getAndroidView(), params)} * and finally calls {@link #registerNEWTWindow(Window)}. - *
+ * * @param androidWindow * @param newtWindow * @param params @@ -151,8 +151,8 @@ public class NewtBaseActivity extends Activity { final WindowDriver newtAWindow = (WindowDriver)delegateWindow; androidWindow.addContentView(newtAWindow.getAndroidView(), params); } else { - throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName()); - } + throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName()); + } registerNEWTWindow(newtWindow); } /** @@ -161,15 +161,15 @@ public class NewtBaseActivity extends Activity { * This methods registers the given NEWT window to ensure it's destruction at {@link #onDestroy()}. * *- * If adding a {@link GLAutoDrawable} implementation, the {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()} + * If adding a {@link GLAutoDrawable} implementation, the {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()} * will be used for {@link #onPause()} and {@link #onResume()}. *
*- * If adding a {@link GLAutoDrawable} implementation, the {@link GLEventListenerState} will preserve it's state - * when {@link #onPause()} is being called while not {@link #isFinishing()}. A later {@link #onResume()} will + * If adding a {@link GLAutoDrawable} implementation, the {@link GLEventListenerState} will preserve it's state + * when {@link #onPause()} is being called while not {@link #isFinishing()}. A later {@link #onResume()} will * reinstate the {@link GLEventListenerState}. *
- * + * * @param newtWindow * @throws IllegalArgumentException if thenewtWindow
's {@link Window#getDelegatedWindow() delegate} is not an AndroidDriver.
* @see #setContentView(android.view.Window, Window)
@@ -182,8 +182,8 @@ public class NewtBaseActivity extends Activity {
final WindowDriver newtAWindow = (WindowDriver)delegateWindow;
newtAWindow.registerActivity(getActivity());
} else {
- throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName());
- }
+ throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName());
+ }
newtWindows.add(newtWindow);
if(newtWindow instanceof GLAutoDrawable) {
glAutoDrawables.add((GLAutoDrawable)newtWindow);
@@ -203,9 +203,9 @@ public class NewtBaseActivity extends Activity {
startAnimation(true);
}
};
-
+
/**
- * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window.
+ * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window.
* * Must be called before creating the view and adding any content, i.e. setContentView() ! *
@@ -216,7 +216,7 @@ public class NewtBaseActivity extends Activity { if(null == androidWindow || null == newtWindow) { throw new IllegalArgumentException("Android or NEWT Window null"); } - + if( newtWindow.isFullscreen() || newtWindow.isUndecorated() ) { androidWindow.requestFeature(android.view.Window.FEATURE_NO_TITLE); } @@ -225,16 +225,16 @@ public class NewtBaseActivity extends Activity { androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { androidWindow.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + } + + if(newtWindow.getWindowWidth()>0 && newtWindow.getWindowHeight()>0 && !newtWindow.isFullscreen()) { + androidWindow.setLayout(newtWindow.getWindowWidth(), newtWindow.getWindowHeight()); } - - if(newtWindow.getSurfaceWidth()>0 && newtWindow.getSurfaceHeight()>0 && !newtWindow.isFullscreen()) { - androidWindow.setLayout(newtWindow.getSurfaceWidth(), newtWindow.getSurfaceHeight()); - } } /** - * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window. + * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window. ** Must be called before creating the view and adding any content, i.e. setContentView() ! *
@@ -245,7 +245,7 @@ public class NewtBaseActivity extends Activity { if(null == androidWindow) { throw new IllegalArgumentException("Android or Window null"); } - + if( fullscreen ) { androidWindow.requestFeature(android.view.Window.FEATURE_NO_TITLE); androidWindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); @@ -255,9 +255,9 @@ public class NewtBaseActivity extends Activity { androidWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } - + /** - * Convenient method to set this context's theme to transparency depending on {@link CapabilitiesImmutable#isBackgroundOpaque()}. + * Convenient method to set this context's theme to transparency depending on {@link CapabilitiesImmutable#isBackgroundOpaque()}. ** Must be called before creating the view and adding any content, i.e. setContentView() ! *
@@ -267,7 +267,7 @@ public class NewtBaseActivity extends Activity { setTransparencyTheme(); } } - + /** * Convenient method to set this context's theme to transparency. *@@ -279,12 +279,12 @@ public class NewtBaseActivity extends Activity { *
** Can be called only once. - *
+ * */ public void setTransparencyTheme() { if(!setThemeCalled) { setThemeCalled = true; - final Context ctx = getActivity().getApplicationContext(); + final Context ctx = getActivity().getApplicationContext(); final String frn = ctx.getPackageName()+":style/Theme.Transparent"; final int resID = ctx.getResources().getIdentifier("Theme.Transparent", "style", ctx.getPackageName()); if(0 == resID) { @@ -295,14 +295,14 @@ public class NewtBaseActivity extends Activity { } } } - + /** * Setting up a global {@Link GLAnimatorControl} for {@link #onPause()} and {@link #onResume()}. ** Note that if adding a {@link GLAutoDrawable} implementation via {@link #registerNEWTWindow(Window)}, * {@link #setContentView(android.view.Window, Window)} or {@link #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams)} * their {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()} will be used as well. - * In this case, using this global {@Link GLAnimatorControl} is redundant. + * In this case, using this global {@Link GLAnimatorControl} is redundant. *
* @see #registerNEWTWindow(Window) * @see #setContentView(android.view.Window, Window) @@ -315,7 +315,7 @@ public class NewtBaseActivity extends Activity { } animator.pause(); } - + @Override public android.view.Window getWindow() { if( isDelegatedActivity() ) { @@ -324,22 +324,22 @@ public class NewtBaseActivity extends Activity { return super.getWindow(); } } - + @Override public void onCreate(Bundle savedInstanceState) { Log.d(MD.TAG, "onCreate.0"); if(!isDelegatedActivity()) { super.onCreate(savedInstanceState); } - // Extraordinary cleanup, for cases of 'onCreate()' calls w/ valid states, + // Extraordinary cleanup, for cases of 'onCreate()' calls w/ valid states, // i.e. w/o having onDestroy() being called. // Could happened due to spec when App process is killed for memory exhaustion or other reasons. cleanup(); - + jogamp.common.os.android.StaticContext.init(rootActivity.getApplicationContext()); Log.d(MD.TAG, "onCreate.X"); } - + @Override public void onStart() { Log.d(MD.TAG, "onStart.0"); @@ -348,7 +348,7 @@ public class NewtBaseActivity extends Activity { } Log.d(MD.TAG, "onStart.X"); } - + @Override public void onRestart() { Log.d(MD.TAG, "onRestart.0"); @@ -407,11 +407,11 @@ public class NewtBaseActivity extends Activity { win.setVisible(false); } if( !isDelegatedActivity() ) { - super.onStop(); + super.onStop(); } Log.d(MD.TAG, "onStop.X"); } - + /** * Performs cleaning up all references, *
@@ -450,14 +450,14 @@ public class NewtBaseActivity extends Activity {
jogamp.common.os.android.StaticContext.clear();
Log.d(MD.TAG, "cleanup.X");
}
-
+
@Override
public void onDestroy() {
Log.d(MD.TAG, "onDestroy.0");
cleanup(); // normal cleanup
if(!isDelegatedActivity()) {
- super.onDestroy();
+ super.onDestroy();
}
Log.d(MD.TAG, "onDestroy.X");
- }
+ }
}
diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java
index 20163f96c..93ff0c1e0 100644
--- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java
@@ -304,7 +304,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 {
if(null == androidView) {
setupAndroidView( StaticContext.getContext() );
}
- viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getSurfaceWidth(), getSurfaceHeight(), Gravity.BOTTOM|Gravity.RIGHT));
+ viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getWindowWidth(), getWindowHeight(), Gravity.BOTTOM|Gravity.RIGHT));
Log.d(MD.TAG, "canCreateNativeImpl: added to static ViewGroup - on thread "+Thread.currentThread().getName());
} });
for(long sleep = TIMEOUT_NATIVEWINDOW; 0