Revert "JBR-3688 PyCharm incredibly slow with fakexrandr"

This reverts commit 0aef3419
This commit is contained in:
Maxim Kartashev
2023-05-24 19:48:37 +03:00
committed by Vitaly Provodin
parent 85f65db694
commit cd781631a8
3 changed files with 3 additions and 67 deletions

View File

@@ -119,7 +119,6 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
@@ -649,15 +648,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
try {
((X11GraphicsEnvironment)GraphicsEnvironment.
getLocalGraphicsEnvironment()).rebuildDevices();
if (useCachedInsets) resetScreenInsetsCache();
} finally {
awtLock();
}
} else if (useCachedInsets) {
final XAtom XA_NET_WORKAREA = XAtom.get("_NET_WORKAREA");
final boolean rootWindowWorkareaResized = (ev.get_type() == XConstants.PropertyNotify
&& ev.get_xproperty().get_atom() == XA_NET_WORKAREA.getAtom());
if (rootWindowWorkareaResized) resetScreenInsetsCache();
}
}
});
@@ -1156,7 +1149,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
* When two screens overlap and the first contains a dock(*****), then
* _NET_WORKAREA may start at point x1,y1 and end at point x2,y2.
*/
private Insets getScreenInsetsImpl(final GraphicsConfiguration gc) {
@Override
public Insets getScreenInsets(final GraphicsConfiguration gc) {
GraphicsDevice gd = gc.getDevice();
XNETProtocol np = XWM.getWM().getNETProtocol();
if (np == null || !(gd instanceof X11GraphicsDevice) || !np.active()) {
@@ -1195,20 +1189,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
}
private final Hashtable<GraphicsConfiguration, Insets> cachedInsets = new Hashtable<>();
private void resetScreenInsetsCache() {
cachedInsets.clear();
}
@Override
public Insets getScreenInsets(final GraphicsConfiguration gc) {
if (useCachedInsets) {
return cachedInsets.computeIfAbsent(gc, this::getScreenInsetsImpl);
} else {
return getScreenInsetsImpl(gc);
}
}
/*
* The current implementation of disabling background erasing for
* canvases is that we don't set any native background color
@@ -2950,8 +2930,4 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
boolean isWindowMoveSupported() {
return XWM.isWMMoveResizeSupported();
}
@SuppressWarnings("removal")
private static final boolean useCachedInsets = Boolean.parseBoolean(AccessController.doPrivileged(
new GetPropertyAction("x11.cache.screen.insets", "true")));
}

View File

@@ -38,7 +38,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.atomic.AtomicBoolean;
import sun.security.action.GetPropertyAction;
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.SunGraphicsEnvironment;
@@ -153,7 +152,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
return Region.clipRound(s + (y - s) / (double)getScaleFactor());
}
private Rectangle getBoundsImpl() {
public Rectangle getBounds() {
Rectangle rect = pGetBounds(getScreen());
if (getScaleFactor() != 1) {
rect.width = scaleDown(rect.width);
@@ -162,28 +161,6 @@ public final class X11GraphicsDevice extends GraphicsDevice
return rect;
}
private Rectangle boundsCached;
private synchronized Rectangle getBoundsCached() {
if (boundsCached == null) {
boundsCached = getBoundsImpl();
}
return boundsCached;
}
public synchronized void resetBoundsCache() {
boundsCached = null;
}
public Rectangle getBounds() {
if (X11GraphicsEnvironment.useBoundsCache()) {
return getBoundsCached();
}
else {
return getBoundsImpl();
}
}
/**
* Returns the identification string associated with this graphics
* device.
@@ -681,6 +658,5 @@ public final class X11GraphicsDevice extends GraphicsDevice
assert XToolkit.isAWTLockHeldByCurrentThread();
screen = device.screen;
if (X11GraphicsEnvironment.useBoundsCache()) resetBoundsCache();
}
}

View File

@@ -38,8 +38,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
import sun.awt.X11.XToolkit;
import sun.java2d.SunGraphicsEnvironment;
@@ -276,12 +274,6 @@ public final class X11GraphicsEnvironment extends SunGraphicsEnvironment {
it.remove();
}
}
if (useBoundsCache()) {
for (final X11GraphicsDevice gd : devices.values()) {
gd.resetBoundsCache();
}
}
}
@Override
@@ -410,12 +402,4 @@ public final class X11GraphicsEnvironment extends SunGraphicsEnvironment {
@Override
public void paletteChanged() {
}
@SuppressWarnings("removal")
private static final boolean cacheScreenBoundsValue = Boolean.parseBoolean(AccessController.doPrivileged(
new GetPropertyAction("x11.cache.screen.bounds", "true")));
public static boolean useBoundsCache() {
return cacheScreenBoundsValue;
}
}