aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java23
-rw-r--r--src/newt/native/MacWindow.m59
2 files changed, 37 insertions, 45 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 748604994..edeb69f84 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -401,9 +401,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
OSXUtil.RunOnMainThread(true, new Runnable() { // waitUntildone due to PointerIconImpl's Lifecycle !
@Override
public void run() {
- if( !setPointerIcon0(getWindowHandle(), piHandle) ) {
- throw new RuntimeException("Failed: "+pi+", "+WindowDriver.this);
- }
+ setPointerIcon0(getWindowHandle(), piHandle);
} } );
} else {
final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true);
@@ -430,9 +428,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
OSXUtil.RunOnMainThread(false, new Runnable() {
@Override
public void run() {
- if( !setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible) ) {
- throw new RuntimeException("Failed");
- }
+ setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible);
} } );
return true; // setPointerVisible0 always returns true ..
} else {
@@ -456,7 +452,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
@Override
protected boolean confinePointerImpl(final boolean confine) {
if( !isOffscreenInstance ) {
- return confinePointer0(getWindowHandle(), confine);
+ confinePointer0(getWindowHandle(), confine);
+ return true;
} // else may need offscreen solution ? FIXME
return false;
}
@@ -464,9 +461,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
@Override
protected void warpPointerImpl(final int x, final int y) {
if( !isOffscreenInstance ) {
- if( !warpPointer0(getWindowHandle(), x, y) ) {
- throw new RuntimeException("Failed");
- }
+ warpPointer0(getWindowHandle(), x, y);
} // else may need offscreen solution ? FIXME
}
@@ -621,10 +616,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
/** Must be called on Main-Thread */
private native void setAlwaysOnTop0(long window, boolean atop);
private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y);
- private static native boolean setPointerIcon0(long windowHandle, long handle);
- private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible);
- private static native boolean confinePointer0(long windowHandle, boolean confine);
- private static native boolean warpPointer0(long windowHandle, int x, int y);
+ private static native void setPointerIcon0(long windowHandle, long handle);
+ private static native void setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible);
+ private static native void confinePointer0(long windowHandle, boolean confine);
+ private static native void warpPointer0(long windowHandle, int x, int y);
// Window styles
private static final int NSBorderlessWindowMask = 0;
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m
index eb5913706..359b67b39 100644
--- a/src/newt/native/MacWindow.m
+++ b/src/newt/native/MacWindow.m
@@ -210,6 +210,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_initNSAp
if(initialized) return JNI_TRUE;
initialized = 1;
+ NewtCommon_init(env);
+
// This little bit of magic is needed in order to receive mouse
// motion events and allow key focus to be properly transferred.
// FIXME: are these Carbon APIs? They come from the
@@ -349,7 +351,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_destroyPoint
{
NSCursor * c = (NSCursor*) (intptr_t) handle ;
if( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) {
- DBG_PRINT( "Not a NSCursor %p\n", c);
+ NewtCommon_throwNewRuntimeException(env, "Not a NSCursor %p", c);
return;
}
DBG_PRINT( "destroyPointerIcon0 %p\n", c);
@@ -960,7 +962,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0
NSWindow *pWin = [mWin parentWindow];
DBG_PRINT( "windowClose.0 - %p [isNSWindow %d, isNewtWin %d], parent %p\n", mWin, isNSWin, isNewtWin, pWin);
if( !isNewtWin ) {
- DBG_PRINT( "windowClose.0 - Not a NEWT win - abort\n");
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin);
return;
}
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -1316,38 +1318,36 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTo
JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocationOnScreen0
(JNIEnv *env, jclass unused, jlong win, jint src_x, jint src_y)
{
- NSObject *nsObj = (NSObject*) ((intptr_t) win);
- NewtMacWindow * mWin = (NewtMacWindow*) nsObj;
+ NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) win;
if( ![mWin isKindOfClass:[NewtMacWindow class]] ) {
- DBG_PRINT("Not a NewtMacWindow %p\n", nsObj);
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin);
return NULL;
}
NSPoint p0 = [mWin getLocationOnScreen: NSMakePoint(src_x, src_y)];
return (*env)->NewObject(env, pointClz, pointCstr, (jint)p0.x, (jint)p0.y);
}
-JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0
(JNIEnv *env, jobject unused, jlong window, jlong handle)
{
NSCursor *c = (NSCursor*) (intptr_t) handle ;
if ( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) {
- DBG_PRINT("Not a NSCursor %p\n", c);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NSCursor %p", c);
+ return;
}
NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window;
if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) {
- DBG_PRINT("Not a NewtMacWindow %p\n", mWin);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin);
+ return;
}
NewtView* nView = (NewtView *) [mWin contentView];
if( ! [nView isKindOfClass:[NewtView class]] ) {
- DBG_PRINT("Not a NewtView %p\n", nView);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView);
+ return;
}
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[nView setPointerIcon: c];
[pool release];
- return JNI_TRUE;
}
/*
@@ -1355,24 +1355,23 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointe
* Method: setPointerVisible0
* Signature: (JZ)Z
*/
-JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0
(JNIEnv *env, jclass clazz, jlong window, jboolean hasFocus, jboolean mouseVisible)
{
NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) {
- DBG_PRINT("Not a NewtMacWindow %p\n", mWin);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin);
+ return;
}
NewtView* nView = (NewtView *) [mWin contentView];
if( ! [nView isKindOfClass:[NewtView class]] ) {
- DBG_PRINT("Not a NewtView %p\n", nView);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView);
+ return;
}
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[nView setMouseVisible: ( JNI_TRUE == mouseVisible ) ? YES : NO
hasFocus: ( JNI_TRUE == hasFocus ) ? YES : NO];
[pool release];
- return JNI_TRUE;
}
/*
@@ -1380,23 +1379,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointe
* Method: confinePointer0
* Signature: (JZ)Z
*/
-JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0
(JNIEnv *env, jclass clazz, jlong window, jboolean confine)
{
NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) {
- DBG_PRINT("Not a NewtMacWindow %p\n", mWin);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin);
+ return;
}
NewtView* nView = (NewtView *) [mWin contentView];
if( ! [nView isKindOfClass:[NewtView class]] ) {
- DBG_PRINT("Not a NewtView %p\n", nView);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView);
+ return;
}
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[nView setMouseConfined: ( JNI_TRUE == confine ) ? YES : NO];
[pool release];
- return JNI_TRUE;
}
/*
@@ -1404,22 +1402,21 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePo
* Method: warpPointer0
* Signature: (JJII)V
*/
-JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0
(JNIEnv *env, jclass clazz, jlong window, jint x, jint y)
{
NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window);
if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) {
- DBG_PRINT("Not a NewtMacWindow %p\n", mWin);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin);
+ return;
}
NewtView* nView = (NewtView *) [mWin contentView];
if( ! [nView isKindOfClass:[NewtView class]] ) {
- DBG_PRINT("Not a NewtView %p\n", nView);
- return JNI_FALSE;
+ NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView);
+ return;
}
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
[nView setMousePosition: [mWin newtRelClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]];
[pool release];
- return JNI_TRUE;
}