aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-04-05 05:54:48 +0200
committerSven Gothel <[email protected]>2019-04-05 05:54:48 +0200
commit1c697274a3c1e976bd9c9b089d6583edf4f346ae (patch)
tree81e34ba1c905a36dc5bd6b090b9f79b3ccab8ea6
parent38cb6fa11f00fb358b8bbe40dc79443a5f30269f (diff)
Bug 1370: Call from Main-Thread: NW's OSXUtil.CreateNSWindow0(..) and NEWT's WindowDriver.createWindow0(..)
OSX 10.14.3 Mojave issues a WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. The complaint about NativeWindow (NW)'s OSXUtil.CreateNSWindow0(..) might be valid, which does create a NS Window instance w/ NSView and framebuffer initialized. However, the complaint about NEWT's WindowDriver.createWindow0(..) is not, since the initialization incl framebuffer happened later on the main thread. Regardless, encapsulated both construction fully to run on the Main-Thread. +++ Originally the Main-Thread design spec was like: Must run on Main-Thread when or after making visible. Oh well.
-rwxr-xr-xmake/scripts/tests-osx-x64.sh2
-rw-r--r--make/scripts/tests.sh6
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java11
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java43
4 files changed, 35 insertions, 27 deletions
diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh
index d58b4d465..020ea34d1 100755
--- a/make/scripts/tests-osx-x64.sh
+++ b/make/scripts/tests-osx-x64.sh
@@ -4,7 +4,7 @@
#export DYLD_LIBRARY_PATH=$HOME/ffmpeg-2.2.3/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/usr/local/Cellar/ffmpeg/2.8/lib:$DYLD_LIBRARY_PATH
-JAVA_HOME=`/usr/libexec/java_home -version`
+JAVA_HOME=`/usr/libexec/java_home`
#JAVA_HOME=`/usr/libexec/java_home -version 1.8`
#JAVA_HOME=`/usr/libexec/java_home -version 1.7`
#JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_25`
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 9399ad913..81ef5d592 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -145,7 +145,7 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.TraceGL"
#D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL"
#D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window"
- D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas"
+ #D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas"
#D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource"
#D_ARGS="-Dnativewindow.debug.JAWT"
#D_ARGS="-Djogl.debug.GLContext.TraceSwitch"
@@ -437,7 +437,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWTNoARBCtx $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile03NEWTOffscreen $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile04NEWTOffscreenNoARBCtx $*
-testawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $*
+#testawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $*
#
#
@@ -781,7 +781,7 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestVersionSemanticsNOUI $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $*
-#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $*
+testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $*
#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $*
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index f71dff1cb..b1bf248ce 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -31,7 +31,6 @@ import com.jogamp.nativewindow.NativeWindowException;
import com.jogamp.nativewindow.NativeWindowFactory;
import com.jogamp.nativewindow.util.Insets;
import com.jogamp.nativewindow.util.Point;
-
import com.jogamp.common.util.Function;
import com.jogamp.common.util.FunctionTask;
import com.jogamp.common.util.InterruptedRuntimeException;
@@ -124,10 +123,16 @@ public class OSXUtil implements ToolkitProperties {
}
public static long CreateNSWindow(final int x, final int y, final int width, final int height) {
- return CreateNSWindow0(x, y, width, height);
+ final long res[] = { 0 };
+ RunOnMainThread(true, false /* kickNSApp */, new Runnable() {
+ @Override
+ public void run() {
+ res[0] = CreateNSWindow0(x, y, width, height);
+ } } );
+ return res[0];
}
public static void DestroyNSWindow(final long nsWindow) {
- DestroyNSWindow0(nsWindow);
+ DestroyNSWindow0(nsWindow);
}
public static long GetNSView(final long nsWindow) {
return GetNSView0(nsWindow);
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 46c86d2c1..e6ae7719c 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -775,32 +775,35 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
}
windowStyle = ws;
}
- final long newWin = createWindow0( pS.getX(), pS.getY(), width, height,
- 0 != ( STATE_MASK_FULLSCREEN & flags),
- windowStyle,
- NSBackingStoreBuffered, surfaceHandle);
- if ( newWin == 0 ) {
- throw new NativeWindowException("Could not create native window "+Thread.currentThread().getName()+" "+this);
- }
- setWindowHandle( newWin );
-
- final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance;
// Blocking initialization on main-thread!
+ final long[] newWin = { 0 };
OSXUtil.RunOnMainThread(true, false /* kickNSApp */, new Runnable() {
@Override
public void run() {
- initWindow0( parentWinHandle, newWin, pS.getX(), pS.getY(), width, height, reqPixelScale[0] /* HiDPI uniformPixelScale */,
- isOpaque,
- !offscreenInstance && 0 != ( STATE_MASK_ALWAYSONTOP & flags),
- !offscreenInstance && 0 != ( STATE_MASK_ALWAYSONBOTTOM & flags),
- !offscreenInstance && 0 != ( STATE_MASK_VISIBLE & flags),
- surfaceHandle);
- if( offscreenInstance ) {
- orderOut0(0!=parentWinHandle ? parentWinHandle : newWin);
- } else {
- setTitle0(newWin, getTitle());
+ newWin[0] = createWindow0( pS.getX(), pS.getY(), width, height,
+ 0 != ( STATE_MASK_FULLSCREEN & flags),
+ windowStyle,
+ NSBackingStoreBuffered, surfaceHandle);
+ if ( newWin[0] != 0 ) {
+ final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance;
+ initWindow0( parentWinHandle, newWin[0], pS.getX(), pS.getY(), width, height, reqPixelScale[0] /* HiDPI uniformPixelScale */,
+ isOpaque,
+ !offscreenInstance && 0 != ( STATE_MASK_ALWAYSONTOP & flags),
+ !offscreenInstance && 0 != ( STATE_MASK_ALWAYSONBOTTOM & flags),
+ !offscreenInstance && 0 != ( STATE_MASK_VISIBLE & flags),
+ surfaceHandle);
+ if( offscreenInstance ) {
+ orderOut0(0!=parentWinHandle ? parentWinHandle : newWin[0]);
+ } else {
+ setTitle0(newWin[0], getTitle());
+ }
}
} });
+
+ if ( newWin[0] == 0 ) {
+ throw new NativeWindowException("Could not create native window "+Thread.currentThread().getName()+" "+this);
+ }
+ setWindowHandle( newWin[0] );
} catch (final Exception ie) {
ie.printStackTrace();
}