mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-26 10:20:49 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9182819b00 |
@@ -160,19 +160,13 @@ public final class UnixDomainSocketAddress extends SocketAddress {
|
||||
* @throws NullPointerException if path is {@code null}
|
||||
*/
|
||||
public static UnixDomainSocketAddress of(Path path) {
|
||||
final FileSystem fs = path.getFileSystem();
|
||||
final FileSystem defaultFS = sun.nio.fs.DefaultFileSystemProvider.theFileSystem();
|
||||
if (fs != defaultFS || fs.getClass().getModule() != Object.class.getModule()) {
|
||||
try {
|
||||
// Check if we'll be able to create a socket from this Path later on by
|
||||
// testing for the presence of a method identical to
|
||||
// AbstractFileSystemProvider.getSunPathForSocketFile()
|
||||
fs.provider().getClass().getMethod("getSunPathForSocketFile", Path.class);
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
FileSystem fs = path.getFileSystem();
|
||||
if (fs != FileSystems.getDefault()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (fs.getClass().getModule() != Object.class.getModule()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
return new UnixDomainSocketAddress(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,22 +99,8 @@ class UnixDomainSockets {
|
||||
}
|
||||
|
||||
static byte[] getPathBytes(Path path) {
|
||||
java.nio.file.FileSystem fs = path.getFileSystem();
|
||||
FileSystemProvider provider = fs.provider();
|
||||
if (fs == sun.nio.fs.DefaultFileSystemProvider.theFileSystem()) {
|
||||
return ((AbstractFileSystemProvider) provider).getSunPathForSocketFile(path);
|
||||
} else {
|
||||
try {
|
||||
java.lang.reflect.Method method = provider.getClass().getMethod("getSunPathForSocketFile", Path.class);
|
||||
Object result = method.invoke(provider, path);
|
||||
return (byte[]) result;
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
// This should've been verified when UnixDomainSocketAddress was created
|
||||
throw new Error("Can't find getSunPathForSocketFile(Path) in the non-default file system provider " + provider.getClass());
|
||||
} catch (java.lang.reflect.InvocationTargetException | IllegalAccessException e) {
|
||||
throw new RuntimeException("Can't invoke getSunPathForSocketFile(Path) from a non-default file system provider", e);
|
||||
}
|
||||
}
|
||||
FileSystemProvider provider = FileSystems.getDefault().provider();
|
||||
return ((AbstractFileSystemProvider) provider).getSunPathForSocketFile(path);
|
||||
}
|
||||
|
||||
static FileDescriptor socket() throws IOException {
|
||||
@@ -150,11 +136,13 @@ class UnixDomainSockets {
|
||||
int rnd = random.nextInt(Integer.MAX_VALUE);
|
||||
try {
|
||||
final Path path = Path.of(dir, "socket_" + rnd);
|
||||
if (path.getFileSystem().provider() != sun.nio.fs.DefaultFileSystemProvider.instance()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unix Domain Sockets not supported on non-default file system");
|
||||
}
|
||||
return UnixDomainSocketAddress.of(path);
|
||||
} catch (InvalidPathException e) {
|
||||
throw new BindException("Invalid temporary directory");
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new UnsupportedOperationException("Unix Domain Sockets not supported on non-default file system without method getSunPathForSocketFile(Path)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ BOOL isDisplaySyncEnabled() {
|
||||
self.framebufferOnly = YES;
|
||||
self.nextDrawableCount = 0;
|
||||
self.opaque = YES;
|
||||
self.presentsWithTransaction = YES;
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -132,7 +133,6 @@ BOOL isDisplaySyncEnabled() {
|
||||
destinationOrigin:MTLOriginMake(0, 0, 0)];
|
||||
[blitEncoder endEncoding];
|
||||
|
||||
[commandBuf presentDrawable:mtlDrawable];
|
||||
__block MTLLayer* layer = self;
|
||||
[layer retain];
|
||||
[commandBuf addCompletedHandler:^(id <MTLCommandBuffer> commandBuf) {
|
||||
@@ -141,6 +141,8 @@ BOOL isDisplaySyncEnabled() {
|
||||
}];
|
||||
|
||||
[commandBuf commit];
|
||||
[commandBuf waitUntilScheduled];
|
||||
[mtlDrawable present];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -307,8 +307,8 @@ public class XBaseWindow {
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected int scaleUp(int i) {
|
||||
return i;
|
||||
protected int scaleUp(int x) {
|
||||
return x;
|
||||
}
|
||||
protected int scaleUpX(int x) {
|
||||
return x;
|
||||
@@ -317,8 +317,8 @@ public class XBaseWindow {
|
||||
return y;
|
||||
}
|
||||
|
||||
protected int scaleDown(int i) {
|
||||
return i;
|
||||
protected int scaleDown(int x) {
|
||||
return x;
|
||||
}
|
||||
protected int scaleDownX(int x) {
|
||||
return x;
|
||||
|
||||
@@ -50,14 +50,11 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
// reparented - indicates that WM has adopted the top-level.
|
||||
boolean configure_seen;
|
||||
boolean insets_corrected;
|
||||
// Set to true after reconfigureContentWindow is called for the first time.
|
||||
// Before this, content window may not be in sync with insets.
|
||||
private boolean content_reconfigured;
|
||||
|
||||
XIconWindow iconWindow;
|
||||
volatile WindowDimensions dimensions;
|
||||
XContentWindow content;
|
||||
private volatile Insets currentInsets; // Device-space
|
||||
volatile Insets currentInsets;
|
||||
XFocusProxyWindow focusProxy;
|
||||
static final Map<Class<?>,Insets> lastKnownInsets =
|
||||
Collections.synchronizedMap(new HashMap<>());
|
||||
@@ -308,6 +305,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets);
|
||||
}
|
||||
|
||||
if (wm_set_insets != null) {
|
||||
wm_set_insets = copyAndScaleDown(wm_set_insets);
|
||||
}
|
||||
return wm_set_insets;
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
wm_set_insets = null;
|
||||
Insets in = getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||
if (isReparented() && (!isMapped() || getMWMDecorTitleProperty().isPresent()) &&
|
||||
in != null && !copyAndScaleDown(in).equals(dimensions.getInsets())) {
|
||||
in != null && !in.equals(dimensions.getInsets())) {
|
||||
handleCorrectInsets(in);
|
||||
}
|
||||
} else {
|
||||
@@ -359,7 +359,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
if (!isEmbedded() && !isTargetUndecorated()) {
|
||||
lastKnownInsets.put(getClass(), in);
|
||||
}
|
||||
if (!copyAndScaleDown(in).equals(dimensions.getInsets())) {
|
||||
if (!in.equals(dimensions.getInsets())) {
|
||||
if (insets_corrected || isMaximized()) {
|
||||
currentInsets = in;
|
||||
insets_corrected = true;
|
||||
@@ -444,7 +444,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
// If these insets are equal to our current insets - no actions are necessary
|
||||
Insets dimInsets = dimensions.getInsets();
|
||||
if (copyAndScaleDown(correctWM).equals(dimInsets)) {
|
||||
if (correctWM.equals(dimInsets)) {
|
||||
insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
|
||||
no_reparent_artifacts = true;
|
||||
insets_corrected = true;
|
||||
@@ -453,6 +453,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
} else {
|
||||
correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
|
||||
if (correctWM != null) {
|
||||
correctWM = copyAndScaleDown(correctWM);
|
||||
}
|
||||
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
if (correctWM != null) {
|
||||
@@ -525,11 +528,14 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
} else {
|
||||
if (!isNull(currentInsets)) {
|
||||
/* insets were set on wdata by System Properties */
|
||||
return currentInsets;
|
||||
return copy(currentInsets);
|
||||
} else {
|
||||
Insets res = getWMSetInsets(null);
|
||||
if (res == null) {
|
||||
res = XWM.getWM().guessInsets(this);
|
||||
if (res != null) {
|
||||
res = copyAndScaleDown(res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -541,20 +547,15 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
currentInsets = copy(guessed);
|
||||
}
|
||||
|
||||
@Override
|
||||
Insets getRealUnscaledInsets() {
|
||||
private Insets getRealInsets() {
|
||||
if (isNull(currentInsets)) {
|
||||
applyGuessedInsets();
|
||||
}
|
||||
return currentInsets;
|
||||
}
|
||||
|
||||
Insets getRealInsets() {
|
||||
return copyAndScaleDown(getRealUnscaledInsets());
|
||||
}
|
||||
|
||||
public Insets getInsets() {
|
||||
Insets in = getRealInsets();
|
||||
Insets in = copy(getRealInsets());
|
||||
in.top += getMenuBarHeight();
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
|
||||
insLog.finest("Get insets returns {0}", in);
|
||||
@@ -695,7 +696,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
break;
|
||||
case SET_CLIENT_SIZE: {
|
||||
// Sets client rect size. Width and height contain insets.
|
||||
Insets in = getRealInsets();
|
||||
Insets in = currentInsets;
|
||||
width -= in.left+in.right;
|
||||
height -= in.top+in.bottom;
|
||||
dims.setClientSize(width, height);
|
||||
@@ -739,7 +740,6 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
return;
|
||||
}
|
||||
content.setContentBounds(dims);
|
||||
content_reconfigured = true;
|
||||
}
|
||||
|
||||
private XEvent pendingConfigureEvent;
|
||||
@@ -839,7 +839,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
}
|
||||
if (correctWM != null) {
|
||||
handleCorrectInsets(correctWM);
|
||||
handleCorrectInsets(copyAndScaleDown(correctWM));
|
||||
} else {
|
||||
//Only one attempt to correct insets is made (to lower risk)
|
||||
//if insets are still not available we simply set the flag
|
||||
@@ -849,23 +849,23 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
|
||||
updateChildrenSizes();
|
||||
|
||||
WindowLocation newLocation = getNewLocation(xe);
|
||||
Dimension newDimension = new Dimension(xe.get_width(), xe.get_height());
|
||||
boolean xinerama = XToolkit.localEnv.runningXinerama();
|
||||
Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
|
||||
WindowDimensions newDimensions =
|
||||
new WindowDimensions(newLocation,
|
||||
new Dimension(scaleDown(xe.get_width()),
|
||||
scaleDown(xe.get_height())),
|
||||
copy(currentInsets), true);
|
||||
|
||||
SunToolkit.executeOnEventHandlerThread(target, () -> {
|
||||
Point newUserLocation = newLocation.getUserLocation();
|
||||
WindowDimensions newDimensions = new WindowDimensions(newUserLocation,
|
||||
new Dimension(scaleDown(newDimension.width), scaleDown(newDimension.height)), getRealInsets(), true);
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
insLog.finer("Insets are {0}, new dimensions {1}",
|
||||
currentInsets, newDimensions);
|
||||
}
|
||||
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
insLog.finer("Insets are {0}, new dimensions {1}",
|
||||
getRealInsets(), newDimensions);
|
||||
}
|
||||
checkIfOnNewScreen(newDimensions.getBounds(), () -> {
|
||||
|
||||
Point oldLocation = getLocation();
|
||||
dimensions = newDimensions;
|
||||
if (!newUserLocation.equals(oldLocation)) {
|
||||
if (!newLocation.equals(oldLocation)) {
|
||||
handleMoved(newDimensions);
|
||||
}
|
||||
reconfigureContentWindow(newDimensions);
|
||||
@@ -873,20 +873,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
|
||||
repositionSecurityWarning();
|
||||
|
||||
if (xinerama) {
|
||||
checkIfOnNewScreen(new Rectangle(newLocation.getDeviceLocation(), newDimension));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
WindowLocation queryXLocation() {
|
||||
XContentWindow c = content;
|
||||
boolean client = c == null || !content_reconfigured;
|
||||
return new WindowLocation(XlibUtil.translateCoordinates(client ? window : c.getWindow(),
|
||||
XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()), 0, 0), client);
|
||||
}
|
||||
|
||||
private void checkShellRectSize(Rectangle shellRect) {
|
||||
shellRect.width = Math.max(MIN_SIZE, shellRect.width);
|
||||
shellRect.height = Math.max(MIN_SIZE, shellRect.height);
|
||||
@@ -1412,28 +1401,13 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
return getMWMDecorTitleProperty().orElse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
void syncBounds() {
|
||||
Rectangle r = target.getBounds();
|
||||
if (syncSizeOnly && dimensions != null) {
|
||||
dimensions.setSize(r.width, r.height);
|
||||
dimensions.setInsets(getRealInsets());
|
||||
xSetSize(r.width, r.height);
|
||||
} else {
|
||||
dimensions = new WindowDimensions(r, getRealInsets(), false);
|
||||
xSetBounds(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
reconfigureContentWindow(dimensions);
|
||||
doValidateSurface();
|
||||
layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateGraphicsData(GraphicsConfiguration gc) {
|
||||
boolean ret = super.updateGraphicsData(gc);
|
||||
if (content != null) {
|
||||
content.initGraphicsConfiguration();
|
||||
content.syncBounds();
|
||||
}
|
||||
boolean ret = super.updateGraphicsData(gc);
|
||||
updateMinimumSize();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -142,21 +142,22 @@ public class XEmbeddedFramePeer extends XFramePeer {
|
||||
xembedLog.fine(xe.toString());
|
||||
}
|
||||
|
||||
WindowLocation newLocation = getNewLocation(xe);
|
||||
Dimension newDimension = new Dimension(xe.get_width(), xe.get_height());
|
||||
boolean xinerama = XToolkit.localEnv.runningXinerama();
|
||||
// fix for 5063031
|
||||
// if we use super.handleConfigureNotifyEvent() we would get wrong
|
||||
// size and position because embedded frame really is NOT a decorated one
|
||||
SunToolkit.executeOnEventHandlerThread(target, () -> {
|
||||
Point newUserLocation = newLocation.getUserLocation();
|
||||
checkIfOnNewScreen(toGlobal(new Rectangle(
|
||||
scaleDown(xe.get_x()),
|
||||
scaleDown(xe.get_y()),
|
||||
scaleDown(xe.get_width()),
|
||||
scaleDown(xe.get_height()))), () -> {
|
||||
|
||||
Rectangle oldBounds = getBounds();
|
||||
|
||||
synchronized (getStateLock()) {
|
||||
x = newUserLocation.x;
|
||||
y = newUserLocation.y;
|
||||
width = scaleDown(newDimension.width);
|
||||
height = scaleDown(newDimension.height);
|
||||
x = scaleDown(xe.get_x());
|
||||
y = scaleDown(xe.get_y());
|
||||
width = scaleDown(xe.get_width());
|
||||
height = scaleDown(xe.get_height());
|
||||
|
||||
dimensions.setClientSize(width, height);
|
||||
dimensions.setLocation(x, y);
|
||||
@@ -167,9 +168,6 @@ public class XEmbeddedFramePeer extends XFramePeer {
|
||||
}
|
||||
reconfigureContentWindow(dimensions);
|
||||
|
||||
if (xinerama) {
|
||||
checkIfOnNewScreen(new Rectangle(newLocation.getDeviceLocation(), newDimension));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1143,8 +1143,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
* insets are calculated using _NET_WORKAREA property of the root window.
|
||||
* <p>
|
||||
* Note that _NET_WORKAREA is a rectangular area and it does not work
|
||||
* well in the Xinerama mode, so we assume that only 0th screen has insets.
|
||||
* Below is an example when _NET_WORKAREA produces wrong result.
|
||||
* well in the Xinerama mode.
|
||||
* <p>
|
||||
* We will trust the part of this rectangular area only if it starts at the
|
||||
* requested graphics configuration. Below is an example when the
|
||||
* _NET_WORKAREA intersects with the requested graphics configuration but
|
||||
* produces wrong result.
|
||||
*
|
||||
* //<-x1,y1///////
|
||||
* // // ////////////////
|
||||
@@ -1162,25 +1166,20 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
if (np == null || !(gd instanceof X11GraphicsDevice) || !np.active()) {
|
||||
return super.getScreenInsets(gc);
|
||||
}
|
||||
X11GraphicsDevice x11gd = (X11GraphicsDevice) gd;
|
||||
int screenNum = x11gd.getScreen();
|
||||
if (localEnv.runningXinerama() && screenNum != 0) {
|
||||
// We cannot estimate insets for non-default screen,
|
||||
// there are often none.
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
Rectangle workArea = getWorkArea(XlibUtil.getRootWindow(screenNum));
|
||||
X11GraphicsDevice x11gd = (X11GraphicsDevice) gd;
|
||||
long root = XlibUtil.getRootWindow(x11gd.getScreen());
|
||||
Rectangle workArea = getWorkArea(root);
|
||||
Rectangle screen = gc.getBounds();
|
||||
if (workArea != null) {
|
||||
workArea.x = x11gd.scaleDownX(workArea.x);
|
||||
workArea.y = x11gd.scaleDownY(workArea.y);
|
||||
workArea.width = x11gd.scaleDown(workArea.width);
|
||||
workArea.height = x11gd.scaleDown(workArea.height);
|
||||
workArea = workArea.intersection(screen);
|
||||
if (!workArea.isEmpty()) {
|
||||
if (screen.contains(workArea.getLocation())) {
|
||||
workArea = workArea.intersection(screen);
|
||||
int top = workArea.y - screen.y;
|
||||
int left = workArea.x - screen.x;
|
||||
int bottom = screen.height - workArea.height - top;
|
||||
|
||||
@@ -1072,10 +1072,9 @@ final class XWM
|
||||
try {
|
||||
Rectangle shellBounds;
|
||||
if (getWMID() != UNITY_COMPIZ_WM) {
|
||||
Insets insets = window.getRealInsets();
|
||||
shellBounds = window.getShellBounds();
|
||||
shellBounds.translate(-insets.left,
|
||||
-insets.top);
|
||||
shellBounds.translate(-window.currentInsets.left,
|
||||
-window.currentInsets.top);
|
||||
} else {
|
||||
shellBounds = window.getDimensions().getScreenBounds();
|
||||
}
|
||||
|
||||
@@ -1740,8 +1740,8 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int scaleUp(int i) {
|
||||
return graphicsConfig.scaleUp(i);
|
||||
protected int scaleUp(int x) {
|
||||
return graphicsConfig.scaleUp(x);
|
||||
}
|
||||
@Override
|
||||
protected int scaleUpX(int x) {
|
||||
@@ -1753,8 +1753,8 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int scaleDown(int i) {
|
||||
return graphicsConfig.scaleDown(i);
|
||||
protected int scaleDown(int x) {
|
||||
return graphicsConfig.scaleDown(x);
|
||||
}
|
||||
@Override
|
||||
protected int scaleDownX(int x) {
|
||||
|
||||
@@ -39,6 +39,7 @@ import sun.awt.AWTAccessor.ComponentAccessor;
|
||||
import sun.awt.DisplayChangedListener;
|
||||
import sun.awt.IconInfo;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.X11GraphicsConfig;
|
||||
import sun.awt.X11GraphicsDevice;
|
||||
import sun.awt.X11GraphicsEnvironment;
|
||||
import sun.java2d.pipe.Region;
|
||||
@@ -99,8 +100,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
private Long desktopId; // guarded by AWT lock
|
||||
private boolean desktopIdInvalid; // guarded by AWT lock
|
||||
|
||||
transient boolean syncSizeOnly; // Force syncBounds() to sync only size, not location.
|
||||
|
||||
/*
|
||||
* Focus related flags
|
||||
*/
|
||||
@@ -529,10 +528,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
}
|
||||
|
||||
Insets getRealUnscaledInsets() {
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public Insets getInsets() {
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
@@ -657,69 +652,83 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
/* Xinerama
|
||||
* called to check if we've been moved onto a different screen
|
||||
* Based on checkNewXineramaScreen() in awt_GraphicsEnv.c
|
||||
* newBounds are specified in device space.
|
||||
*/
|
||||
public boolean checkIfOnNewScreen(Rectangle newBounds) {
|
||||
public void checkIfOnNewScreen(Rectangle newBounds, Runnable next) {
|
||||
if (!XToolkit.localEnv.runningXinerama()) {
|
||||
if (next != null) next.run();
|
||||
return;
|
||||
}
|
||||
|
||||
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
|
||||
log.finest("XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode");
|
||||
}
|
||||
|
||||
// Remap new bounds to native unscaled coordinates
|
||||
newBounds.x = scaleUpX(newBounds.x);
|
||||
newBounds.y = scaleUpY(newBounds.y);
|
||||
newBounds.width = scaleUp(newBounds.width);
|
||||
newBounds.height = scaleUp(newBounds.height);
|
||||
|
||||
int largestIntersection = 0;
|
||||
int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen();
|
||||
int newScreenNum = curScreenNum;
|
||||
GraphicsDevice[] gds = XToolkit.localEnv.getScreenDevices();
|
||||
GraphicsConfiguration newGC = null;
|
||||
|
||||
for (int i = 0; i < gds.length; i++) {
|
||||
X11GraphicsDevice device = (X11GraphicsDevice) gds[i];
|
||||
Rectangle screenBounds = gds[i].getDefaultConfiguration().getBounds();
|
||||
// Rescale screen size to native unscaled coordinates
|
||||
screenBounds.width = device.scaleUp(screenBounds.width);
|
||||
screenBounds.height = device.scaleUp(screenBounds.height);
|
||||
XToolkit.awtUnlock();
|
||||
try {
|
||||
for (int i = 0; i < gds.length; i++) {
|
||||
X11GraphicsDevice device = (X11GraphicsDevice) gds[i];
|
||||
Rectangle screenBounds = gds[i].getDefaultConfiguration().getBounds();
|
||||
// Rescale screen size to native unscaled coordinates
|
||||
screenBounds.width = device.scaleUp(screenBounds.width);
|
||||
screenBounds.height = device.scaleUp(screenBounds.height);
|
||||
|
||||
Rectangle intersection = screenBounds.intersection(newBounds);
|
||||
if (!intersection.isEmpty()) {
|
||||
int area = intersection.width * intersection.height;
|
||||
if (area > largestIntersection) {
|
||||
largestIntersection = area;
|
||||
newScreenNum = i;
|
||||
newGC = gds[i].getDefaultConfiguration();
|
||||
if (intersection.equals(newBounds)) break;
|
||||
Rectangle intersection = screenBounds.intersection(newBounds);
|
||||
if (!intersection.isEmpty()) {
|
||||
int area = intersection.width * intersection.height;
|
||||
if (area > largestIntersection) {
|
||||
largestIntersection = area;
|
||||
newScreenNum = i;
|
||||
newGC = gds[i].getDefaultConfiguration();
|
||||
if (intersection.equals(newBounds)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ensure that after window will be moved to another monitor and (probably)
|
||||
// resized as a result, majority of its area will stay on the new monitor
|
||||
if (newScreenNum != curScreenNum) {
|
||||
X11GraphicsDevice device = (X11GraphicsDevice) gds[newScreenNum];
|
||||
Rectangle screenBounds = newGC.getBounds();
|
||||
// Rescale screen size to native unscaled coordinates
|
||||
screenBounds.width = device.scaleUp(screenBounds.width);
|
||||
screenBounds.height = device.scaleUp(screenBounds.height);
|
||||
// Rescale window to new screen's scale
|
||||
newBounds.width = newBounds.width * device.getScaleFactor() / graphicsConfig.getScale();
|
||||
newBounds.height = newBounds.height * device.getScaleFactor() / graphicsConfig.getScale();
|
||||
// Ensure that after window will be moved to another monitor and (probably)
|
||||
// resized as a result, majority of its area will stay on the new monitor
|
||||
if (newScreenNum != curScreenNum) {
|
||||
X11GraphicsDevice device = (X11GraphicsDevice) gds[newScreenNum];
|
||||
Rectangle screenBounds = newGC.getBounds();
|
||||
// Rescale screen size to native unscaled coordinates
|
||||
screenBounds.width = device.scaleUp(screenBounds.width);
|
||||
screenBounds.height = device.scaleUp(screenBounds.height);
|
||||
// Rescale window to new screen's scale
|
||||
newBounds.width = newBounds.width * device.getScaleFactor() / graphicsConfig.getScale();
|
||||
newBounds.height = newBounds.height * device.getScaleFactor() / graphicsConfig.getScale();
|
||||
|
||||
Rectangle intersection = screenBounds.intersection(newBounds);
|
||||
if (intersection.isEmpty() ||
|
||||
intersection.width * intersection.height <= newBounds.width * newBounds.height / 2) {
|
||||
newScreenNum = curScreenNum; // Don't move to new screen
|
||||
Rectangle intersection = screenBounds.intersection(newBounds);
|
||||
if (intersection.isEmpty() ||
|
||||
intersection.width * intersection.height < newBounds.width * newBounds.height / 2) {
|
||||
newScreenNum = curScreenNum; // Don't move to new screen
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
XToolkit.awtLock();
|
||||
}
|
||||
if (newScreenNum != curScreenNum) {
|
||||
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
|
||||
log.finest("XWindowPeer: Moved to a new screen");
|
||||
}
|
||||
var gc = newGC;
|
||||
var device = (X11GraphicsDevice) gc.getDevice();
|
||||
var acc = AWTAccessor.getComponentAccessor();
|
||||
syncSizeOnly = true;
|
||||
acc.setSize(target, device.scaleDown(newBounds.width), device.scaleDown(newBounds.height));
|
||||
acc.setGraphicsConfiguration(target, gc);
|
||||
syncSizeOnly = false;
|
||||
return true;
|
||||
graphicsConfig = (X11GraphicsConfig) newGC;
|
||||
final GraphicsConfiguration ngc = newGC;
|
||||
SunToolkit.executeOnEventHandlerThread(target, () -> {
|
||||
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(target, ngc);
|
||||
if (next != null) next.run();
|
||||
});
|
||||
} else {
|
||||
if (next != null) next.run();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -752,68 +761,28 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
public void paletteChanged() {
|
||||
}
|
||||
|
||||
void xSetSize(int width, int height) {
|
||||
if (getWindow() == 0) {
|
||||
insLog.warning("Attempt to resize uncreated window");
|
||||
throw new IllegalStateException("Attempt to resize uncreated window");
|
||||
}
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
insLog.fine("Setting size on " + this + " to " + width + "x" + height);
|
||||
}
|
||||
width = Math.max(MIN_SIZE, width);
|
||||
height = Math.max(MIN_SIZE, height);
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getWindow(),
|
||||
scaleUp(width), scaleUp(height));
|
||||
} finally {
|
||||
XToolkit.awtUnlock();
|
||||
}
|
||||
private Point queryXLocation()
|
||||
{
|
||||
Point p = XlibUtil.translateCoordinates(getContentWindow(), XlibWrapper
|
||||
.RootWindow(XToolkit.getDisplay(),
|
||||
getScreenNumber()),
|
||||
0, 0);
|
||||
p.x = scaleDownX(p.x);
|
||||
p.y = scaleDownY(p.y);
|
||||
return p;
|
||||
}
|
||||
|
||||
class WindowLocation {
|
||||
private final Point location; // Device space
|
||||
private final boolean client;
|
||||
WindowLocation(Point location, boolean client) {
|
||||
this.location = location;
|
||||
this.client = client;
|
||||
}
|
||||
Point getDeviceLocation() {
|
||||
if (location == null) {
|
||||
Point l = AWTAccessor.getComponentAccessor().getLocation(target);
|
||||
l.x = scaleUpX(l.x);
|
||||
l.y = scaleUpY(l.y);
|
||||
return l;
|
||||
} else if (client) {
|
||||
Insets insets = getRealUnscaledInsets();
|
||||
return new Point(location.x - insets.left, location.y - insets.top);
|
||||
} else {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
Point getUserLocation() {
|
||||
if (location == null) {
|
||||
return AWTAccessor.getComponentAccessor().getLocation(target);
|
||||
} else if (client) {
|
||||
Insets insets = getRealUnscaledInsets();
|
||||
return new Point(scaleDownX(location.x - insets.left), scaleDownY(location.y - insets.top));
|
||||
} else {
|
||||
return new Point(scaleDownX(location.x), scaleDownY(location.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
protected Point getNewLocation(XConfigureEvent xe, int leftInset, int topInset) {
|
||||
// Bounds of the window
|
||||
Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds(target);
|
||||
|
||||
WindowLocation queryXLocation() {
|
||||
return new WindowLocation(XlibUtil.translateCoordinates(getContentWindow(),
|
||||
XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()), 0, 0), false);
|
||||
}
|
||||
|
||||
WindowLocation getNewLocation(XConfigureEvent xe) {
|
||||
int runningWM = XWM.getWMID();
|
||||
Point newLocation = targetBounds.getLocation();
|
||||
if (xe.get_send_event() ||
|
||||
(ENABLE_REPARENTING_CHECK ? (runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) : !isReparented())) {
|
||||
// Location, Client size + insets
|
||||
return new WindowLocation(new Point(xe.get_x(), xe.get_y()), true);
|
||||
newLocation = new Point(scaleDownX(xe.get_x()) - leftInset,
|
||||
scaleDownY(xe.get_y()) - topInset);
|
||||
} else {
|
||||
// ICCCM 4.1.5 states that a real ConfigureNotify will be sent when
|
||||
// a window is resized but the client can not tell if the window was
|
||||
@@ -830,15 +799,20 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
case XWM.UNITY_COMPIZ_WM:
|
||||
case XWM.AWESOME_WM:
|
||||
{
|
||||
WindowLocation xlocation = queryXLocation();
|
||||
Point xlocation = queryXLocation();
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine("New X location: {0} ({1})", xlocation.location, xlocation.client ? "client" : "bounds");
|
||||
log.fine("New X location: {0}", xlocation);
|
||||
}
|
||||
return xlocation;
|
||||
if (xlocation != null) {
|
||||
newLocation = xlocation;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new WindowLocation(null, false);
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -853,18 +827,18 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
insLog.fine(xe.toString());
|
||||
}
|
||||
|
||||
WindowLocation newLocation = getNewLocation(xe);
|
||||
Dimension newDimension = new Dimension(xe.get_width(), xe.get_height());
|
||||
boolean xinerama = XToolkit.localEnv.runningXinerama();
|
||||
Rectangle oldBounds = getBounds();
|
||||
|
||||
SunToolkit.executeOnEventHandlerThread(target, () -> {
|
||||
Point newUserLocation = newLocation.getUserLocation();
|
||||
Rectangle oldBounds = getBounds();
|
||||
x = scaleDownX(xe.get_x());
|
||||
y = scaleDownY(xe.get_y());
|
||||
width = scaleDown(xe.get_width());
|
||||
height = scaleDown(xe.get_height());
|
||||
|
||||
x = newUserLocation.x;
|
||||
y = newUserLocation.y;
|
||||
width = scaleDown(newDimension.width);
|
||||
height = scaleDown(newDimension.height);
|
||||
checkIfOnNewScreen(new Rectangle(
|
||||
scaleDownX(xe.get_x()),
|
||||
scaleDownY(xe.get_y()),
|
||||
scaleDown(xe.get_width()),
|
||||
scaleDown(xe.get_height())), () -> {
|
||||
|
||||
if (!getBounds().getSize().equals(oldBounds.getSize())) {
|
||||
AWTAccessor.getComponentAccessor().setSize(target, width, height);
|
||||
@@ -876,9 +850,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
repositionSecurityWarning();
|
||||
|
||||
if (xinerama) {
|
||||
checkIfOnNewScreen(new Rectangle(newLocation.getDeviceLocation(), newDimension));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2611,29 +2582,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
void syncBounds() {
|
||||
Rectangle r = target.getBounds();
|
||||
width = r.width;
|
||||
height = r.height;
|
||||
if (syncSizeOnly) {
|
||||
xSetSize(width, height);
|
||||
} else {
|
||||
x = r.x;
|
||||
y = r.y;
|
||||
xSetBounds(x, y, width, height);
|
||||
}
|
||||
doValidateSurface();
|
||||
layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateGraphicsData(GraphicsConfiguration gc) {
|
||||
if (super.updateGraphicsData(gc)) return true;
|
||||
repositionSecurityWarning();
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean haveCommonAncestor(Component c1, Component c2) {
|
||||
return getRootOwner(c1) == getRootOwner(c2);
|
||||
}
|
||||
|
||||
@@ -271,8 +271,8 @@ public class X11GraphicsConfig extends GraphicsConfiguration
|
||||
return getDevice().getScaleFactor();
|
||||
}
|
||||
|
||||
public int scaleUp(int i) {
|
||||
return getDevice().scaleUp(i);
|
||||
public int scaleUp(int x) {
|
||||
return getDevice().scaleUp(x);
|
||||
}
|
||||
public int scaleUpX(int x) {
|
||||
return getDevice().scaleUpX(x);
|
||||
@@ -281,8 +281,8 @@ public class X11GraphicsConfig extends GraphicsConfiguration
|
||||
return getDevice().scaleUpY(y);
|
||||
}
|
||||
|
||||
public int scaleDown(int i) {
|
||||
return getDevice().scaleDown(i);
|
||||
public int scaleDown(int x) {
|
||||
return getDevice().scaleDown(x);
|
||||
}
|
||||
public int scaleDownX(int x) {
|
||||
return getDevice().scaleDownX(x);
|
||||
|
||||
@@ -129,8 +129,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
return TYPE_RASTER_SCREEN;
|
||||
}
|
||||
|
||||
public int scaleUp(int i) {
|
||||
return Region.clipRound(i * (double)getScaleFactor());
|
||||
public int scaleUp(int x) {
|
||||
return Region.clipRound(x * (double)getScaleFactor());
|
||||
}
|
||||
public int scaleUpX(int x) {
|
||||
int s = getBoundsCached().x;
|
||||
@@ -141,8 +141,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
return Region.clipRound(s + (y - s) * (double)getScaleFactor());
|
||||
}
|
||||
|
||||
public int scaleDown(int i) {
|
||||
return Region.clipRound(i / (double)getScaleFactor());
|
||||
public int scaleDown(int x) {
|
||||
return Region.clipRound(x / (double)getScaleFactor());
|
||||
}
|
||||
public int scaleDownX(int x) {
|
||||
int s = getBoundsCached().x;
|
||||
|
||||
@@ -143,32 +143,6 @@ static void* get_schema_value(char *name, char *key) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// When monitor framebuffer scaling enabled, compositor scales down monitor resolutions according to their scales,
|
||||
// so that we're working in logical, not device pixels, just like in macOS. This approach is used for implementing
|
||||
// fractional scaling, so basically this function tells you whether fractional scaling is enabled or not.
|
||||
int isMonitorFramebufferScalingEnabled() {
|
||||
int result = 0;
|
||||
void* features = get_schema_value("org.gnome.mutter", "experimental-features");
|
||||
if (features) {
|
||||
if (fp_g_variant_is_of_type(features, "as")) {
|
||||
int numFeatures = fp_g_variant_n_children(features);
|
||||
for (int i = 0; i < numFeatures; i++) {
|
||||
void* feature = fp_g_variant_get_child_value(features, i);
|
||||
if (feature) {
|
||||
char* name = fp_g_variant_get_string(feature, NULL);
|
||||
if (name && strcmp(name, "scale-monitor-framebuffer") == 0) {
|
||||
result = 1;
|
||||
}
|
||||
fp_g_variant_unref(feature);
|
||||
if (result) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fp_g_variant_unref(features);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static double getDesktopScale(char *output_name) {
|
||||
double result = -1;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
double getNativeScaleFactor(char *output_name, double default_value);
|
||||
double getScaleEnvVar(const char* var_name, double default_value);
|
||||
int isMonitorFramebufferScalingEnabled();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -802,28 +802,24 @@ Java_sun_awt_X11GraphicsEnvironment_updateWaylandMonitorScaling(JNIEnv *env, jcl
|
||||
if (!usingXinerama || !wlLibHandle) return;
|
||||
|
||||
struct UpdateWaylandMonitorsData monData;
|
||||
monData.currentWaylandMonitor = -1;
|
||||
monData.currentWaylandScale = 1;
|
||||
monData.waylandMonitorScales = NULL;
|
||||
if (!isMonitorFramebufferScalingEnabled()) {
|
||||
monData.xinInfo = (*XineramaQueryScreens)(awt_display, &monData.xinScreens);
|
||||
if (monData.xinInfo == NULL) return;
|
||||
wl_display* display = wl_display_connect(NULL);
|
||||
if (display == NULL) return;
|
||||
monData.waylandMonitorScales = calloc(monData.xinScreens, sizeof(int32_t));
|
||||
monData.xinInfo = (*XineramaQueryScreens)(awt_display, &monData.xinScreens);
|
||||
if (monData.xinInfo == NULL) return;
|
||||
wl_display* display = wl_display_connect(NULL);
|
||||
if (display == NULL) return;
|
||||
monData.waylandMonitorScales = calloc(monData.xinScreens, sizeof(int32_t));
|
||||
|
||||
wl_registry* registry = wl_proxy_marshal_constructor(display, 1, wl_registry_interface, NULL); // wl_display_get_registry
|
||||
wl_proxy_add_listener(registry, (void (**)(void)) &wlRegistryListener, &monData); // wl_registry_add_listener
|
||||
wl_display_roundtrip(display); // Get globals (wl_outputs)
|
||||
wl_display_roundtrip(display); // Get outputs info
|
||||
wl_registry* registry = wl_proxy_marshal_constructor(display, 1, wl_registry_interface, NULL); // wl_display_get_registry
|
||||
wl_proxy_add_listener(registry, (void (**)(void)) &wlRegistryListener, &monData); // wl_registry_add_listener
|
||||
wl_display_roundtrip(display); // Get globals (wl_outputs)
|
||||
wl_display_roundtrip(display); // Get outputs info
|
||||
|
||||
wl_display_disconnect(display);
|
||||
XFree(monData.xinInfo);
|
||||
}
|
||||
XFree(monData.xinInfo);
|
||||
|
||||
int32_t* oldScales = waylandMonitorScales;
|
||||
waylandMonitorScales = monData.waylandMonitorScales;
|
||||
free(oldScales);
|
||||
|
||||
wl_display_disconnect(display);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,481 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.nio.file.attribute.FileAttributeView;
|
||||
import java.nio.file.attribute.UserPrincipalLookupService;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.SeekableByteChannel;
|
||||
import java.net.URI;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestProvider extends FileSystemProvider {
|
||||
|
||||
private final FileSystemProvider defaultProvider;
|
||||
private final TestFileSystem theFileSystem;
|
||||
|
||||
public TestProvider(FileSystemProvider defaultProvider) {
|
||||
this.defaultProvider = defaultProvider;
|
||||
FileSystem fs = defaultProvider.getFileSystem(URI.create("file:/"));
|
||||
this.theFileSystem = new TestFileSystem(fs, this);
|
||||
}
|
||||
|
||||
FileSystemProvider defaultProvider() {
|
||||
return defaultProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileSystem newFileSystem(URI uri, Map<String,?> env) throws IOException {
|
||||
return defaultProvider.newFileSystem(uri, env);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileSystem getFileSystem(URI uri) {
|
||||
return theFileSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPath(URI uri) {
|
||||
Path path = defaultProvider.getPath(uri);
|
||||
return theFileSystem.wrap(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(Path file, String attribute, Object value,
|
||||
LinkOption... options)
|
||||
throws IOException
|
||||
{
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> readAttributes(Path file, String attributes,
|
||||
LinkOption... options)
|
||||
throws IOException
|
||||
{
|
||||
Path delegate = theFileSystem.unwrap(file);
|
||||
return defaultProvider.readAttributes(delegate, attributes, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <A extends BasicFileAttributes> A readAttributes(Path file,
|
||||
Class<A> type,
|
||||
LinkOption... options)
|
||||
throws IOException
|
||||
{
|
||||
Path delegate = theFileSystem.unwrap(file);
|
||||
return defaultProvider.readAttributes(delegate, type, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V extends FileAttributeView> V getFileAttributeView(Path file,
|
||||
Class<V> type,
|
||||
LinkOption... options)
|
||||
{
|
||||
Path delegate = theFileSystem.unwrap(file);
|
||||
return defaultProvider.getFileAttributeView(delegate, type, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Path file) throws IOException {
|
||||
Path delegate = theFileSystem.unwrap(file);
|
||||
defaultProvider.delete(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLink(Path link, Path existing) throws IOException {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path readSymbolicLink(Path link) throws IOException {
|
||||
Path delegate = theFileSystem.unwrap(link);
|
||||
Path target = defaultProvider.readSymbolicLink(delegate);
|
||||
return theFileSystem.wrap(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(Path source, Path target, CopyOption... options)
|
||||
throws IOException
|
||||
{
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(Path source, Path target, CopyOption... options)
|
||||
throws IOException
|
||||
{
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectoryStream<Path> newDirectoryStream(Path dir,
|
||||
DirectoryStream.Filter<? super Path> filter)
|
||||
throws IOException
|
||||
{
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDirectory(Path dir, FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
Path delegate = theFileSystem.unwrap(dir);
|
||||
defaultProvider.createDirectory(delegate, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SeekableByteChannel newByteChannel(Path file,
|
||||
Set<? extends OpenOption> options,
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
Path delegate = theFileSystem.unwrap(file);
|
||||
return defaultProvider.newByteChannel(delegate, options, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileChannel newFileChannel(Path file,
|
||||
Set<? extends OpenOption> options,
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
Path delegate = theFileSystem.unwrap(file);
|
||||
return defaultProvider.newFileChannel(delegate, options, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(Path file) throws IOException {
|
||||
throw new ReadOnlyFileSystemException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStore getFileStore(Path file) throws IOException {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameFile(Path file, Path other) throws IOException {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkAccess(Path file, AccessMode... modes)
|
||||
throws IOException
|
||||
{
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
static class TestFileSystem extends FileSystem {
|
||||
private final FileSystem delegate;
|
||||
private final TestProvider provider;
|
||||
|
||||
TestFileSystem(FileSystem delegate, TestProvider provider) {
|
||||
this.delegate = delegate;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
Path wrap(Path path) {
|
||||
return (path != null) ? new TestPath(this, path) : null;
|
||||
}
|
||||
|
||||
Path unwrap(Path wrapper) {
|
||||
if (wrapper == null)
|
||||
throw new NullPointerException();
|
||||
if (!(wrapper instanceof TestPath))
|
||||
throw new ProviderMismatchException();
|
||||
return ((TestPath)wrapper).unwrap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileSystemProvider provider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSeparator() {
|
||||
return delegate.getSeparator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Path> getRootDirectories() {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<FileStore> getFileStores() {
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> supportedFileAttributeViews() {
|
||||
return delegate.supportedFileAttributeViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPath(String first, String... more) {
|
||||
Path path = delegate.getPath(first, more);
|
||||
return wrap(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathMatcher getPathMatcher(String syntaxAndPattern) {
|
||||
return delegate.getPathMatcher(syntaxAndPattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserPrincipalLookupService getUserPrincipalLookupService() {
|
||||
return delegate.getUserPrincipalLookupService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WatchService newWatchService() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestPath implements Path {
|
||||
private final TestFileSystem fs;
|
||||
private final Path delegate;
|
||||
|
||||
TestPath(TestFileSystem fs, Path delegate) {
|
||||
this.fs = fs;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
Path unwrap() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileSystem getFileSystem() {
|
||||
return fs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbsolute() {
|
||||
return delegate.isAbsolute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getRoot() {
|
||||
return fs.wrap(delegate.getRoot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getParent() {
|
||||
return fs.wrap(delegate.getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNameCount() {
|
||||
return delegate.getNameCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFileName() {
|
||||
return fs.wrap(delegate.getFileName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getName(int index) {
|
||||
return fs.wrap(delegate.getName(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path subpath(int beginIndex, int endIndex) {
|
||||
return fs.wrap(delegate.subpath(beginIndex, endIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startsWith(Path other) {
|
||||
return delegate.startsWith(fs.unwrap(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startsWith(String other) {
|
||||
return delegate.startsWith(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean endsWith(Path other) {
|
||||
return delegate.endsWith(fs.unwrap(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean endsWith(String other) {
|
||||
return delegate.endsWith(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path normalize() {
|
||||
return fs.wrap(delegate.normalize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path resolve(Path other) {
|
||||
return fs.wrap(delegate.resolve(fs.unwrap(other)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path resolve(String other) {
|
||||
return fs.wrap(delegate.resolve(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path resolveSibling(Path other) {
|
||||
return fs.wrap(delegate.resolveSibling(fs.unwrap(other)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path resolveSibling(String other) {
|
||||
return fs.wrap(delegate.resolveSibling(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path relativize(Path other) {
|
||||
return fs.wrap(delegate.relativize(fs.unwrap(other)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof TestPath))
|
||||
return false;
|
||||
return delegate.equals(fs.unwrap((TestPath) other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return delegate.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI toUri() {
|
||||
String ssp = delegate.toUri().getSchemeSpecificPart();
|
||||
return URI.create(fs.provider().getScheme() + ":" + ssp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path toAbsolutePath() {
|
||||
return fs.wrap(delegate.toAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path toRealPath(LinkOption... options) throws IOException {
|
||||
return fs.wrap(delegate.toRealPath(options));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File toFile() {
|
||||
return new File(toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Path> iterator() {
|
||||
final Iterator<Path> itr = delegate.iterator();
|
||||
return new Iterator<Path>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return itr.hasNext();
|
||||
}
|
||||
@Override
|
||||
public Path next() {
|
||||
return fs.wrap(itr.next());
|
||||
}
|
||||
@Override
|
||||
public void remove() {
|
||||
itr.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Path other) {
|
||||
return delegate.compareTo(fs.unwrap(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WatchKey register(WatchService watcher,
|
||||
WatchEvent.Kind<?>[] events,
|
||||
WatchEvent.Modifier... modifiers)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WatchKey register(WatchService watcher,
|
||||
WatchEvent.Kind<?>... events)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY_PATH = new byte[0];
|
||||
|
||||
public byte[] getSunPathForSocketFile(Path path) {
|
||||
if (path.getNameCount() == 0) {
|
||||
return EMPTY_PATH;
|
||||
}
|
||||
return path.toString().getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023, JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Verifies that Unix domain sockets work with a non-default
|
||||
* file system provider that implements
|
||||
* @library /test/lib
|
||||
* @build TestProvider
|
||||
* @run main/othervm -Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider UnixSocketWithCustomProvider
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.StandardProtocolFamily;
|
||||
import java.net.UnixDomainSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
|
||||
public class UnixSocketWithCustomProvider {
|
||||
public static void main(String[] args) {
|
||||
FileSystemProvider provider = FileSystems.getDefault().provider();
|
||||
if (!provider.getClass().getName().equals("TestProvider")) {
|
||||
throw new Error("Test must be run with non-default file system");
|
||||
}
|
||||
|
||||
Path socketPath = Path.of("socket");
|
||||
UnixDomainSocketAddress socketAddress = UnixDomainSocketAddress.of(socketPath);
|
||||
try (ServerSocketChannel serverCh = ServerSocketChannel.open(StandardProtocolFamily.UNIX)) {
|
||||
serverCh.bind(socketAddress);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
Files.deleteIfExists(socketPath);
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import java.awt.event.MouseListener;
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @requires (os.family == "windows" | os.family == "mac")
|
||||
* @summary JBR-4875 The test drag&drops a frame which contains an instance of JComboBox and checks that ComboBoxPopup
|
||||
* does not become detached from its' control. The test performs checking for both cases when
|
||||
* <code>apple.awt.transparentTitleBar</code> is not set and it is set to <code>true</code>.
|
||||
|
||||
@@ -133,7 +133,7 @@ java/awt/dnd/DropTargetEnterExitTest/ExtraDragEnterTest.java 8029680 generic-all
|
||||
java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java 8171510,JBR-881 macosx-all,linux-all
|
||||
javax/swing/dnd/7171812/bug7171812.java 8041447,8253184 macosx-all,windows-all
|
||||
java/awt/Focus/ChoiceFocus/ChoiceFocus.java 8169103 windows-all,macosx-all
|
||||
java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618 macosx-all
|
||||
java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618,JBR-814 macosx-all,linux-all
|
||||
java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java 6986252,JBR-5178 windows-all
|
||||
java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java 8194753 linux-all,macosx-all
|
||||
java/awt/Focus/NoAutotransferToDisabledCompTest/NoAutotransferToDisabledCompTest.java 7152980 macosx-all
|
||||
@@ -266,6 +266,7 @@ java/awt/image/multiresolution/MultiResolutionJOptionPaneIconTest.java 8253184 w
|
||||
java/awt/print/Headless/HeadlessPrinterJob.java 8196088 windows-all
|
||||
sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all
|
||||
sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all
|
||||
sun/java2d/DirectX/OpaqueImageToSurfaceBlitTest/OpaqueImageToSurfaceBlitTest.java JBR-5393 windows-aarch64
|
||||
sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all
|
||||
sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180,8252812 windows-all,macosx-all,linux-all
|
||||
java/awt/Graphics2D/CopyAreaOOB.java JBR-5354 macosx-all,windows-all
|
||||
@@ -845,6 +846,7 @@ javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
|
||||
javax/swing/JEditorPane/8195095/ImageViewTest.java 8253184 windows-all
|
||||
javax/swing/JRadioButton/4314194/bug4314194.java 8298153 linux-all
|
||||
javax/swing/JRootPane/4670486/bug4670486.java 8042381,8197552 macosx-all,windows-all
|
||||
javax/swing/JRootPane/DefaultButtonTest.java 8285635 windows-all,linux-all
|
||||
javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java JBR-5210 windows-all
|
||||
javax/swing/text/html/StyleSheet/bug4936917.java JBR-899 windows-all
|
||||
javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java 8253184 windows-all
|
||||
@@ -1067,6 +1069,7 @@ java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java JBR-4880 windows-a
|
||||
java/awt/Frame/MiscUndecorated/UndecoratedInitiallyIconified.java JBR-4880 windows-all
|
||||
java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java JBR-4275,JBR-4880 linux-all,windows-all
|
||||
java/awt/FullScreen/SetFSWindow/FSFrame.java 8253184 windows-all
|
||||
java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java JBR-4880 windows-all
|
||||
java/awt/grab/GrabOnUnfocusableToplevel/GrabOnUnfocusableToplevel.java JBR-4880 windows-all
|
||||
java/awt/grab/MenuDragEvents/MenuDragEvents.java JBR-4880 windows-all
|
||||
java/awt/image/multiresolution/MenuMultiresolutionIconTest.java JBR-4880,8253184 windows-all
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# cannotbe run against jbr which does not contain some jbrsdk's utilities required for test executions
|
||||
javax/imageio/stream/StreamCloserLeak/run_test.sh NO_BUG generic_all
|
||||
javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh NO_BUG generic_all
|
||||
javax/imageio/stream/StreamCloserLeak/run_test.sh nobug generic-all
|
||||
javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh nobug generic-all
|
||||
|
||||
#
|
||||
# intermittently failed, they were muted in regular runs with the option "unmute manually"
|
||||
|
||||
Reference in New Issue
Block a user