aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-05-14 05:41:22 +0200
committerSven Gothel <[email protected]>2023-05-14 05:41:22 +0200
commit9d1e7c9adca97780a5b45b135c5693cffee218fc (patch)
tree454a8afe6c9f5d4d31efed60403476e0a7fe5092 /src/newt/classes/jogamp
parentcfe56e9e6bda15873fefce6f03d343ccdfc51f9b (diff)
HiDPI AWT/NEWT: Propagate AWT enforced pixelScale via setSurfaceScale() blocking native change by monitor-pixelScale (Windows, X11)
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java38
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java2
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java2
3 files changed, 12 insertions, 30 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index c860e4c3e..8632dc5f4 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -163,6 +163,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
protected final float[] maxPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
protected final float[] hasPixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
protected final float[] reqPixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
+ private boolean hasSetPixelScale = false;
private volatile int[] pixelPos = new int[] { 64, 64 }; // client-area pos w/o insets in pixel units
private volatile int[] pixelSize = new int[] { 128, 128 }; // client-area size w/o insets in pixel units, default: may be overwritten by user
private volatile int[] windowPos = new int[] { 64, 64 }; // client-area pos w/o insets in window units
@@ -2695,15 +2696,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
/**
* {@inheritDoc}
- * <p>
- * FIXME: Bug 1373, 1374: Implement general High-DPI for even non native DPI toolkit aware platforms (Linux, Windows)
- * </p>
*/
@Override
public boolean setSurfaceScale(final float[] pixelScale) {
+ final boolean isAuto = SurfaceScaleUtils.isEqual(pixelScale, ScalableSurface.AUTOMAX_PIXELSCALE);
+ if( DEBUG_IMPLEMENTATION ) {
+ System.err.println("WindowImpl.setPixelScale.0: has["+hasPixelScale[0]+", "+hasPixelScale[1]+"], req["+
+ reqPixelScale[0]+", "+reqPixelScale[1]+"] -> req["+
+ pixelScale[0]+", "+pixelScale[1]+"], isAuto "+isAuto+", realized "+isNativeValid());
+ }
System.arraycopy(pixelScale, 0, reqPixelScale, 0, 2);
+ hasSetPixelScale = !isAuto;
return false;
}
+ protected boolean hasSetPixelScale() { return hasSetPixelScale; }
@Override
public final float[] getRequestedSurfaceScale(final float[] result) {
@@ -2967,7 +2973,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
boolean res = false;
if( DEBUG_IMPLEMENTATION ) {
System.err.println("Window.SoftPixelScale.0a: req "+reqPixelScale[0]+", has "+hasPixelScale[0]+", new "+newPixelScale[0]+" - "+getThreadName());
- // Thread.dumpStack();
+ Thread.dumpStack();
}
synchronized( scaleLock ) {
try {
@@ -5245,30 +5251,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
// Misc
//
- /**
- * Notify to update the pixel-scale values.
- * <p>
- * FIXME: Bug 1373, 1374: Implement general High-DPI for even non native DPI toolkit aware platforms (Linux, Windows)
- * A variation may be be desired like
- * {@code pixelScaleChangeNotify(final float[] curPixelScale, final float[] minPixelScale, final float[] maxPixelScale)}.
- * </p>
- * <p>
- * Maybe create interface {@code ScalableSurface.Upstream} with above method,
- * to allow downstream to notify upstream ScalableSurface implementations like NEWT's {@link Window} to act accordingly.
- * </p>
- * @param minPixelScale
- * @param maxPixelScale
- * @param reset if {@code true} {@link #setSurfaceScale(float[]) reset pixel-scale} w/ {@link #getRequestedSurfaceScale(float[]) requested values}
- * value to reflect the new minimum and maximum values.
- */
- public final void pixelScaleChangeNotify(final float[] minPixelScale, final float[] maxPixelScale, final boolean reset) {
- System.arraycopy(minPixelScale, 0, this.minPixelScale, 0, 2);
- System.arraycopy(maxPixelScale, 0, this.maxPixelScale, 0, 2);
- if( reset ) {
- setSurfaceScale(reqPixelScale);
- }
- }
-
@Override
public final void windowRepaint(final int x, final int y, final int width, final int height) {
windowRepaint(false, x, y, width, height);
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
index 1605d4126..b95911adf 100644
--- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java
@@ -76,7 +76,7 @@ public class WindowDriver extends WindowImpl {
*/
private boolean updatePixelScaleByMonitor(final long crt_handle, final int[] move_diff, final boolean sendEvent, final boolean defer) {
boolean res = false;
- if( 0 != crt_handle ) {
+ if( !hasSetPixelScale() && 0 != crt_handle ) {
final float newPixelScaleRaw[] = { 0, 0 };
if( GDIUtil.GetMonitorPixelScale(crt_handle, newPixelScaleRaw) ) {
res = applySoftPixelScale(move_diff, sendEvent, defer, newPixelScaleRaw);
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index 5fb01c619..e939edeae 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -105,7 +105,7 @@ public class WindowDriver extends WindowImpl {
*/
private boolean updatePixelScaleByMonitor(final MonitorDevice md, final int[] move_diff, final boolean sendEvent, final boolean defer) {
boolean res = false;
- if( null != md ) {
+ if( !hasSetPixelScale() && null != md ) {
final float newPixelScale[] = { 0, 0 };
md.getPixelScale(newPixelScale);
if( DEBUG_IMPLEMENTATION ) {