summaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-06-02 14:17:17 +0200
committerMichael Bien <[email protected]>2010-06-02 14:17:17 +0200
commit1c4dadcc23b3920b0c612254af361da370d86cb8 (patch)
tree95d505f3109cada84ee54d3b1d0f27737e398640 /src/newt/classes/com
parentace04b51b41dd7887aec4095c8c4792dfc4c284b (diff)
parentede9386de45b63f46c206aaed27ddeafe8fe96fa (diff)
Merge branch 'master' of github.com:sgothel/jogl
Diffstat (limited to 'src/newt/classes/com')
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Display.java108
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/Window.java13
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java40
-rw-r--r--src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java59
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java3
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java17
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java245
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java10
8 files changed, 236 insertions, 259 deletions
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index 113ec547e..8710f82ba 100755
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -112,7 +112,7 @@ public abstract class Display {
Map displayMap = getCurrentDisplayMap();
Set entrySet = displayMap.entrySet();
Iterator i = entrySet.iterator();
- System.err.println(prefix+" DisplayMap["+entrySet.size()+"] "+Thread.currentThread());
+ System.err.println(prefix+" DisplayMap[] entries: "+entrySet.size()+" - "+Thread.currentThread());
for(int j=0; i.hasNext(); j++) {
Map.Entry entry = (Map.Entry) i.next();
System.err.println(" ["+j+"] "+entry.getKey()+" -> "+entry.getValue());
@@ -125,7 +125,7 @@ public abstract class Display {
}
/** Make sure to reuse a Display with the same name */
- protected static Display create(String type, String name, final long handle) {
+ protected static synchronized Display create(String type, String name, final long handle) {
try {
Class displayClass = getDisplayClass(type);
Display tmpDisplay = (Display) displayClass.newInstance();
@@ -140,41 +140,30 @@ public abstract class Display {
tmpDisplay = null;
display.name = name;
display.type=type;
- display.refCount=1;
-
- if(NewtFactory.useEDT()) {
- final Display f_dpy = display;
- Thread current = Thread.currentThread();
- display.edtUtil = new EDTUtil(current.getThreadGroup(),
- "Display_"+display.getFQName(),
- new Runnable() {
- public void run() {
- if(null!=f_dpy.getGraphicsDevice()) {
- f_dpy.pumpMessagesImpl();
- }
- } } );
- display.edt = display.edtUtil.start();
- display.edtUtil.invokeAndWait(new Runnable() {
- public void run() {
- f_dpy.createNative();
- }
- } );
- } else {
- display.createNative();
- }
- if(null==display.aDevice) {
- throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice");
- }
- setCurrentDisplay(display);
+ display.refCount=0;
if(DEBUG) {
- System.err.println("Display.create("+getFQName(type, name)+") NEW: "+display+" "+Thread.currentThread());
+ System.err.println("Display.create("+getFQName(type, name)+") NEW: refCount "+display.refCount+", "+display+" "+Thread.currentThread());
}
} else {
tmpDisplay = null;
- synchronized(display) {
- display.refCount++;
+ if(DEBUG) {
+ System.err.println("Display.create("+getFQName(type, name)+") REUSE: refCount "+display.refCount+", "+display+" "+Thread.currentThread());
+ }
+ }
+ synchronized(display) {
+ display.refCount++;
+ if(null==display.aDevice) {
+ final Display f_dpy = display;
+ display.runOnEDTIfAvail(true, new Runnable() {
+ public void run() {
+ f_dpy.createNative();
+ }});
+ if(null==display.aDevice) {
+ throw new RuntimeException("Display.createNative() failed to instanciate an AbstractGraphicsDevice");
+ }
+ setCurrentDisplay(display);
if(DEBUG) {
- System.err.println("Display.create("+getFQName(type, name)+") REUSE: refCount "+display.refCount+", "+display+" "+Thread.currentThread());
+ System.err.println("Display.create("+getFQName(type, name)+") CreateNative: "+display+" "+Thread.currentThread());
}
}
}
@@ -187,7 +176,41 @@ public abstract class Display {
}
}
- public EDTUtil getEDTUtil() { return edtUtil; }
+ public boolean runCreateAndDestroyOnEDT() {
+ return true;
+ }
+ public EDTUtil getEDTUtil() {
+ if( !edtQueried ) {
+ synchronized (this) {
+ if( !edtQueried ) {
+ edtQueried = true;
+ if(NewtFactory.useEDT()) {
+ final Display f_dpy = this;
+ Thread current = Thread.currentThread();
+ edtUtil = new EDTUtil(current.getThreadGroup(),
+ "Display_"+getFQName(),
+ new Runnable() {
+ public void run() {
+ if(null!=f_dpy.getGraphicsDevice()) {
+ f_dpy.pumpMessagesImpl();
+ } } } );
+ edt = edtUtil.start();
+ }
+ }
+ }
+ }
+ return edtUtil;
+ }
+ volatile boolean edtQueried = false;
+
+ public void runOnEDTIfAvail(boolean wait, final Runnable task) {
+ EDTUtil edtUtil = getEDTUtil();
+ if(runCreateAndDestroyOnEDT() && null!=edtUtil) {
+ edtUtil.invoke(wait, task);
+ } else {
+ task.run();
+ }
+ }
public synchronized void destroy() {
if(DEBUG) {
@@ -199,18 +222,17 @@ public abstract class Display {
if(DEBUG) {
System.err.println("Display.destroy("+getFQName()+") REMOVE: "+this+" "+Thread.currentThread());
}
- if(null!=edtUtil) {
- final Display f_dpy = this;
- final EDTUtil f_edt = edtUtil;
- edtUtil.invokeAndWait(new Runnable() {
- public void run() {
- f_dpy.closeNative();
+ final Display f_dpy = this;
+ final EDTUtil f_edt = edtUtil;
+ runOnEDTIfAvail(true, new Runnable() {
+ public void run() {
+ f_dpy.closeNative();
+ if(null!=f_edt) {
f_edt.stop();
}
- } );
- } else {
- closeNative();
- }
+ }
+ } );
+
if(null!=edtUtil) {
edtUtil.waitUntilStopped();
edtUtil=null;
diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java
index bb3fa8982..87f0bf0eb 100755
--- a/src/newt/classes/com/jogamp/newt/Window.java
+++ b/src/newt/classes/com/jogamp/newt/Window.java
@@ -161,11 +161,6 @@ public abstract class Window implements NativeWindow
if( null==screen || 0!=windowHandle || !visible ) {
return 0 != windowHandle ;
}
- EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
- if( null != edtUtil && edtUtil.isRunning() && !edtUtil.isCurrentThreadEDT() ) {
- throw new NativeWindowException("EDT enabled but not on EDT");
- }
-
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.createNative() START ("+Thread.currentThread()+", "+this+")");
}
@@ -219,12 +214,8 @@ public abstract class Window implements NativeWindow
if(null==screen) {
throw new RuntimeException("Null screen of inner class: "+this);
}
- EDTUtil edtUtil = screen.getDisplay().getEDTUtil();
- if(null!=edtUtil) {
- edtUtil.invoke(wait, task);
- } else {
- task.run();
- }
+ Display d = screen.getDisplay();
+ d.runOnEDTIfAvail(wait, task);
}
/**
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
index d94a32a9c..33c291e96 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTParentWindowAdapter.java
@@ -35,12 +35,24 @@ package com.jogamp.newt.event.awt;
* Specialized parent/client adapter,
* where the NEWT child window really gets resized,
* and the parent move window event gets discarded. */
-public class AWTParentWindowAdapter extends AWTWindowAdapter
+public class AWTParentWindowAdapter
+ extends AWTWindowAdapter
+ implements java.awt.event.HierarchyListener
{
public AWTParentWindowAdapter(com.jogamp.newt.Window downstream) {
super(downstream);
}
+ public AWTAdapter addTo(java.awt.Component awtComponent) {
+ awtComponent.addHierarchyListener(this);
+ return super.addTo(awtComponent);
+ }
+
+ public AWTAdapter removeFrom(java.awt.Component awtComponent) {
+ awtComponent.removeHierarchyListener(this);
+ return super.removeFrom(awtComponent);
+ }
+
public void componentResized(java.awt.event.ComponentEvent e) {
// Need to resize the NEWT child window
// the resized event will be send via the native window feedback.
@@ -67,5 +79,31 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter
public void windowDeactivated(java.awt.event.WindowEvent e) {
// no propagation to NEWT child window
}
+
+ public void hierarchyChanged(java.awt.event.HierarchyEvent e) {
+ if( null == newtListener ) {
+ long bits = e.getChangeFlags();
+ final java.awt.Component changed = e.getChanged();
+ if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
+ final boolean showing = changed.isShowing();
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed);
+ }
+ if(!newtWindow.isDestroyed()) {
+ newtWindow.runOnEDTIfAvail(false, new Runnable() {
+ public void run() {
+ newtWindow.setVisible(showing);
+ }
+ });
+ }
+ }
+ if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) {
+ final boolean displayability = changed.isDisplayable();
+ if(DEBUG_IMPLEMENTATION) {
+ System.out.println("hierarchyChanged DISPLAYABILITY_CHANGED: displayability "+displayability+", "+changed);
+ }
+ }
+ }
+ }
}
diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
index 53ce03299..570b0678a 100644
--- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
+++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java
@@ -33,8 +33,7 @@ package com.jogamp.newt.event.awt;
public class AWTWindowAdapter
extends AWTAdapter
- implements java.awt.event.ComponentListener, java.awt.event.WindowListener,
- java.awt.event.HierarchyListener, java.awt.event.HierarchyBoundsListener
+ implements java.awt.event.ComponentListener, java.awt.event.WindowListener
{
WindowClosingListener windowClosingListener;
@@ -53,8 +52,6 @@ public class AWTWindowAdapter
public AWTAdapter addTo(java.awt.Component awtComponent) {
java.awt.Window win = getWindow(awtComponent);
awtComponent.addComponentListener(this);
- awtComponent.addHierarchyListener(this);
- awtComponent.addHierarchyBoundsListener(this);
if( null == windowClosingListener ) {
windowClosingListener = new WindowClosingListener();
}
@@ -69,8 +66,6 @@ public class AWTWindowAdapter
public AWTAdapter removeFrom(java.awt.Component awtComponent) {
awtComponent.removeComponentListener(this);
- awtComponent.removeHierarchyListener(this);
- awtComponent.removeHierarchyBoundsListener(this);
java.awt.Window win = getWindow(awtComponent);
if( null != win && null != windowClosingListener ) {
win.removeWindowListener(windowClosingListener);
@@ -110,6 +105,7 @@ public class AWTWindowAdapter
}
public void componentShown(java.awt.event.ComponentEvent e) {
+ /**
if(null==newtListener) {
if(!newtWindow.isDestroyed()) {
newtWindow.runOnEDTIfAvail(false, new Runnable() {
@@ -118,10 +114,11 @@ public class AWTWindowAdapter
}
});
}
- }
+ }*/
}
public void componentHidden(java.awt.event.ComponentEvent e) {
+ /**
if(null==newtListener) {
if(!newtWindow.isDestroyed()) {
newtWindow.runOnEDTIfAvail(false, new Runnable() {
@@ -130,7 +127,7 @@ public class AWTWindowAdapter
}
});
}
- }
+ }*/
}
public void windowActivated(java.awt.event.WindowEvent e) {
@@ -161,52 +158,6 @@ public class AWTWindowAdapter
public void windowOpened(java.awt.event.WindowEvent e) { }
- public void hierarchyChanged(java.awt.event.HierarchyEvent e) {
- if( null == newtListener ) {
- long bits = e.getChangeFlags();
- final java.awt.Component changed = e.getChanged();
- if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) {
- final boolean showing = changed.isShowing();
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed);
- }
- if(!newtWindow.isDestroyed()) {
- newtWindow.runOnEDTIfAvail(false, new Runnable() {
- public void run() {
- newtWindow.setVisible(showing);
- }
- });
- }
- }
- if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) {
- final boolean displayability = changed.isDisplayable();
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("hierarchyChanged DISPLAYABILITY_CHANGED: displayability "+displayability+", "+changed);
- }
- }
- }
- }
-
- public void ancestorMoved(java.awt.event.HierarchyEvent e) {
- if( null == newtListener ) {
- final java.awt.Component changed = e.getChanged();
- final boolean showing = changed.isShowing();
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("ancestorMoved: showing "+showing+", "+changed);
- }
- }
- }
-
- public void ancestorResized(java.awt.event.HierarchyEvent e) {
- if( null == newtListener ) {
- final java.awt.Component changed = e.getChanged();
- final boolean showing = changed.isShowing();
- if(DEBUG_IMPLEMENTATION) {
- System.out.println("ancestorResized: showing "+showing+", "+changed);
- }
- }
- }
-
class WindowClosingListener implements java.awt.event.WindowListener {
public void windowClosing(java.awt.event.WindowEvent e) {
com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow);
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
index f54e66f07..e705d364a 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTDisplay.java
@@ -54,6 +54,9 @@ public class AWTDisplay extends Display {
protected void closeNative() { }
+ public boolean runCreateAndDestroyOnEDT() {
+ return false;
+ }
protected void dispatchMessagesNative() { /* nop */ }
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
index 0c4362a9e..9b9dca2e4 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
@@ -67,7 +67,16 @@ public class MacDisplay extends Display {
private DispatchAction dispatchAction = new DispatchAction();
protected void dispatchMessagesNative() {
- MainThread.invoke(false, dispatchAction);
+ if (false && MainThread.isRunning()) {
+ MainThread.invoke(false, dispatchAction);
+ } else {
+ try {
+ java.awt.EventQueue.invokeLater(dispatchAction);
+ // java.awt.EventQueue.invokeAndWait(dispatchAction);
+ } catch (Exception ie) {
+ ie.printStackTrace();
+ }
+ }
}
protected void createNative() {
@@ -76,6 +85,12 @@ public class MacDisplay extends Display {
protected void closeNative() { }
+ /*public boolean runCreateAndDestroyOnEDT() {
+ return false;
+ }
+ public EDTUtil getEDTUtil() {
+ return null;
+ }*/
private static native boolean initNSApplication0();
protected native void dispatchMessages0();
}
diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
index 20a181096..c45a30bc7 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
@@ -36,7 +36,6 @@ package com.jogamp.newt.impl.macosx;
import javax.media.nativewindow.*;
import com.jogamp.nativewindow.impl.RecursiveToolkitLock;
-import com.jogamp.newt.util.MainThread;
import com.jogamp.newt.*;
import com.jogamp.newt.event.*;
import com.jogamp.newt.impl.*;
@@ -149,30 +148,23 @@ public class MacWindow extends Window {
}
}
- class CloseAction implements Runnable {
- public void run() {
- nsViewLock.lock();
- try {
- if(DEBUG_IMPLEMENTATION) { System.out.println("MacWindow.CloseAction "+Thread.currentThread().getName()); }
- if (windowHandle != 0) {
- close0(windowHandle);
- }
- } catch (Throwable t) {
- if(DEBUG_IMPLEMENTATION) {
- Exception e = new Exception("closeNative failed - "+Thread.currentThread().getName(), t);
- e.printStackTrace();
- }
- } finally {
- windowHandle = 0;
- nsViewLock.unlock();
+ protected void closeNative() {
+ nsViewLock.lock();
+ try {
+ if(DEBUG_IMPLEMENTATION) { System.out.println("MacWindow.CloseAction "+Thread.currentThread().getName()); }
+ if (windowHandle != 0) {
+ close0(windowHandle);
}
+ } catch (Throwable t) {
+ if(DEBUG_IMPLEMENTATION) {
+ Exception e = new Exception("closeNative failed - "+Thread.currentThread().getName(), t);
+ e.printStackTrace();
+ }
+ } finally {
+ windowHandle = 0;
+ nsViewLock.unlock();
}
}
- private CloseAction closeAction = new CloseAction();
-
- protected void closeNative() {
- MainThread.invoke(true, closeAction);
- }
public long getWindowHandle() {
nsViewLock.lock();
@@ -192,25 +184,12 @@ public class MacWindow extends Window {
}
}
- class EnsureWindowCreatedAction implements Runnable {
- public void run() {
- nsViewLock.lock();
- try {
- createWindow(false, getX(), getY(), getWidth(), getHeight(), isFullscreen());
- } finally {
- nsViewLock.unlock();
- }
- }
- }
- private EnsureWindowCreatedAction ensureWindowCreatedAction =
- new EnsureWindowCreatedAction();
-
public Insets getInsets() {
// in order to properly calculate insets we need the window to be
// created
- MainThread.invoke(true, ensureWindowCreatedAction);
nsViewLock.lock();
try {
+ createWindow(false, getX(), getY(), getWidth(), getHeight(), isFullscreen());
return (Insets) insets.clone();
} finally {
nsViewLock.unlock();
@@ -235,120 +214,84 @@ public class MacWindow extends Window {
}
protected void setVisibleImpl(final boolean visible) {
- MainThread.invoke(true, new Runnable() {
- public void run() {
- nsViewLock.lock();
- try {
- if (visible) {
- createWindow(false, getX(), getY(), getWidth(), getHeight(), isFullscreen());
- if (windowHandle != 0) {
- makeKeyAndOrderFront0(windowHandle);
- }
- } else {
- if (windowHandle != 0) {
- orderOut0(windowHandle);
- }
- }
- } finally {
- nsViewLock.unlock();
+ nsViewLock.lock();
+ try {
+ if (visible) {
+ createWindow(false, getX(), getY(), getWidth(), getHeight(), isFullscreen());
+ if (windowHandle != 0) {
+ makeKeyAndOrderFront0(windowHandle);
}
- }
- });
- }
-
- class TitleAction implements Runnable {
- public void run() {
- nsViewLock.lock();
- try {
+ } else {
if (windowHandle != 0) {
- setTitle0(windowHandle, title);
+ orderOut0(windowHandle);
}
- } finally {
- nsViewLock.unlock();
}
+ } finally {
+ nsViewLock.unlock();
}
}
- private TitleAction titleAction = new TitleAction();
public void setTitle(String title) {
super.setTitle(title);
- MainThread.invoke(true, titleAction);
- }
-
- class FocusAction implements Runnable {
- public void run() {
- nsViewLock.lock();
- try {
- if (windowHandle != 0) {
- makeKey0(windowHandle);
- }
- } finally {
- nsViewLock.unlock();
+ nsViewLock.lock();
+ try {
+ if (windowHandle != 0) {
+ setTitle0(windowHandle, title);
}
+ } finally {
+ nsViewLock.unlock();
}
}
- private FocusAction focusAction = new FocusAction();
public void requestFocus() {
super.requestFocus();
- MainThread.invoke(true, focusAction);
- }
-
- class SizeAction implements Runnable {
- public void run() {
- nsViewLock.lock();
- try {
- if (windowHandle != 0) {
- setContentSize0(windowHandle, width, height);
- }
- } finally {
- nsViewLock.unlock();
+ nsViewLock.lock();
+ try {
+ if (windowHandle != 0) {
+ makeKey0(windowHandle);
}
+ } finally {
+ nsViewLock.unlock();
}
}
- private SizeAction sizeAction = new SizeAction();
-
+
protected void setSizeImpl(int width, int height) {
// this width/height will be set by sizeChanged, called by OSX
- MainThread.invoke(true, sizeAction);
- }
-
- class PositionAction implements Runnable {
- public void run() {
- nsViewLock.lock();
- try {
- if (windowHandle != 0) {
- setFrameTopLeftPoint0(parentWindowHandle, windowHandle, x, y);
- }
- } finally {
- nsViewLock.unlock();
+ nsViewLock.lock();
+ try {
+ if (windowHandle != 0) {
+ setContentSize0(windowHandle, width, height);
}
+ } finally {
+ nsViewLock.unlock();
}
}
- private PositionAction positionAction = new PositionAction();
-
+
protected void setPositionImpl(int x, int y) {
// this x/y will be set by positionChanged, called by OSX
- MainThread.invoke(true, positionAction);
+ nsViewLock.lock();
+ try {
+ if (windowHandle != 0) {
+ setFrameTopLeftPoint0(parentWindowHandle, windowHandle, x, y);
+ }
+ } finally {
+ nsViewLock.unlock();
+ }
}
protected boolean setFullscreenImpl(final boolean fullscreen, final int x, final int y, final int w, final int h) {
- MainThread.invoke(true, new Runnable() {
- public void run() {
- nsViewLock.lock();
- try {
- if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
- System.err.println("MacWindow fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
- }
- createWindow(true, x, y, w, h, fullscreen);
- if (windowHandle != 0) {
- makeKeyAndOrderFront0(windowHandle);
- }
- } finally {
- nsViewLock.unlock();
- }
+ nsViewLock.lock();
+ try {
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ System.err.println("MacWindow fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
}
- });
+ createWindow(true, x, y, w, h, fullscreen);
+ if (windowHandle != 0) {
+ makeKeyAndOrderFront0(windowHandle);
+ }
+ } finally {
+ nsViewLock.unlock();
+ }
return fullscreen;
}
@@ -500,35 +443,45 @@ public class MacWindow extends Window {
super.sendKeyEvent(eventType, modifiers, key, keyChar);
}
- private void createWindow(boolean recreate, int x, int y, int width, int height, boolean fullscreen) {
+ private void createWindow(final boolean recreate, final int x, final int y, final int width, final int height, final boolean fullscreen) {
+
if(0!=windowHandle && !recreate) {
return;
}
- if(0!=windowHandle) {
- // save the view .. close the window
- surfaceHandle = changeContentView0(parentWindowHandle, windowHandle, 0);
- if(recreate && 0==surfaceHandle) {
- throw new NativeWindowException("Internal Error - recreate, window but no view");
- }
- close0(windowHandle);
- windowHandle=0;
- } else {
- surfaceHandle = 0;
- }
- windowHandle = createWindow0(parentWindowHandle,
- x, y, width, height, fullscreen,
- (isUndecorated(fullscreen) ?
- NSBorderlessWindowMask :
- NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask),
- NSBackingStoreBuffered,
- getScreen().getIndex(), surfaceHandle);
- if (windowHandle == 0) {
- throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this);
+
+ try {
+ java.awt.EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ if(0!=windowHandle) {
+ // save the view .. close the window
+ surfaceHandle = changeContentView0(parentWindowHandle, windowHandle, 0);
+ if(recreate && 0==surfaceHandle) {
+ throw new NativeWindowException("Internal Error - recreate, window but no view");
+ }
+ close0(windowHandle);
+ windowHandle=0;
+ } else {
+ surfaceHandle = 0;
+ }
+ windowHandle = createWindow0(parentWindowHandle,
+ x, y, width, height, fullscreen,
+ (isUndecorated(fullscreen) ?
+ NSBorderlessWindowMask :
+ NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask),
+ NSBackingStoreBuffered,
+ getScreen().getIndex(), surfaceHandle);
+ if (windowHandle == 0) {
+ throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this);
+ }
+ surfaceHandle = contentView0(windowHandle);
+ setTitle0(windowHandle, getTitle());
+ // don't make the window visible on window creation
+ // makeKeyAndOrderFront0(windowHandle);
+ } } );
+ } catch (Exception ie) {
+ ie.printStackTrace();
}
- surfaceHandle = contentView0(windowHandle);
- setTitle0(windowHandle, getTitle());
- // don't make the window visible on window creation
-// makeKeyAndOrderFront0(windowHandle);
+
sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 2bb28466c..9559043c4 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -120,10 +120,14 @@ public class GLWindow extends Window implements GLAutoDrawable {
return (null!=window)?window.isDestroyed():true;
}
- public Window getInnerWindow() {
+ public final Window getInnerWindow() {
return window.getInnerWindow();
}
+ public final Object getWrappedWindow() {
+ return window.getWrappedWindow();
+ }
+
/**
* EXPERIMENTAL<br>
* Enable or disables running the {@link Display#pumpMessages} in the {@link #display()} call.<br>
@@ -244,8 +248,8 @@ public class GLWindow extends Window implements GLAutoDrawable {
window.setVisible(visible);
if (null == context && visible && 0 != window.getWindowHandle() && 0<getWidth()*getHeight()) {
NativeWindow nw;
- if (window.getWrappedWindow() != null) {
- nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getGraphicsConfiguration());
+ if (getWrappedWindow() != null) {
+ nw = NativeWindowFactory.getNativeWindow(getWrappedWindow(), window.getGraphicsConfiguration());
} else {
nw = window;
}