summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-01-05 23:02:55 +0100
committerSven Gothel <[email protected]>2020-01-05 23:02:55 +0100
commit8caf3fab68dc890855961d22cb235d1c8f5c52c6 (patch)
treed074f8d2a16557f1bd6963efddac0ca5dd37e9da /src/nativewindow/native
parent1216aa7bc4284e5568d7dd7bbd7f6d9fed27d25b (diff)
Bug 1358: GLCanvas: Call new OSXUtil.SetWindowPixelScale(..) when GLCanvas gets realized on MacOS
This fixes GLCanvas's High-DPI scaled size issue on MacOS of Bug 1358.
Diffstat (limited to 'src/nativewindow/native')
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 8cbfde8ed..091b1a67e 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -358,16 +358,13 @@ JNIEXPORT jfloat JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetWindowPixelS
NSObject *nsObj = (NSObject*) (intptr_t) winOrView;
NSWindow* win = NULL;
NSView* view = NULL;
- NSScreen *screen = NULL;
if( [nsObj isKindOfClass:[NSWindow class]] ) {
win = (NSWindow*) nsObj;
view = [win contentView];
- screen = [win screen];
} else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
view = (NSView*) nsObj;
win = [view window];
- screen = [win screen];
} else {
NativewindowCommon_throwNewRuntimeException(env, "neither win nor view %p\n", nsObj);
}
@@ -390,6 +387,43 @@ NS_ENDHANDLER
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method: SetWindowPixelScale1
+ * Signature: (JF)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_SetWindowPixelScale1
+ (JNIEnv *env, jclass unused, jlong winOrView, jfloat reqPixelScale)
+{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ NSObject *nsObj = (NSObject*) (intptr_t) winOrView;
+ NSWindow* win = NULL;
+ NSView* view = NULL;
+
+ if( [nsObj isKindOfClass:[NSWindow class]] ) {
+ win = (NSWindow*) nsObj;
+ view = [win contentView];
+ } else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
+ view = (NSView*) nsObj;
+ win = [view window];
+ } else {
+ NativewindowCommon_throwNewRuntimeException(env, "neither win nor view %p\n", nsObj);
+ }
+
+NS_DURING
+ // HiDPI scaling: Setup - Available >= 10.7
+ if( 1.0 == reqPixelScale ) {
+ [view setWantsBestResolutionOpenGLSurface: NO];
+ } else {
+ [view setWantsBestResolutionOpenGLSurface: YES];
+ }
+NS_HANDLER
+NS_ENDHANDLER
+
+ [pool release];
+}
+
+/*
+ * Class: Java_jogamp_nativewindow_macosx_OSXUtil
* Method: CreateNSWindow0
* Signature: (IIIIZ)J
*/