mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-4389 IDEA UI font becomes too large after disconnecting the external monitor / sleep
This commit is contained in:
@@ -41,12 +41,14 @@ import sun.java2d.SunGraphicsEnvironment;
|
||||
import sun.java2d.MacOSFlags;
|
||||
import sun.java2d.metal.MTLGraphicsConfig;
|
||||
import sun.java2d.opengl.CGLGraphicsConfig;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import static java.awt.peer.ComponentPeer.SET_BOUNDS;
|
||||
|
||||
public final class CGraphicsDevice extends GraphicsDevice
|
||||
implements DisplayChangedListener {
|
||||
|
||||
private static final PlatformLogger logger = PlatformLogger.getLogger(CGraphicsDevice.class.getName());
|
||||
/**
|
||||
* CoreGraphics display ID. This identifier can become non-valid at any time
|
||||
* therefore methods, which is using this id should be ready to it.
|
||||
@@ -381,6 +383,7 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
}
|
||||
|
||||
private void initScaleFactor() {
|
||||
int _scale = scale;
|
||||
if (SunGraphicsEnvironment.isUIScaleEnabled()) {
|
||||
double debugScale = SunGraphicsEnvironment.getDebugScale();
|
||||
scale = (int) (debugScale >= 1
|
||||
@@ -389,6 +392,9 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
} else {
|
||||
scale = 1;
|
||||
}
|
||||
if (_scale != scale && logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
logger.fine("current scale = " + _scale + ", new scale = " + scale + " (" + this + ")");
|
||||
}
|
||||
}
|
||||
|
||||
private static native double nativeGetScaleFactor(int displayID);
|
||||
|
||||
@@ -31,8 +31,10 @@ import sun.java2d.NullSurfaceData;
|
||||
import sun.lwawt.LWWindowPeer;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.lwawt.macosx.CFLayer;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
public class CGLLayer extends CFLayer {
|
||||
private static final PlatformLogger logger = PlatformLogger.getLogger(CGLLayer.class.getName());
|
||||
|
||||
private native long nativeCreateLayer();
|
||||
private static native void nativeSetScale(long layerPtr, double scale);
|
||||
@@ -46,6 +48,14 @@ public class CGLLayer extends CFLayer {
|
||||
|
||||
setPtr(nativeCreateLayer());
|
||||
this.peer = peer;
|
||||
|
||||
CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
logger.fine("device = " + (gc != null ? gc.getDevice() : "null"));
|
||||
}
|
||||
if (gc != null) {
|
||||
setScale(gc.getDevice().getScaleFactor());
|
||||
}
|
||||
}
|
||||
|
||||
public SurfaceData replaceSurfaceData() {
|
||||
@@ -94,8 +104,12 @@ public class CGLLayer extends CFLayer {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private void setScale(final int _scale) {
|
||||
private void setScale(int _scale) {
|
||||
if (scale != _scale) {
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
|
||||
logger.fine("current scale = " + scale + ", new scale = " + _scale + " (device = " + (gc != null ? gc.getDevice() : "null") + ")");
|
||||
}
|
||||
scale = _scale;
|
||||
execute(ptr -> nativeSetScale(ptr, scale));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user