aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-01-04 17:18:02 +0100
committerSven Gothel <[email protected]>2020-01-04 17:18:02 +0100
commit7d7d4e4f194ed25dc8b450e13ab67020c607445b (patch)
tree2b1cd05475a6610af16fa9a0b3a876325c02fe35 /src
parentfb211581fefc994d1458a2a74801dfb937170f39 (diff)
Bug 1358: MacOS NEWT WindowDriver / NewtCanvasSWT High-DPI:
Even w/ commit fb211581fefc994d1458a2a74801dfb937170f39, propagating the SWT pixelScale to NEWT-Child, hasPixelScale was never updated via updatePixelScale() through native callback [NSView viewDidChangeBackingProperties]! [NSView viewDidChangeBackingProperties] not being called on [created] child windows (NewtCanvasSWT) confused the overal pixelScale state, i.e. no hasPixelScale update via updatePixelScale(..). This change explicitly queries OSXUtil.GetWindowPixelScale(handle) (commit e6d53e29f05a6928192f6c4a988b2aa558be8d65)for: 1) updateMaxScreenPixelScaleByWindowHandle(..), which now updates the actual hasPixelScale after native creation and for 2) setSurfaceScale(..), which directly calls updatePixelScale(..) with the queried actual pixelScale instead of relying on the native callback [NSView viewDidChangeBackingProperties].
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
index 18d1ebafa..636bfe9b2 100644
--- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java
@@ -109,16 +109,17 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
}
/**
- * Essentially updates {@code maxPixelScale} ..
+ * Essentially updates {@code hasPixelScale} and {@code maxPixelScale} ..
*/
private boolean updateMaxScreenPixelScaleByWindowHandle(final boolean sendEvent) {
final long handle = getWindowHandle();
if( 0 != handle ) {
final float maxPixelScaleRaw = OSXUtil.GetScreenPixelScale(handle);
+ final float newPixelScaleRaw = OSXUtil.GetWindowPixelScale(handle);
if( DEBUG_IMPLEMENTATION ) {
- System.err.println("WindowDriver.updatePixelScale.2: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", max "+maxPixelScaleRaw);
+ System.err.println("WindowDriver.updatePixelScale.2: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", new "+newPixelScaleRaw+", max "+maxPixelScaleRaw);
}
- return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, hasPixelScale[0], maxPixelScaleRaw);
+ return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, newPixelScaleRaw, maxPixelScaleRaw);
} else {
return false;
}
@@ -168,15 +169,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
changed = updatePixelScale(true /* sendEvent */, true /* defer */, true /*offthread */, reqPixelScale[0], maxPixelScale[0]); // HiDPI: uniformPixelScale
}
} else {
- // set pixelScale in native code, will issue an update updatePixelScale(..)
- // hence we pre-query whether pixel-scale will change, without affecting current state 'hasPixelScale'!
+ // setPixelScale0(..) _should_ issue an update updatePixelScale(..) via NSView::viewDidChangeBackingProperties
+ // We pre-query whether pixel-scale will change, without affecting current state 'hasPixelScale',
+ // but to issue setPixelScale0(..) only when required.
final float[] _hasPixelScale = new float[2];
System.arraycopy(hasPixelScale, 0, _hasPixelScale, 0, 2);
if( SurfaceScaleUtils.setNewPixelScale(_hasPixelScale, _hasPixelScale, reqPixelScale, minPixelScale, maxPixelScale, DEBUG_IMPLEMENTATION ? getClass().getName() : null) ) {
OSXUtil.RunOnMainThread(true, false, new Runnable() {
@Override
public void run() {
- setPixelScale0(getWindowHandle(), surfaceHandle, _hasPixelScale[0]); // HiDPI: uniformPixelScale
+ final long windowHandle = getWindowHandle();
+ setPixelScale0(windowHandle, surfaceHandle, _hasPixelScale[0]); // HiDPI: uniformPixelScale
+ // For some reason NSView::viewDidChangeBackingProperties won't get called on child windows after creation
+ // hence explicitly call it here.
+ final float newPixelScaleRaw = OSXUtil.GetWindowPixelScale(windowHandle);
+ updatePixelScale(true /* sendEvent */, true /* defer */, false /*offthread */, newPixelScaleRaw, maxPixelScale[0]);
}
} );
changed = true;
@@ -755,7 +762,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl
if(DEBUG_IMPLEMENTATION) {
System.err.println("MacWindow.createWindow on thread "+Thread.currentThread().getName()+
": offscreen "+offscreenInstance+", recreate "+recreate+
- ", pS "+pS+", "+width+"x"+height+", state "+getReconfigStateMaskString(flags)+
+ ", pS "+pS+", "+width+"x"+height+", reqPixelScale "+reqPixelScale[0]+", state "+getReconfigStateMaskString(flags)+
", preWinHandle "+toHexString(oldWinHandle)+", parentWin "+toHexString(parentWinHandle)+
", surfaceHandle "+toHexString(surfaceHandle));
// Thread.dumpStack();