aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-04-10 05:36:16 +0200
committerSven Gothel <[email protected]>2019-04-10 05:36:16 +0200
commitca7f0fb61b0a608b6e684a5bbde71f6ecb6e3fe0 (patch)
tree94a272f64d4343d223c914ecab68e379815a85f3 /src/newt
parentfc2edeb79e42897b926081769ad3cb3e509aed71 (diff)
Bug 1358: 'Honor' SWT's projection of High-DPI Scaling (Reading hidden pixel dimensions)
Christian reported this bug and described multiple pathways. This change usese the following: - access to getClientAreaInPixels w/ fallback of - DPIUtil.autoScaleUp(getClientArea()) I hardly have tested this on Linux/GTK, even though I use a High DPI monitor, maybe just because of it and Eclipse _poor_ state of proper UI presentation. Christian: Please test this .. if buggy, reopen quick for release 2.4.0 SWT/GTK High-DPI is a PIA: - GDK_SCALE renders offscreen and scales the image (wow & ugly) - GDK_DPI_SCALE works at least on the fonts properly - swt.autoScale is pretty much like: What will be scaled? It scales some icons in Eclipse, not fonts and result in Eclipse looks horrible. Maybe I just made this patch to vent about this poor state of things. Notable: KDE looks great and uses DPI, firefox some GDK_DPI_SCALE equivalent (OK) One also wonders why there is only a single scale dimension, where DPI differs x/y! But enough of my rant :)
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java63
1 files changed, 26 insertions, 37 deletions
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index d30dbe6dc..bd5c43d6c 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -79,7 +79,7 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
private WindowClosingMode newtChildClosingMode = WindowClosingMode.DISPOSE_ON_CLOSE;
private final WindowClosingMode closingMode = WindowClosingMode.DISPOSE_ON_CLOSE;
- private volatile Rectangle clientArea;
+ private volatile Rectangle clientAreaPixels, clientAreaWindow;
private volatile SWTNativeWindow nativeWindow;
private volatile Window newtChild = null;
@@ -129,7 +129,8 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
SWTAccessor.setRealized(this, true);
- clientArea = getClientArea();
+ clientAreaPixels = SWTAccessor.getClientAreaInPixels(this);
+ clientAreaWindow = getClientArea();
final AbstractGraphicsDevice device = SWTAccessor.getDevice(this);
screen = SWTAccessor.getScreen(device, -1 /* default */);
@@ -154,14 +155,14 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
if( null != nativeWindow || validateNative() ) {
if( newtChildReady ) {
if( postSetSize ) {
- newtChild.setSize(clientArea.width, clientArea.height);
+ newtChild.setSize(clientAreaPixels.width, clientAreaPixels.height);
postSetSize = false;
}
if( postSetPos ) {
- newtChild.setPosition(clientArea.x, clientArea.y);
+ newtChild.setPosition(clientAreaPixels.x, clientAreaPixels.y);
postSetPos = false;
}
- newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height);
+ newtChild.windowRepaint(0, 0, clientAreaPixels.width, clientAreaPixels.height);
}
}
break;
@@ -175,7 +176,7 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
if( DEBUG ) {
System.err.println("NewtCanvasSWT.Event.RESIZE, "+event);
}
- updateSizeCheck();
+ updatePosSizeCheck(false);
break;
case SWT.Dispose:
if( DEBUG ) {
@@ -204,14 +205,14 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
}
if( SWTAccessor.isOSX ) {
// Force newtChild to update its size and position (OSX only)
- updatePosSizeCheck(x, y, width, height, true /* updatePos */);
+ updatePosSizeCheck(true /* updatePos */);
}
}
/** assumes nativeWindow == null ! */
protected final boolean validateNative() {
- updateSizeCheck();
- final Rectangle nClientArea = clientArea;
+ updatePosSizeCheck(false);
+ final Rectangle nClientArea = clientAreaPixels;
if(0 >= nClientArea.width || 0 >= nClientArea.height) {
return false;
}
@@ -249,46 +250,34 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
return null != nativeWindow;
}
- protected final void updateSizeCheck() {
- final Rectangle nClientArea = getClientArea();
- if( null != nClientArea ) {
- updatePosSizeCheck(nClientArea.x, nClientArea.y, nClientArea.width, nClientArea.height, false /* updatePos */);
- }
- }
- protected final void updatePosSizeCheck() {
- final Rectangle nClientArea = getClientArea();
- if( null != nClientArea ) {
- updatePosSizeCheck(nClientArea.x, nClientArea.y, nClientArea.width, nClientArea.height, true /* updatePos */);
- }
- }
- protected final void updatePosSizeCheck(final int newX, final int newY, final int newWidth, final int newHeight, final boolean updatePos) {
+ protected final void updatePosSizeCheck(final boolean updatePos) {
final boolean sizeChanged, posChanged;
- final Rectangle nClientArea;
+ Rectangle nClientAreaPixels = SWTAccessor.getClientAreaInPixels(this);
{
- final Rectangle oClientArea = clientArea;
- sizeChanged = newWidth != oClientArea.width || newHeight != oClientArea.height;
- posChanged = newX != oClientArea.x || newY != oClientArea.y;
+ final Rectangle oClientAreaPixels = clientAreaPixels;
+ sizeChanged = nClientAreaPixels.width != oClientAreaPixels.width || nClientAreaPixels.height != oClientAreaPixels.height;
+ posChanged = nClientAreaPixels.x != oClientAreaPixels.x || nClientAreaPixels.y != oClientAreaPixels.y;
if( sizeChanged || posChanged ) {
- nClientArea = new Rectangle(updatePos ? newX : oClientArea.x, updatePos ? newY : oClientArea.y, newWidth, newHeight);
- clientArea = nClientArea;
+ clientAreaPixels = nClientAreaPixels;
+ clientAreaWindow = getClientArea();
} else {
- nClientArea = clientArea;
+ nClientAreaPixels = clientAreaPixels;
}
}
if(DEBUG) {
final long nsh = newtChildReady ? newtChild.getSurfaceHandle() : 0;
- System.err.println("NewtCanvasSWT.updatePosSizeCheck: sizeChanged "+sizeChanged+", posChanged "+posChanged+", updatePos "+updatePos+", ("+Thread.currentThread().getName()+"): newtChildReady "+newtChildReady+", "+nClientArea.x+"/"+nClientArea.y+" "+nClientArea.width+"x"+nClientArea.height+" - surfaceHandle 0x"+Long.toHexString(nsh));
+ System.err.println("NewtCanvasSWT.updatePosSizeCheck: sizeChanged "+sizeChanged+", posChanged "+posChanged+", updatePos "+updatePos+", ("+Thread.currentThread().getName()+"): newtChildReady "+newtChildReady+", "+nClientAreaPixels.x+"/"+nClientAreaPixels.y+" "+nClientAreaPixels.width+"x"+nClientAreaPixels.height+" - surfaceHandle 0x"+Long.toHexString(nsh));
}
if( sizeChanged ) {
if( newtChildReady ) {
- newtChild.setSize(nClientArea.width, nClientArea.height);
+ newtChild.setSize(nClientAreaPixels.width, nClientAreaPixels.height);
} else {
postSetSize = true;
}
}
if( updatePos && posChanged ) {
if( newtChildReady ) {
- newtChild.setPosition(nClientArea.x, nClientArea.y);
+ newtChild.setPosition(nClientAreaPixels.x, nClientAreaPixels.y);
} else {
postSetPos = true;
}
@@ -437,9 +426,9 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
newtChild.setFocusAction(null); // no AWT focus traversal ..
if(add) {
- updateSizeCheck();
- final int w = clientArea.width;
- final int h = clientArea.height;
+ updatePosSizeCheck(false);
+ final int w = clientAreaPixels.width;
+ final int h = clientAreaPixels.height;
// set SWT EDT and start it
{
@@ -557,12 +546,12 @@ public class NewtCanvasSWT extends Canvas implements NativeWindowHolder, WindowC
@Override
public int getSurfaceWidth() {
- return clientArea.width;
+ return clientAreaPixels.width;
}
@Override
public int getSurfaceHeight() {
- return clientArea.height;
+ return clientAreaPixels.height;
}
@Override