mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-1834 [linux] runtime hidpi switch is broken
(cherry picked from commit eaa04303a7)
This commit is contained in:
committed by
alexey.ushakov@jetbrains.com
parent
95bd84812b
commit
6a5db5e5a8
@@ -70,8 +70,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
private boolean shutdownHookRegistered;
|
||||
private int scale;
|
||||
private final AtomicBoolean isScaleFactorDefault = new AtomicBoolean(false);
|
||||
private static final int XRM_XFT_DPI;
|
||||
private static volatile int XFT_DPI;
|
||||
private static volatile int xrmXftDpi;
|
||||
private static volatile int xftDpi;
|
||||
private static final int GDK_SCALE;
|
||||
private static final double GDK_DPI_SCALE;
|
||||
private static final double GDK_SCALE_MULTIPLIER;
|
||||
@@ -525,6 +525,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
*/
|
||||
@Override
|
||||
public synchronized void displayChanged() {
|
||||
xrmXftDpi = getXrmXftDpi(-1);
|
||||
scale = initScaleFactor(1);
|
||||
// On X11 the visuals do not change, and therefore we don't need
|
||||
// to reset the defaultConfig, config, doubleBufferVisuals,
|
||||
@@ -561,9 +562,9 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
}
|
||||
|
||||
public static void setXftDpi(int dpi) {
|
||||
XFT_DPI = dpi;
|
||||
xftDpi = dpi;
|
||||
boolean uiScaleEnabled = SunGraphicsEnvironment.isUIScaleEnabled(dpi);
|
||||
double xftDpiScale = uiScaleEnabled ? XFT_DPI / 96.0 : 1.0;
|
||||
double xftDpiScale = uiScaleEnabled ? xftDpi / 96.0 : 1.0;
|
||||
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
|
||||
X11GraphicsDevice x11gd = (X11GraphicsDevice)gd;
|
||||
synchronized (x11gd.isScaleFactorDefault) {
|
||||
@@ -588,11 +589,11 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
if (nativeScale > 0) {
|
||||
return (int)Math.round(nativeScale * gdkScaleMult);
|
||||
}
|
||||
if (XRM_XFT_DPI > 0) {
|
||||
return (int)Math.round((XRM_XFT_DPI / 96.0) * gdkScaleMult);
|
||||
if (xrmXftDpi > 0) {
|
||||
return (int)Math.round((xrmXftDpi / 96.0) * gdkScaleMult);
|
||||
}
|
||||
if (XFT_DPI > 0) {
|
||||
return (int)Math.round((XFT_DPI / 96.0) * gdkScaleMult);
|
||||
if (xftDpi > 0) {
|
||||
return (int)Math.round((xftDpi / 96.0) * gdkScaleMult);
|
||||
}
|
||||
}
|
||||
return defValue;
|
||||
@@ -602,8 +603,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
* Used externally for diagnostic purpose.
|
||||
*/
|
||||
public String[][] getDpiInfo() {
|
||||
int xftDpi = XRM_XFT_DPI != -1 ? XRM_XFT_DPI : XFT_DPI;
|
||||
String xftDpiStr = xftDpi != -1 ? String.valueOf(xftDpi) : "undefined";
|
||||
int dpi = xrmXftDpi != -1 ? xrmXftDpi : xftDpi;
|
||||
String xftDpiStr = dpi != -1 ? String.valueOf(dpi) : "undefined";
|
||||
double gsettingsScale = getNativeScaleFactor(screen, -1);
|
||||
String gsettingsScaleStr = gsettingsScale != -1 ? String.valueOf(gsettingsScale) : "undefined";
|
||||
String gdkScaleStr = GDK_SCALE != -1 ? String.valueOf(GDK_SCALE) : "undefined";
|
||||
|
||||
Reference in New Issue
Block a user