diff options
Diffstat (limited to 'src/nativewindow')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java | 21 | ||||
-rw-r--r-- | src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java | 22 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index f4309617b..735d85fb1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -37,11 +37,13 @@ import org.eclipse.swt.widgets.Control; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowFactory; + import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import jogamp.common.awt.AWTEDTExecutor; import jogamp.nativewindow.macosx.OSXUtil; public class SWTAccessor { @@ -254,8 +256,25 @@ public class SWTAccessor { }); } + /** + * Runs the specified action in an SWT compatible thread, which is: + * <ul> + * <li>Mac OSX + * <ul> + * <!--li>AWT EDT: In case AWT is available, the AWT EDT is the OSX UI main thread</li--> + * <li><i>Main Thread</i>: Run on OSX UI main thread.</li> + * </ul></li> + * <li>Linux, Windows, .. + * <ul> + * <li>Current thread.</li> + * </ul></li> + * </ul> + * @see Platform#AWT_AVAILABLE + * @see Platform#getOSType() + */ public static void invoke(boolean wait, Runnable runnable) { - if(Platform.OS_TYPE == Platform.OSType.MACOS) { + if( Platform.OS_TYPE == Platform.OSType.MACOS ) { + // Use SWT main thread! Only reliable config w/ -XStartOnMainThread !? OSXUtil.RunOnMainThread(wait, runnable); } else { runnable.run(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 94f949ea3..2cd87f276 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -30,6 +30,7 @@ package jogamp.nativewindow.macosx; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Point; +import jogamp.common.awt.AWTEDTExecutor; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; @@ -111,6 +112,27 @@ public class OSXUtil { return IsMainThread0(); } + /*** + private static boolean isAWTEDTMainThreadInit = false; + private static boolean isAWTEDTMainThread; + + public synchronized static boolean isAWTEDTMainThread() { + if(!isAWTEDTMainThreadInit) { + isAWTEDTMainThreadInit = true; + if(Platform.AWT_AVAILABLE) { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + isAWTEDTMainThread = IsMainThread(); + System.err.println("XXX: "+Thread.currentThread().getName()+" - isAWTEDTMainThread "+isAWTEDTMainThread); + } + }); + } else { + isAWTEDTMainThread = false; + } + } + return isAWTEDTMainThread; + } */ + private static native boolean initIDs0(); private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); private static native long CreateNSView0(int x, int y, int width, int height); |