summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build-newt.xml2
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java45
-rwxr-xr-xsrc/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java2
3 files changed, 37 insertions, 12 deletions
diff --git a/make/build-newt.xml b/make/build-newt.xml
index 0d9ee2118..2cb848588 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -122,7 +122,7 @@
<isset property="setup.noOpenGL"/>
</condition>
- <property name="java.excludes.cdcfp" value="${java.part.awt}, com/jogamp/newt/impl/macosx/*"/>
+ <property name="java.excludes.cdcfp" value="${java.part.awt}"/>
<condition property="java.excludes.desktop"
value="${java.part.x11} ${java.part.windows}, ${java.part.macosx}, ${java.part.awt}">
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 9b9dca2e4..861dc7a6c 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java
@@ -35,6 +35,7 @@ package com.jogamp.newt.impl.macosx;
import javax.media.nativewindow.*;
import javax.media.nativewindow.macosx.*;
+import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.newt.*;
import com.jogamp.newt.impl.*;
import com.jogamp.newt.util.MainThread;
@@ -67,16 +68,7 @@ public class MacDisplay extends Display {
private DispatchAction dispatchAction = new DispatchAction();
protected void dispatchMessagesNative() {
- 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();
- }
- }
+ runOnMainThread(false, dispatchAction);
}
protected void createNative() {
@@ -91,6 +83,39 @@ public class MacDisplay extends Display {
public EDTUtil getEDTUtil() {
return null;
}*/
+
+ protected static void runOnMainThread(boolean wait, Runnable r) {
+ if (MainThread.isRunning()) {
+ MainThread.invoke(wait, r);
+ } else if(!runOnAWTEDT(wait, r)) {
+ throw new NativeWindowException("Neither MainThread is running nor AWT EDT available");
+ }
+ }
+
+ protected static boolean runOnAWTEDT(boolean wait, Runnable r) {
+ if(ReflectionUtil.isClassAvailable("java.awt.EventQueue")) {
+ try {
+ if(wait) {
+ ReflectionUtil.callStaticMethod(
+ "java.awt.EventQueue",
+ "invokeAndWait",
+ new Class[] { java.lang.Runnable.class },
+ new Object[] { r } );
+ } else {
+ ReflectionUtil.callStaticMethod(
+ "java.awt.EventQueue",
+ "invokeLater",
+ new Class[] { java.lang.Runnable.class },
+ new Object[] { r } );
+ }
+ } catch (Exception e) {
+ throw new NativeWindowException(e);
+ }
+ return true;
+ }
+ return false;
+ }
+
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 c45a30bc7..b6328b02f 100755
--- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
+++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacWindow.java
@@ -450,7 +450,7 @@ public class MacWindow extends Window {
}
try {
- java.awt.EventQueue.invokeAndWait(new Runnable() {
+ MacDisplay.runOnMainThread(true, new Runnable() {
public void run() {
if(0!=windowHandle) {
// save the view .. close the window