< prev index next >
src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java
Print this page
@@ -30,11 +30,11 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Insets;
import java.awt.Window;
import java.util.Objects;
-
+import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.opengl.CGLGraphicsConfig;
public final class CGraphicsDevice extends GraphicsDevice
implements DisplayChangedListener {
@@ -138,11 +138,11 @@
@Override
public void displayChanged() {
xResolution = nativeGetXResolution(displayID);
yResolution = nativeGetYResolution(displayID);
- scale = (int) nativeGetScaleFactor(displayID);
+ initScaleFactor();
//TODO configs/fullscreenWindow/modes?
}
@Override
public void paletteChanged() {
@@ -247,10 +247,21 @@
@Override
public DisplayMode[] getDisplayModes() {
return nativeGetDisplayModes(displayID);
}
+ private void initScaleFactor() {
+ if (SunGraphicsEnvironment.isUIScaleEnabled()) {
+ double debugScale = SunGraphicsEnvironment.getDebugScale();
+ scale = (int) (debugScale >= 1
+ ? Math.round(debugScale)
+ : nativeGetScaleFactor(displayID));
+ } else {
+ scale = 1;
+ }
+ }
+
private static native double nativeGetScaleFactor(int displayID);
private static native void nativeSetDisplayMode(int displayID, int w, int h, int bpp, int refrate);
private static native DisplayMode nativeGetDisplayMode(int displayID);
< prev index next >