summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-27 00:44:18 +0100
committerSven Gothel <[email protected]>2011-11-27 00:44:18 +0100
commit9bdc043059abc927a0cdb72b4e775d097e3c8876 (patch)
treed2852076c8211fbde96536e38d05a7a58e5b0308 /src/newt/classes
parent457803bac0bf2328de160daa35542fd7c854dc4b (diff)
NEWT OSX: Add stopNSApplication(), revert commit c26d6005e1fe74e9aee01d9d72942f566884fcd2
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/util/MainThread.java31
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java4
2 files changed, 28 insertions, 7 deletions
diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java
index c7780b0d8..b1862834c 100644
--- a/src/newt/classes/com/jogamp/newt/util/MainThread.java
+++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java
@@ -93,6 +93,9 @@ import jogamp.newt.NEWTJNILibLoader;
*/
public class MainThread {
private static final String MACOSXDisplayClassName = "jogamp.newt.driver.macosx.MacDisplay";
+ private static final Platform.OSType osType;
+ private static final boolean isMacOSX;
+
/** if true, use the main thread EDT, otherwise AWT's EDT */
public static final boolean HINT_USE_MAIN_THREAD;
@@ -103,7 +106,9 @@ public class MainThread {
NativeWindowFactory.initSingleton(true);
NEWTJNILibLoader.loadNEWT();
HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() ||
- Debug.getBooleanProperty("newt.MainThread.force", true, localACC);
+ Debug.getBooleanProperty("newt.MainThread.force", true, localACC);
+ osType = Platform.getOSType();
+ isMacOSX = osType == Platform.OSType.MACOS;
}
public static boolean useMainThread = false;
@@ -132,7 +137,7 @@ public class MainThread {
try {
Class<?> mainClass = ReflectionUtil.getClass(mainClassName, true, getClass().getClassLoader());
if(null==mainClass) {
- throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName));
+ throw new RuntimeException(new ClassNotFoundException("MainAction couldn't find main class "+mainClassName));
}
try {
mainClassMain = mainClass.getDeclaredMethod("main", new Class[] { String[].class });
@@ -151,8 +156,23 @@ public class MainThread {
if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" user app fin");
if ( useMainThread ) {
- if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainThread fin - stop");
- System.exit(0);
+ if(isMacOSX) {
+ try {
+ if(DEBUG) {
+ System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.0");
+ }
+ ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "stopNSApplication",
+ null, null, MainThread.class.getClassLoader());
+ if(DEBUG) {
+ System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.X");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainAction fin - System.exit(0)");
+ System.exit(0);
+ }
}
}
}
@@ -164,9 +184,6 @@ public class MainThread {
useMainThread = HINT_USE_MAIN_THREAD;
- final Platform.OSType osType = Platform.getOSType();
- final boolean isMacOSX = osType == Platform.OSType.MACOS;
-
if(DEBUG) {
System.err.println("MainThread.main(): "+cur.getName()+
", useMainThread "+ useMainThread +
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java
index 527fdac6d..2ac98f255 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java
@@ -72,8 +72,12 @@ public class MacDisplay extends DisplayImpl {
public static void runNSApplication() {
runNSApplication0();
}
+ public static void stopNSApplication() {
+ stopNSApplication0();
+ }
private static native boolean initNSApplication0();
private static native void runNSApplication0();
+ private static native void stopNSApplication0();
}