From 8caf3fab68dc890855961d22cb235d1c8f5c52c6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 5 Jan 2020 23:02:55 +0100 Subject: 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. --- src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java') 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; } -- cgit v1.2.3