diff options
Diffstat (limited to 'src/nativewindow/native')
-rw-r--r-- | src/nativewindow/native/macosx/OSXmisc.m | 49 | ||||
-rw-r--r-- | src/nativewindow/native/win32/GDImisc.c | 4 | ||||
-rw-r--r-- | src/nativewindow/native/x11/Xmisc.c | 4 |
3 files changed, 46 insertions, 11 deletions
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 127b329d1..2cc272a41 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -65,12 +65,12 @@ static jmethodID runnableRunID = NULL; static const char * const ClazzAnyCstrName = "<init>"; -static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; +static const char * const ClazzNamePoint = "com/jogamp/nativewindow/util/Point"; static const char * const ClazzNamePointCstrSignature = "(II)V"; static jclass pointClz = NULL; static jmethodID pointCstr = NULL; -static const char * const ClazzNameInsets = "javax/media/nativewindow/util/Insets"; +static const char * const ClazzNameInsets = "com/jogamp/nativewindow/util/Insets"; static const char * const ClazzNameInsetsCstrSignature = "(IIII)V"; static jclass insetsClz = NULL; static jmethodID insetsCstr = NULL; @@ -138,17 +138,29 @@ Java_jogamp_nativewindow_macosx_OSXUtil_isNSWindow0(JNIEnv *env, jclass _unused, } static CGDirectDisplayID OSXUtil_getCGDirectDisplayIDByNSScreen(NSScreen *screen) { - // Mind: typedef uint32_t CGDirectDisplayID; - however, we assume it's 64bit on 64bit ?! + // Mind: typedef uint32_t CGDirectDisplayID; NSDictionary * dict = [screen deviceDescription]; NSNumber * val = (NSNumber *) [dict objectForKey: @"NSScreenNumber"]; // [NSNumber integerValue] returns NSInteger which is 32 or 64 bit native size return (CGDirectDisplayID) [val integerValue]; } +static NSScreen * OSXUtil_getNSScreenByCGDirectDisplayID(CGDirectDisplayID displayID) { + NSArray *screens = [NSScreen screens]; + int i; + for(i=[screens count]-1; i>=0; i--) { + NSScreen * screen = (NSScreen *) [screens objectAtIndex: i]; + CGDirectDisplayID dID = OSXUtil_getCGDirectDisplayIDByNSScreen(screen); + if( dID == displayID ) { + return screen; + } + } + return (NSScreen *) [screens objectAtIndex: 0]; +} /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: getLocationOnScreen0 - * Signature: (JII)Ljavax/media/nativewindow/util/Point; + * Signature: (JII)Lcom/jogamp/nativewindow/util/Point; */ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnScreen0 (JNIEnv *env, jclass unused, jlong winOrView, jint src_x, jint src_y) @@ -209,7 +221,7 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnS /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: getInsets0 - * Signature: (J)Ljavax/media/nativewindow/util/Insets; + * Signature: (J)Lcom/jogamp/nativewindow/util/Insets; */ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetInsets0 (JNIEnv *env, jclass unused, jlong winOrView) @@ -264,7 +276,7 @@ JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetPixelScale0 NSArray *screens = [NSScreen screens]; if( screen_idx<0 || screen_idx>=[screens count] ) { screen = NULL; - pixelScale = 0.0; + pixelScale = 1.0; } else { screen = (NSScreen *) [screens objectAtIndex: screen_idx]; pixelScale = 1.0; // default @@ -282,9 +294,32 @@ NS_ENDHANDLER /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: GetPixelScale1 - * Signature: (J)D + * Signature: (I)D */ JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetPixelScale1 + (JNIEnv *env, jclass unused, jint displayID) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + CGFloat pixelScale; + NSScreen *screen = OSXUtil_getNSScreenByCGDirectDisplayID((CGDirectDisplayID)displayID); + pixelScale = 1.0; // default +NS_DURING + // Available >= 10.7 + pixelScale = [screen backingScaleFactor]; // HiDPI scaling +NS_HANDLER +NS_ENDHANDLER + [pool release]; + + return (jdouble)pixelScale; +} + +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: GetPixelScale1 + * Signature: (J)D + */ +JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetPixelScale2 (JNIEnv *env, jclass unused, jlong winOrView) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index 76143c426..29eed540b 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -26,7 +26,7 @@ #define DBG_PRINT_FLUSH(args...) #endif -static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; +static const char * const ClazzNamePoint = "com/jogamp/nativewindow/util/Point"; static const char * const ClazzAnyCstrName = "<init>"; static const char * const ClazzNamePointCstrSignature = "(II)V"; @@ -528,7 +528,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_windows_GDIUtil_getDummyWndProc /* * Class: jogamp_nativewindow_windows_GDIUtil * Method: GetRelativeLocation0 - * Signature: (JJII)Ljavax/media/nativewindow/util/Point; + * Signature: (JJII)Lcom/jogamp/nativewindow/util/Point; */ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDIUtil_GetRelativeLocation0 (JNIEnv *env, jclass unused, jlong jsrc_win, jlong jdest_win, jint src_x, jint src_y) diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index 247dc1311..a2e744cd8 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -98,7 +98,7 @@ static const char * const ClazzNameBuffers = "com/jogamp/common/nio/Buffers"; static const char * const ClazzNameBuffersStaticCstrName = "copyByteBuffer"; static const char * const ClazzNameBuffersStaticCstrSignature = "(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;"; static const char * const ClazzNameByteBuffer = "java/nio/ByteBuffer"; -static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; +static const char * const ClazzNamePoint = "com/jogamp/nativewindow/util/Point"; static const char * const ClazzAnyCstrName = "<init>"; static const char * const ClazzNamePointCstrSignature = "(II)V"; static jclass X11UtilClazz = NULL; @@ -669,7 +669,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_SetWindowPosSize /* * Class: jogamp_nativewindow_x11_X11Lib * Method: GetRelativeLocation - * Signature: (JIJJII)Ljavax/media/nativewindow/util/Point; + * Signature: (JIJJII)Lcom/jogamp/nativewindow/util/Point; */ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_x11_X11Lib_GetRelativeLocation0 (JNIEnv *env, jclass unused, jlong jdisplay, jint screen_index, jlong jsrc_win, jlong jdest_win, jint src_x, jint src_y) |