diff options
author | Sven Gothel <[email protected]> | 2020-01-05 23:02:55 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-01-05 23:02:55 +0100 |
commit | 8caf3fab68dc890855961d22cb235d1c8f5c52c6 (patch) | |
tree | d074f8d2a16557f1bd6963efddac0ca5dd37e9da /src/jogl/classes | |
parent | 1216aa7bc4284e5568d7dd7bbd7f6d9fed27d25b (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/jogl/classes')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 5e90c4035..6ca53b3f2 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -55,6 +55,7 @@ import com.jogamp.opengl.GLRunnable; import com.jogamp.opengl.GLSharedContextSetter; import com.jogamp.opengl.Threading; +import jogamp.nativewindow.macosx.OSXUtil; import jogamp.nativewindow.x11.X11Util; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; @@ -64,6 +65,7 @@ import jogamp.opengl.GLDrawableImpl; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.internal.DPIUtil; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; @@ -581,6 +583,15 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS } } else { nativeWindowHandle = SWTAccessor.getWindowHandle(this); + if( SWTAccessor.isOSX ) { + final float reqPixelScale = DPIUtil.autoScaleUp(this, 1f); + if( DEBUG ) { + System.err.println(getThreadName()+": SWT.GLCanvas.OSX "+toHexString(hashCode())+": Scaling: devZoom "+DPIUtil.getDeviceZoom()+", general "+DPIUtil.autoScaleUp(1f)+", onWidged "+reqPixelScale); + } + if( reqPixelScale > 1f ) { + OSXUtil.SetWindowPixelScale(nativeWindowHandle, reqPixelScale); + } + } } final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); @@ -593,11 +604,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextS if(!_drawable.isRealized()) { // oops if(DEBUG) { + System.err.println(getThreadName()+": SWT.GLCanvas.validate.X "+proxySurface); System.err.println(getThreadName()+": SWT.GLCanvas.validate.X "+toHexString(hashCode())+": Drawable could not be realized: "+_drawable); } } else { if(DEBUG) { - System.err.println(getThreadName()+": SWT.GLCanvas.validate "+toHexString(hashCode())+": Drawable created and realized"); + System.err.println(getThreadName()+": SWT.GLCanvas.validate "+proxySurface); + System.err.println(getThreadName()+": SWT.GLCanvas.validate "+toHexString(hashCode())+": Drawable created and realized: "+_drawable); } drawable = _drawable; } |