summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/Window.java9
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java43
-rw-r--r--src/newt/classes/jogamp/newt/DefaultEDTUtil.java2
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java194
4 files changed, 72 insertions, 176 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index b78f7a9e8..5b3d93eec 100644
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -109,19 +109,12 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
* which will issue {@link Screen#destroy()} if the reference count becomes 0.<br>
* This destruction sequence shall end up in {@link Display#destroy()}, if all reference counts become 0.
* </p>
- * @see #invalidate()
+ * @see #destroy()
* @see #setVisible(boolean)
*/
void destroy();
/**
- * Destroys the Window via {@link #destroy()} and clears all Object references,
- * eg. all states, size, position, parent handles, list of child Windows and reference to it's Screen.<br>
- * This Window cannot be recreated after calling this method anymore.<br>
- */
- void invalidate();
-
- /**
* <p>
* <code>setVisible</code> makes the window and children visible if <code>visible</code> is true,
* otherwise the window and children becomes invisible.<br></p>
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index bc0d67bfc..d8eda923a 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -341,28 +341,18 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
}
context = null;
drawable = null;
-
+
+ GLAnimatorControl ctrl = GLWindow.this.getAnimator();
+ if ( null!=ctrl ) {
+ ctrl.remove(GLWindow.this);
+ }
+ // helper=null; // pending events ..
+
if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
System.err.println("GLWindow.destroy() "+Thread.currentThread()+", fin");
}
}
- public synchronized void invalidate(boolean unrecoverable) {
- if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
- String msg = "GLWindow.invalidate("+unrecoverable+") "+Thread.currentThread()+", start";
- System.err.println(msg);
- //Exception e1 = new Exception(msg);
- //e1.printStackTrace();
- }
- if(unrecoverable) {
- GLAnimatorControl ctrl = GLWindow.this.getAnimator();
- if ( null!=ctrl ) {
- ctrl.remove(GLWindow.this);
- }
- helper=null;
- }
- }
-
public synchronized void resetCounter() {
if(Window.DEBUG_WINDOW_EVENT || Window.DEBUG_IMPLEMENTATION) {
System.err.println("GLWindow.resetCounter() "+Thread.currentThread());
@@ -407,19 +397,20 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
}
}
+ private GLAnimatorControl savedAnimator = null;
+
public synchronized boolean pauseRenderingAction() {
boolean animatorPaused = false;
- GLAnimatorControl ctrl = GLWindow.this.getAnimator();
- if ( null!=ctrl ) {
- animatorPaused = ctrl.pause();
+ savedAnimator = GLWindow.this.getAnimator();
+ if ( null != savedAnimator ) {
+ animatorPaused = savedAnimator.pause();
}
return animatorPaused;
}
public synchronized void resumeRenderingAction() {
- GLAnimatorControl ctrl = GLWindow.this.getAnimator();
- if ( null!=ctrl && ctrl.isPaused() ) {
- ctrl.resume();
+ if ( null != savedAnimator && savedAnimator.isPaused() ) {
+ savedAnimator.resume();
}
}
}
@@ -849,10 +840,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
return window.surfaceSwap();
}
- public final void invalidate() {
- window.invalidate();
- }
-
public final long getWindowHandle() {
return window.getWindowHandle();
@@ -917,7 +904,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
});
glWindow.setVisible(true);
- glWindow.invalidate();
+ glWindow.destroy();
}
}
diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
index 3b14f30fc..847407683 100644
--- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
+++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java
@@ -135,7 +135,7 @@ public class DefaultEDTUtil implements EDTUtil {
if(stop) {
edt.shouldStop = true;
if(DEBUG) {
- String msg = Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - edt: "+edt;
+ String msg = Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - tasks: "+edt.tasks.size()+" - "+edt;
System.err.println(msg);
// Throwable t = new Throwable(msg);
// t.printStackTrace();
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index cb1c0eda2..2286fdd00 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -75,16 +75,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private RecursiveLock windowLock = new RecursiveLock(); // Window instance wide lock
private RecursiveLock surfaceLock = new RecursiveLock(); // Surface only lock
- private long windowHandle;
- private ScreenImpl screen;
+ private long windowHandle = 0;
+ private ScreenImpl screen = null;
private boolean screenReferenceAdded = false;
- private NativeWindow parentWindow;
- private long parentWindowHandle;
- protected AbstractGraphicsConfiguration config;
- protected CapabilitiesImmutable capsRequested;
+ private NativeWindow parentWindow = null;
+ private long parentWindowHandle = 0;
+ protected AbstractGraphicsConfiguration config = null;
+ protected CapabilitiesImmutable capsRequested = null;
protected CapabilitiesChooser capabilitiesChooser = null; // default null -> default
- protected boolean fullscreen, visible, hasFocus;
- protected int width, height, x, y;
+ protected boolean fullscreen = false, visible = false, hasFocus = false;
+ protected int width = 128, height = 128, x = 0, y = 0; // default values
+
protected int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen dimensions ..
protected String title = "Newt Window";
protected boolean undecorated = false;
@@ -99,37 +100,23 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
private FocusRunnable focusAction = null;
private Object surfaceUpdatedListenersLock = new Object();
- private ArrayList surfaceUpdatedListeners;
+ private ArrayList surfaceUpdatedListeners = new ArrayList();
private Object childWindowsLock = new Object();
- private ArrayList childWindows;
+ private ArrayList childWindows = new ArrayList();
- private ArrayList mouseListeners;
- private int mouseButtonPressed; // current pressed mouse button number
- private long lastMousePressed; // last time when a mouse button was pressed
- private int lastMouseClickCount; // last mouse button click count
+ private ArrayList mouseListeners = new ArrayList();
+ private int mouseButtonPressed = 0; // current pressed mouse button number
+ private long lastMousePressed = 0; // last time when a mouse button was pressed
+ private int lastMouseClickCount = 0; // last mouse button click count
- private ArrayList keyListeners;
+ private ArrayList keyListeners = new ArrayList();
- private ArrayList windowListeners;
+ private ArrayList windowListeners = new ArrayList();
private boolean repaintQueued = false;
ScreenModeListenerImpl screenModeListenerImpl = new ScreenModeListenerImpl();
- private void initializeStates() {
- invalidate(true);
-
- childWindows = new ArrayList();
- surfaceUpdatedListeners = new ArrayList();
- windowListeners = new ArrayList();
- mouseListeners = new ArrayList();
-
- mouseButtonPressed = 0; // current pressed mouse button number
- lastMousePressed = 0; // last time when a mouse button was pressed
- lastMouseClickCount = 0; // last mouse button click count
- keyListeners = new ArrayList();
- }
-
// Workaround for initialization order problems on Mac OS X
// between native Newt and (apparently) Fmod -- if Fmod is
// initialized first then the connection to the window server
@@ -179,7 +166,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
windowClass = OffscreenWindow.class;
}
WindowImpl window = (WindowImpl) windowClass.newInstance();
- window.initializeStates();
window.parentWindow = parentWindow;
window.parentWindowHandle = parentWindowHandle;
window.screen = (ScreenImpl) screen;
@@ -204,7 +190,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
throw new NativeWindowException("WindowClass "+windowClass+" constructor mismatch at argument #"+argsChecked+"; Constructor: "+getTypeStrList(cstrArgumentTypes)+", arguments: "+getArgsStrList(cstrArguments));
}
WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ;
- window.initializeStates();
window.screen = (ScreenImpl) screen;
window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable();
return window;
@@ -244,13 +229,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
void destroyActionInLock();
/**
- * Invoked after destruction from Window's invalidate method.<br>
- * Called while window is locked.
- * @param unrecoverable
- */
- void invalidate(boolean unrecoverable);
-
- /**
* Invoked for expensive modifications, ie while reparenting and ScreenMode change.<br>
* No lock is hold when invoked.<br>
*
@@ -310,26 +288,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
- private void closeAndInvalidate() {
- windowLock.lock();
- try {
- if( null != screen ) {
- if( 0 != windowHandle ) {
- screen.removeScreenModeListener(screenModeListenerImpl);
- closeNativeImpl();
- removeScreenReference();
- }
- Display dpy = screen.getDisplay();
- if(null != dpy) {
- dpy.validateEDT();
- }
- }
- invalidate(false);
- } finally {
- windowLock.unlock();
- }
- }
-
private boolean validateParentWindowHandle() {
if(null!=parentWindow) {
parentWindowHandle = getNativeWindowHandle(parentWindow);
@@ -765,6 +723,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
return; // nop
}
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ String msg = "!!! Window DestroyAction() "+getThreadName();
+ System.err.println(msg);
+ }
// Childs first ..
synchronized(childWindowsLock) {
if(childWindows.size()>0) {
@@ -787,7 +749,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
lifecycleHook.destroyActionInLock();
}
- closeAndInvalidate();
+ if( null != screen ) {
+ if( 0 != windowHandle ) {
+ screen.removeScreenModeListener(screenModeListenerImpl);
+ closeNativeImpl();
+ removeScreenReference();
+ }
+ Display dpy = screen.getDisplay();
+ if(null != dpy) {
+ dpy.validateEDT();
+ }
+ }
// send synced destroyed notification
sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROYED);
@@ -800,7 +772,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
if(animatorPaused) {
lifecycleHook.resumeRenderingAction();
- }
+ }
+ windowHandle = 0;
+ visible = false;
+ fullscreen = false;
+ hasFocus = false;
+ parentWindowHandle = 0;
+
+ // these refs shall be kept alive - resurrection
+ /**
+ if(null!=parentWindow && parentWindow instanceof Window) {
+ ((Window)parentWindow).removeChild(WindowImpl.this);
+ }
+ childWindows = null;
+ surfaceUpdatedListeners = null;
+ mouseListeners = null;
+ keyListeners = null;
+ capsRequested = null;
+ lifecycleHook = null;
+
+ screen = null;
+ windowListeners = null;
+ parentWindow = null;
+ */
}
}
@@ -816,84 +810,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
}
- public final void invalidate() {
- destroy();
- invalidate(true);
- }
-
- /**
- * @param unrecoverable If true, all states, size, position, parent handles,
- * reference to it's Screen are reset.
- * Otherwise you can recreate the window, via <code>setVisible(true)</code>.
- * @see #invalidate()
- * @see #destroy()
- * @see #destroy(boolean)
- */
- protected void invalidate(boolean unrecoverable) {
- windowLock.lock();
- try {
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- String msg = "!!! Window Invalidate(unrecoverable: "+unrecoverable+") "+getThreadName();
- System.err.println(msg);
- // Throwable t = new Throwable(msg);
- // t.printStackTrace();
- }
-
- // Childs first ..
- synchronized(childWindowsLock) {
- // avoid ConcurrentModificationException: parent -> child -> parent.removeChild(this)
- if(null!=childWindows && childWindows.size()>0) {
- ArrayList clonedChildWindows = (ArrayList) childWindows.clone();
- while( clonedChildWindows.size() > 0 ) {
- NativeWindow nw = (NativeWindow) clonedChildWindows.remove(0);
- if(nw instanceof WindowImpl) {
- ((WindowImpl)nw).invalidate(unrecoverable);
- }
- }
- }
- }
-
- if(null!=lifecycleHook) {
- lifecycleHook.invalidate(unrecoverable);
- }
-
- windowHandle = 0;
- visible = false;
- fullscreen = false;
- hasFocus = false;
-
- if(unrecoverable) {
- if(null!=parentWindow && parentWindow instanceof Window) {
- ((Window)parentWindow).removeChild(WindowImpl.this);
- }
- screen = null;
-
- synchronized(childWindowsLock) {
- childWindows = null;
- }
- synchronized(surfaceUpdatedListenersLock) {
- surfaceUpdatedListeners = null;
- }
- windowListeners = null;
- mouseListeners = null;
- keyListeners = null;
-
- parentWindowHandle = 0;
- parentWindow = null;
- capsRequested = null;
- lifecycleHook = null;
-
- // Default position and dimension will be re-set immediately by user
- width = 128;
- height = 128;
- x=0;
- y=0;
- }
- } finally {
- windowLock.unlock();
- }
- }
-
private class ReparentActionImpl implements Runnable, ReparentAction {
NativeWindow newParentWindow;
boolean forceDestroyCreate;