Re: SWT GLCanvas with DPI scaling in Eclipse
Posted by
Wade Walker on
Jan 23, 2018; 10:38pm
URL: https://forum.jogamp.org/SWT-GLCanvas-with-DPI-scaling-in-Eclipse-tp4038566p4038570.html
For my app (which uses Eclipse's SWT GL canvas instead of Jogamp's), I had to do some similar workarounds, because Eclipse's GL canvas reports the client area in pixels, but now all the mouse events are in scaled "SWT points".
As you alluded, I use the private API org.eclipse.swt.internal.DPIUtil.autoScaleUp() methods to convert my mouse events to pixels so everything matches again. It's a bit unsatisfactory to rely on an internal SWT API, but I guess you could also write your own version of DPIUtil if you have some way to query the scale factor. It appears that DPIUtil uses System.getProperty (SWT_AUTOSCALE) to query this factor (see
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/plain/bundles/org.eclipse.swt/Eclipse%20SWT/common/org/eclipse/swt/internal/DPIUtil.java), which should also work from user code.