--- old/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java 2015-10-22 10:07:29.755072449 -0400 +++ new/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java 2015-10-22 10:07:29.415072436 -0400 @@ -43,6 +43,7 @@ import sun.java2d.loops.SurfaceType; import sun.awt.util.ThreadGroupUtils; +import sun.java2d.SunGraphicsEnvironment; import sun.misc.ManagedLocalsThread; /** @@ -63,9 +64,11 @@ private SunDisplayChanger topLevels = new SunDisplayChanger(); private DisplayMode origDisplayMode; private boolean shutdownHookRegistered; + private final int scale; public X11GraphicsDevice(int screennum) { this.screen = screennum; + this.scale = initScaleFactor(); } /* @@ -279,6 +282,7 @@ int width, int height, int displayMode); private static native void resetNativeData(int screen); + private static native int getNativeScaleFactor(int screen); /** * Returns true only if: @@ -509,6 +513,27 @@ topLevels.add(client); } + public int getScaleFactor() { + return scale; + } + + private int initScaleFactor() { + + if (SunGraphicsEnvironment.isUIScaleEnabled()) { + + double debugScale = SunGraphicsEnvironment.getDebugScale(); + + if (debugScale >= 1) { + return (int) debugScale; + } + + int nativeScale = getNativeScaleFactor(screen); + return nativeScale >= 1 ? nativeScale : 1; + } + + return 1; + } + /** * Remove a DisplayChangeListener from this X11GraphicsDevice. */