< prev index next >
src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java
Print this page
@@ -41,10 +41,11 @@
import sun.java2d.opengl.GLXGraphicsConfig;
import sun.java2d.xr.XRGraphicsConfig;
import sun.java2d.loops.SurfaceType;
import sun.awt.util.ThreadGroupUtils;
+import sun.java2d.SunGraphicsEnvironment;
import sun.misc.ManagedLocalsThread;
/**
* This is an implementation of a GraphicsDevice object for a single
* X11 screen.
@@ -61,13 +62,15 @@
private static Boolean xrandrExtSupported;
private final Object configLock = new Object();
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();
}
/*
* Initialize JNI field and method IDs for fields that may be
* accessed from C.
@@ -277,10 +280,11 @@
ArrayList<DisplayMode> modes);
private static native void configDisplayMode(int screen,
int width, int height,
int displayMode);
private static native void resetNativeData(int screen);
+ private static native int getNativeScaleFactor(int screen);
/**
* Returns true only if:
* - the Xrandr extension is present
* - the necessary Xrandr functions were loaded successfully
@@ -507,10 +511,31 @@
*/
public void addDisplayChangedListener(DisplayChangedListener client) {
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.
*/
public void removeDisplayChangedListener(DisplayChangedListener client) {
topLevels.remove(client);
< prev index next >