diff options
author | Sven Gothel <[email protected]> | 2019-07-08 04:55:28 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-07-08 04:55:28 +0200 |
commit | f74e9c1597612edbff81425d4f2f528da5ebaf43 (patch) | |
tree | c45eaf4828f3a74b5066ed0f2e5dc8bf238364dc /src/newt/classes/jogamp | |
parent | a307ab505ed3fb5fe64f01478ce6d2933cd26c7d (diff) |
iOS / MacOS: PixelScale Update
- IOSUtil/OSXUtil: Return float value and refine name to GetScreenPixelScale*
- WindowDriver's updateMaxScreenPixelScaleByDisplayID(..) and updateMaxScreenPixelScaleByWindowHandle(..)
will only update the maxPixelScale, as actual user pixelSize change should not be triggered here.
A user pixelSize adaption to the changed underlying scale capabilities (e.g. switch monitor)
should be supported by the implemented WindowDriver's: updatePixelScale(..) called by native code.
Diffstat (limited to 'src/newt/classes/jogamp')
4 files changed, 47 insertions, 38 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java index 47280865d..daa033edb 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/ScreenDriver.java @@ -82,7 +82,7 @@ public class ScreenDriver extends ScreenImpl { // for(int crtIdx=0; crtIdx<count; crtIdx++) { final int crt_id = crtIDs[crtIdx]; - final float pixelScaleRaw = (float)IOSUtil.GetPixelScaleByDisplayID(crt_id); + final float pixelScaleRaw = IOSUtil.GetScreenPixelScaleByScreenIdx(crt_id); pixelScaleArray[crtIdx] = FloatUtil.isZero(pixelScaleRaw, FloatUtil.EPSILON) ? 1.0f : pixelScaleRaw; propsOrigArray[crtIdx] = getMonitorProps0(crt_id); if ( null == propsOrigArray[crtIdx] ) { diff --git a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java index 2a257436a..79c35c310 100644 --- a/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/ios/WindowDriver.java @@ -49,6 +49,7 @@ import jogamp.newt.driver.DriverUpdatePosition; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.math.FloatUtil; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { @@ -75,7 +76,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( SurfaceScaleUtils.setNewPixelScale(hasPixelScale, hasPixelScale, newPixelScale, minPixelScale, maxPixelScale, DEBUG_IMPLEMENTATION ? getClass().getName() : null) ) { if( sendEvent ) { - if( deferOffThread ) { + if( defer && deferOffThread ) { superSizeChangedOffThread(defer, getWidth(), getHeight(), true); } else { super.sizeChanged(defer, getWidth(), getHeight(), true); @@ -89,51 +90,55 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } - private boolean updatePixelScaleByDisplayID(final boolean sendEvent) { - final float maxPixelScaleRaw = (float) IOSUtil.GetPixelScaleByDisplayID(getDisplayID()); + /** + * Essentially updates {@code maxPixelScale} .. + */ + private boolean updateMaxScreenPixelScaleByDisplayID(final boolean sendEvent) { + final float maxPixelScaleRaw = IOSUtil.GetScreenPixelScaleByScreenIdx(getDisplayID()); if( DEBUG_IMPLEMENTATION ) { - System.err.println("WindowDriver.updatePixelScale.1: "+hasPixelScale[0]+", "+maxPixelScaleRaw+" (max)"); + System.err.println("WindowDriver.updatePixelScale.1: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", max "+maxPixelScaleRaw); } - return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, maxPixelScaleRaw, maxPixelScaleRaw); + return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, hasPixelScale[0], maxPixelScaleRaw); } - private boolean updatePixelScaleByWindowHandle(final boolean sendEvent) { + /** + * Essentially updates {@code maxPixelScale} .. + */ + private boolean updateMaxScreenPixelScaleByWindowHandle(final boolean sendEvent) { final long handle = getWindowHandle(); if( 0 != handle ) { - final float maxPixelScaleRaw = (float)IOSUtil.GetPixelScale(handle); + final float maxPixelScaleRaw = IOSUtil.GetScreenPixelScale(handle); if( DEBUG_IMPLEMENTATION ) { - System.err.println("WindowDriver.updatePixelScale.2: "+hasPixelScale[0]+", "+maxPixelScaleRaw+" (max)"); + System.err.println("WindowDriver.updatePixelScale.2: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", max "+maxPixelScaleRaw); } - return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, maxPixelScaleRaw, maxPixelScaleRaw); + return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, hasPixelScale[0], maxPixelScaleRaw); } else { return false; } } /** Called from native code */ - protected void updatePixelScale(final boolean defer, final float newPixelScaleRaw, final float maxPixelScaleRaw) { + protected void updatePixelScale(final boolean defer, final float oldPixelScaleRaw, final float newPixelScaleRaw, final float maxPixelScaleRaw, final boolean changed) { if( DEBUG_IMPLEMENTATION ) { - System.err.println("WindowDriver.updatePixelScale.3: "+hasPixelScale[0]+" (has) -> "+newPixelScaleRaw+" (new), "+maxPixelScaleRaw+" (max), drop "+!isNativeValid()); - } - if( isNativeValid() ) { - updatePixelScale(true /* sendEvent*/, defer, true /*offthread */, newPixelScaleRaw, maxPixelScaleRaw); + System.err.println("WindowDriver.updatePixelScale.3: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", old "+oldPixelScaleRaw+", new "+newPixelScaleRaw+", max "+maxPixelScaleRaw+", changed "+changed); } + updatePixelScale(true /* sendEvent*/, defer, true /*offthread */, newPixelScaleRaw, maxPixelScaleRaw); } @Override protected final void instantiationFinishedImpl() { - updatePixelScaleByDisplayID(false /* sendEvent*/); + updateMaxScreenPixelScaleByDisplayID(false /* sendEvent*/); } @Override protected void setScreen(final ScreenImpl newScreen) { // never null ! super.setScreen(newScreen); - updatePixelScaleByDisplayID(false /* sendEvent*/); // caller (reparent, ..) will send reshape event + updateMaxScreenPixelScaleByDisplayID(false /* sendEvent*/); // caller (reparent, ..) will send reshape event } @Override protected void monitorModeChanged(final MonitorEvent me, final boolean success) { - updatePixelScaleByWindowHandle(false /* sendEvent*/); // send reshape event itself + updateMaxScreenPixelScaleByWindowHandle(false /* sendEvent*/); // send reshape event itself } @Override @@ -441,7 +446,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl createWindow(false, 0 != oldWindowHandle, pClientLevelOnSreen, width, height, flags); } // no native event (fullscreen, some reparenting) - updatePixelScaleByWindowHandle(false /* sendEvent */); + updateMaxScreenPixelScaleByWindowHandle(false /* sendEvent */); if( isOffscreenInstance) { super.sizeChanged(false, width, height, true); positionChanged(false, x, y); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index ddeea265a..590f706df 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -88,7 +88,7 @@ public class ScreenDriver extends ScreenImpl { // for(int crtIdx=0; crtIdx<count; crtIdx++) { final int crt_id = crtIDs[crtIdx]; - final float pixelScaleRaw = (float)OSXUtil.GetPixelScaleByDisplayID(crt_id); + final float pixelScaleRaw = OSXUtil.GetScreenPixelScaleByDisplayID(crt_id); pixelScaleArray[crtIdx] = FloatUtil.isZero(pixelScaleRaw, FloatUtil.EPSILON) ? 1.0f : pixelScaleRaw; propsOrigArray[crtIdx] = getMonitorProps0(crt_id); if ( null == propsOrigArray[crtIdx] ) { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index e6ae7719c..1c6102f88 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -82,7 +82,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( SurfaceScaleUtils.setNewPixelScale(hasPixelScale, hasPixelScale, newPixelScale, minPixelScale, maxPixelScale, DEBUG_IMPLEMENTATION ? getClass().getName() : null) ) { if( sendEvent ) { - if( deferOffThread ) { + if( defer && deferOffThread ) { superSizeChangedOffThread(defer, getWidth(), getHeight(), true); } else { super.sizeChanged(defer, getWidth(), getHeight(), true); @@ -96,51 +96,55 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } - private boolean updatePixelScaleByDisplayID(final boolean sendEvent) { - final float maxPixelScaleRaw = (float) OSXUtil.GetPixelScaleByDisplayID(getDisplayID()); + /** + * Essentially updates {@code maxPixelScale} .. + */ + private boolean updateMaxScreenPixelScaleByDisplayID(final boolean sendEvent) { + final float maxPixelScaleRaw = OSXUtil.GetScreenPixelScaleByDisplayID(getDisplayID()); if( DEBUG_IMPLEMENTATION ) { - System.err.println("WindowDriver.updatePixelScale.1: "+hasPixelScale[0]+", "+maxPixelScaleRaw+" (max)"); + System.err.println("WindowDriver.updatePixelScale.1: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", max "+maxPixelScaleRaw); } - return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, maxPixelScaleRaw, maxPixelScaleRaw); + return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, hasPixelScale[0], maxPixelScaleRaw); } - private boolean updatePixelScaleByWindowHandle(final boolean sendEvent) { + /** + * Essentially updates {@code maxPixelScale} .. + */ + private boolean updateMaxScreenPixelScaleByWindowHandle(final boolean sendEvent) { final long handle = getWindowHandle(); if( 0 != handle ) { - final float maxPixelScaleRaw = (float)OSXUtil.GetPixelScale(handle); + final float maxPixelScaleRaw = OSXUtil.GetScreenPixelScale(handle); if( DEBUG_IMPLEMENTATION ) { - System.err.println("WindowDriver.updatePixelScale.2: "+hasPixelScale[0]+", "+maxPixelScaleRaw+" (max)"); + System.err.println("WindowDriver.updatePixelScale.2: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", max "+maxPixelScaleRaw); } - return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, maxPixelScaleRaw, maxPixelScaleRaw); + return updatePixelScale(sendEvent, true /* defer */, false /*offthread */, hasPixelScale[0], maxPixelScaleRaw); } else { return false; } } /** Called from native code */ - protected void updatePixelScale(final boolean defer, final float newPixelScaleRaw, final float maxPixelScaleRaw) { + protected void updatePixelScale(final boolean defer, final float oldPixelScaleRaw, final float newPixelScaleRaw, final float maxPixelScaleRaw, final boolean changed) { if( DEBUG_IMPLEMENTATION ) { - System.err.println("WindowDriver.updatePixelScale.3: "+hasPixelScale[0]+" (has) -> "+newPixelScaleRaw+" (new), "+maxPixelScaleRaw+" (max), drop "+!isNativeValid()); - } - if( isNativeValid() ) { - updatePixelScale(true /* sendEvent*/, defer, true /*offthread */, newPixelScaleRaw, maxPixelScaleRaw); + System.err.println("WindowDriver.updatePixelScale.3: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", old "+oldPixelScaleRaw+", new "+newPixelScaleRaw+", max "+maxPixelScaleRaw+", changed "+changed); } + updatePixelScale(true /* sendEvent*/, defer, true /*offthread */, newPixelScaleRaw, maxPixelScaleRaw); } @Override protected final void instantiationFinishedImpl() { - updatePixelScaleByDisplayID(false /* sendEvent*/); + updateMaxScreenPixelScaleByDisplayID(false /* sendEvent*/); } @Override protected void setScreen(final ScreenImpl newScreen) { // never null ! super.setScreen(newScreen); - updatePixelScaleByDisplayID(false /* sendEvent*/); // caller (reparent, ..) will send reshape event + updateMaxScreenPixelScaleByDisplayID(false /* sendEvent*/); // caller (reparent, ..) will send reshape event } @Override protected void monitorModeChanged(final MonitorEvent me, final boolean success) { - updatePixelScaleByWindowHandle(false /* sendEvent*/); // send reshape event itself + updateMaxScreenPixelScaleByWindowHandle(false /* sendEvent*/); // send reshape event itself } @Override @@ -448,7 +452,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl createWindow(false, 0 != oldWindowHandle, pClientLevelOnSreen, width, height, flags); } // no native event (fullscreen, some reparenting) - updatePixelScaleByWindowHandle(false /* sendEvent */); + updateMaxScreenPixelScaleByWindowHandle(false /* sendEvent */); if( isOffscreenInstance) { super.sizeChanged(false, width, height, true); positionChanged(false, x, y); |