Compare commits

..

1 Commits

Author SHA1 Message Date
Vitaly Provodin
2cbbf03d6e update exclude list on results of 25.0.1_220.18 test runs 2025-11-27 11:59:33 +04:00
57 changed files with 516 additions and 1193 deletions

View File

@@ -27,12 +27,6 @@ JCEF_PATH=${JCEF_PATH:=./jcef_linux_aarch64}
function do_configure {
GTK_SHELL_PATH=/gtk-shell.xml
WAYLAND_PROTOCOLS_PATH=/opt/wayland-protocols
WITH_WAYLAND_PROTOCOLS=
if [ -e "$WAYLAND_PROTOCOLS_PATH" ]; then
WITH_WAYLAND_PROTOCOLS="--with-wayland-protocols=$WAYLAND_PROTOCOLS_PATH"
fi
if [ ! -e $GTK_SHELL_PATH ]; then
echo $GTK_SHELL_PATH" does not exist"
@@ -60,7 +54,6 @@ function do_configure {
$REPRODUCIBLE_BUILD_OPTS \
$WITH_ZIPPED_NATIVE_DEBUG_SYMBOLS \
$WITH_BUNDLED_FREETYPE \
$WITH_WAYLAND_PROTOCOLS \
|| do_exit $?
}

View File

@@ -34,12 +34,6 @@ function do_configure {
fi
GTK_SHELL_PATH=/gtk-shell.xml
WAYLAND_PROTOCOLS_PATH=/opt/wayland-protocols
WITH_WAYLAND_PROTOCOLS=
if [ -e "$WAYLAND_PROTOCOLS_PATH" ]; then
WITH_WAYLAND_PROTOCOLS="--with-wayland-protocols=$WAYLAND_PROTOCOLS_PATH"
fi
if [ ! -e $GTK_SHELL_PATH ]; then
echo $GTK_SHELL_PATH" does not exist"
@@ -74,7 +68,6 @@ function do_configure {
$REPRODUCIBLE_BUILD_OPTS \
$WITH_ZIPPED_NATIVE_DEBUG_SYMBOLS \
$WITH_BUNDLED_FREETYPE \
$WITH_WAYLAND_PROTOCOLS \
|| do_exit $?
}

View File

@@ -33,7 +33,6 @@ WAYLAND_BASIC_PROTOCOL_FILES := \
$(WAYLAND_PROTOCOLS_ROOT)/stable/viewporter/viewporter.xml \
$(WAYLAND_PROTOCOLS_ROOT)/stable/xdg-shell/xdg-shell.xml \
$(WAYLAND_PROTOCOLS_ROOT)/staging/xdg-activation/xdg-activation-v1.xml \
$(WAYLAND_PROTOCOLS_ROOT)/staging/xdg-toplevel-icon/xdg-toplevel-icon-v1.xml \
$(WAYLAND_PROTOCOLS_ROOT)/unstable/primary-selection/primary-selection-unstable-v1.xml \
$(WAYLAND_PROTOCOLS_ROOT)/unstable/xdg-output/xdg-output-unstable-v1.xml \
$(WAYLAND_PROTOCOLS_ROOT)/unstable/relative-pointer/relative-pointer-unstable-v1.xml \

View File

@@ -159,84 +159,5 @@ public class IoOverNio {
* <p>
* The problem was found with the test {@code jtreg:test/jdk/java/io/FileDescriptor/Sharing.java}.
*/
public static class ParentForFileChannelImplHolder {
private static final ThreadLocal<Closeable> holder = new ThreadLocal<>();
private ParentForFileChannelImplHolder() {}
public static Closeable get() {
return holder.get();
}
public static void set(Closeable parent) {
RecursionGuard.ensureActive();
holder.set(parent);
}
public static void remove() {
RecursionGuard.ensureActive();
holder.remove();
}
}
/**
* <p>With java.io over java.nio backend, it's possible that some code invokes file system operations while
* already executing a similar operation. An example is when a classloader uses {@link FileSystems#getDefault()}
* during class loading. Such cases break usage of {@link ParentForFileChannelImplHolder}.</p>
*
* <p>This class is to be used around places that can hypothetically access {@link ParentForFileChannelImplHolder}
* recursively.</p>
*/
public static class RecursionGuard implements Closeable {
private static final ThreadLocal<RecursionGuard> HEAD = new ThreadLocal<>();
private final RecursionGuard parent;
private final Object label;
private final ThreadLocalCloseable additionalClosable;
/**
* @param label A unique object for a specific method. The object is used for reference equality.
* A static string or a reference to a class is a good candidate.
*/
public static RecursionGuard create(Object label) {
ThreadLocalCloseable additionalClosable = null;
for (var guard = HEAD.get(); guard != null; guard = guard.parent) {
if (guard.label == label) {
additionalClosable = disableInThisThread();
break;
}
}
var result = new RecursionGuard(HEAD.get(), label, additionalClosable);
HEAD.set(result);
return result;
}
private RecursionGuard(RecursionGuard parent, Object label, ThreadLocalCloseable additionalClosable) {
this.parent = parent;
this.label = label;
this.additionalClosable = additionalClosable;
}
public static void ensureActive() {
if (HEAD.get() == null) {
throw new Error("RecursionGuard is not installed");
}
}
@Override
public void close() {
HEAD.set(parent);
if (additionalClosable != null) {
additionalClosable.close();
}
}
}
/**
* Intended only for suppressing warnings about unused variables.
*/
@SuppressWarnings("unused")
public static void blackhole(Object any) {
// Nothing here.
}
public static final ThreadLocal<Closeable> PARENT_FOR_FILE_CHANNEL_IMPL = new ThreadLocal<>();
}

View File

@@ -156,40 +156,37 @@ public class FileInputStream extends InputStream
}
path = file.getPath();
try (var guard = IoOverNio.RecursionGuard.create(FileInputStream.class)) {
IoOverNio.blackhole(guard);
java.nio.file.FileSystem nioFs = IoOverNioFileSystem.acquireNioFs(path);
Path nioPath = null;
if (nioFs != null && path != null) {
try {
nioPath = nioFs.getPath(path);
isRegularFile = Files.isRegularFile(nioPath);
} catch (InvalidPathException _) {
// Nothing.
}
java.nio.file.FileSystem nioFs = IoOverNioFileSystem.acquireNioFs(path);
Path nioPath = null;
if (nioFs != null && path != null) {
try {
nioPath = nioFs.getPath(path);
isRegularFile = Files.isRegularFile(nioPath);
} catch (InvalidPathException _) {
// Nothing.
}
}
// Two significant differences between the legacy java.io and java.nio.files:
// * java.nio.file allows to open directories as streams, java.io.FileInputStream doesn't.
// * java.nio.file doesn't work well with pseudo devices, i.e., `seek()` fails, while java.io works well.
useNio = nioPath != null && isRegularFile == Boolean.TRUE;
// Two significant differences between the legacy java.io and java.nio.files:
// * java.nio.file allows to open directories as streams, java.io.FileInputStream doesn't.
// * java.nio.file doesn't work well with pseudo devices, i.e., `seek()` fails, while java.io works well.
useNio = nioPath != null && isRegularFile == Boolean.TRUE;
if (useNio) {
var bundle = IoOverNioFileSystem.initializeStreamUsingNio(
this, nioFs, file, nioPath, Set.of(StandardOpenOption.READ), channelCleanable);
channel = bundle.channel();
fd = bundle.fd();
externalChannelHolder = bundle.externalChannelHolder();
} else {
fd = new FileDescriptor();
fd.attach(this);
open(path);
FileCleanable.register(fd); // open set the fd, register the cleanup
externalChannelHolder = null;
}
if (DEBUG.writeTraces()) {
System.err.printf("Created a FileInputStream for %s%n", file);
}
if (useNio) {
var bundle = IoOverNioFileSystem.initializeStreamUsingNio(
this, nioFs, file, nioPath, Set.of(StandardOpenOption.READ), channelCleanable);
channel = bundle.channel();
fd = bundle.fd();
externalChannelHolder = bundle.externalChannelHolder();
} else {
fd = new FileDescriptor();
fd.attach(this);
open(path);
FileCleanable.register(fd); // open set the fd, register the cleanup
externalChannelHolder = null;
}
if (DEBUG.writeTraces()) {
System.err.printf("Created a FileInputStream for %s%n", file);
}
}

View File

@@ -225,49 +225,46 @@ public class FileOutputStream extends OutputStream
}
this.path = file.getPath();
try (var guard = IoOverNio.RecursionGuard.create(FileOutputStream.class)) {
IoOverNio.blackhole(guard);
java.nio.file.FileSystem nioFs = IoOverNioFileSystem.acquireNioFs(path);
useNio = path != null && nioFs != null;
if (useNio) {
Path nioPath = nioFs.getPath(path);
java.nio.file.FileSystem nioFs = IoOverNioFileSystem.acquireNioFs(path);
useNio = path != null && nioFs != null;
if (useNio) {
Path nioPath = nioFs.getPath(path);
// java.io backend doesn't open DOS hidden files for writing, but java.nio.file opens.
// This code mimics the old behavior.
if (nioFs.getSeparator().equals("\\")) {
DosFileAttributes attrs = null;
try {
var view = Files.getFileAttributeView(nioPath, DosFileAttributeView.class);
if (view != null) {
attrs = view.readAttributes();
}
} catch (IOException | UnsupportedOperationException _) {
// Windows paths without DOS attributes? Not a problem in this case.
}
if (attrs != null && (attrs.isHidden() || attrs.isDirectory())) {
throw new FileNotFoundException(file.getPath() + " (Access is denied)");
// java.io backend doesn't open DOS hidden files for writing, but java.nio.file opens.
// This code mimics the old behavior.
if (nioFs.getSeparator().equals("\\")) {
DosFileAttributes attrs = null;
try {
var view = Files.getFileAttributeView(nioPath, DosFileAttributeView.class);
if (view != null) {
attrs = view.readAttributes();
}
} catch (IOException | UnsupportedOperationException _) {
// Windows paths without DOS attributes? Not a problem in this case.
}
if (attrs != null && (attrs.isHidden() || attrs.isDirectory())) {
throw new FileNotFoundException(file.getPath() + " (Access is denied)");
}
Set<OpenOption> options = append
? Set.of(StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.APPEND)
: Set.of(StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
var bundle = IoOverNioFileSystem.initializeStreamUsingNio(
this, nioFs, file, nioPath, options, channelCleanable);
channel = bundle.channel();
fd = bundle.fd();
externalChannelHolder = bundle.externalChannelHolder();
} else {
this.fd = new FileDescriptor();
fd.attach(this);
open(this.path, append);
FileCleanable.register(fd); // open sets the fd, register the cleanup
externalChannelHolder = null;
}
if (DEBUG.writeTraces()) {
System.err.printf("Created a FileOutputStream for %s%n", file);
}
Set<OpenOption> options = append
? Set.of(StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.APPEND)
: Set.of(StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
var bundle = IoOverNioFileSystem.initializeStreamUsingNio(
this, nioFs, file, nioPath, options, channelCleanable);
channel = bundle.channel();
fd = bundle.fd();
externalChannelHolder = bundle.externalChannelHolder();
} else {
this.fd = new FileDescriptor();
fd.attach(this);
open(this.path, append);
FileCleanable.register(fd); // open sets the fd, register the cleanup
externalChannelHolder = null;
}
if (DEBUG.writeTraces()) {
System.err.printf("Created a FileOutputStream for %s%n", file);
}
}

View File

@@ -273,10 +273,10 @@ class IoOverNioFileSystem extends FileSystem {
try {
// This tricky thread local variable allows specifying an argument for sun.nio.ch.FileChannelImpl.<init>
// which is not present in the NIO public API and which is not easy to specify another way.
IoOverNio.ParentForFileChannelImplHolder.set(owner);
IoOverNio.PARENT_FOR_FILE_CHANNEL_IMPL.set(owner);
return initializeStreamsUsingNio0(owner, nioFs, file, nioPath, optionsForChannel, channelCleanable);
} finally {
IoOverNio.ParentForFileChannelImplHolder.remove();
IoOverNio.PARENT_FOR_FILE_CHANNEL_IMPL.remove();
}
}
@@ -876,8 +876,7 @@ class IoOverNioFileSystem extends FileSystem {
@Override
public boolean delete(File f) {
try (var guard = IoOverNio.RecursionGuard.create("IoOverNioFileSystem.delete")) {
IoOverNio.blackhole(guard);
try {
boolean result = delete0(f, true);
if (DEBUG.writeTraces()) {
System.err.printf("IoOverNioFileSystem.delete(%s) = %b%n", f, result);

View File

@@ -279,50 +279,47 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
}
path = name;
try (var guard = IoOverNio.RecursionGuard.create(RandomAccessFile.class)) {
IoOverNio.blackhole(guard);
FileSystem nioFs = IoOverNioFileSystem.acquireNioFs(path);
Path nioPath = null;
if (nioFs != null) {
try {
nioPath = nioFs.getPath(path);
} catch (InvalidPathException _) {
// Nothing.
}
}
// Two significant differences between the legacy java.io and java.nio.files:
// * java.nio.file allows to open directories as streams, java.io.FileInputStream doesn't.
// * java.nio.file doesn't work well with pseudo devices, i.e., `seek()` fails, while java.io works well.
boolean isRegularFile;
FileSystem nioFs = IoOverNioFileSystem.acquireNioFs(path);
Path nioPath = null;
if (nioFs != null) {
try {
isRegularFile = nioPath != null &&
Files.readAttributes(nioPath, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).isRegularFile();
}
catch (NoSuchFileException _) {
isRegularFile = true;
}
catch (IOException _) {
isRegularFile = false;
nioPath = nioFs.getPath(path);
} catch (InvalidPathException _) {
// Nothing.
}
}
useNio = nioPath != null && isRegularFile;
if (useNio) {
var bundle = IoOverNioFileSystem.initializeStreamUsingNio(
this, nioFs, file, nioPath, optionsForChannel(imode), channelCleanable);
channel = bundle.channel();
fd = bundle.fd();
externalChannelHolder = bundle.externalChannelHolder();
} else {
fd = new FileDescriptor();
fd.attach(this);
open(name, imode);
FileCleanable.register(fd); // open sets the fd, register the cleanup
externalChannelHolder = null;
}
if (DEBUG.writeTraces()) {
System.err.printf("Created a RandomAccessFile for %s%n", file);
}
// Two significant differences between the legacy java.io and java.nio.files:
// * java.nio.file allows to open directories as streams, java.io.FileInputStream doesn't.
// * java.nio.file doesn't work well with pseudo devices, i.e., `seek()` fails, while java.io works well.
boolean isRegularFile;
try {
isRegularFile = nioPath != null &&
Files.readAttributes(nioPath, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).isRegularFile();
}
catch (NoSuchFileException _) {
isRegularFile = true;
}
catch (IOException _) {
isRegularFile = false;
}
useNio = nioPath != null && isRegularFile;
if (useNio) {
var bundle = IoOverNioFileSystem.initializeStreamUsingNio(
this, nioFs, file, nioPath, optionsForChannel(imode), channelCleanable);
channel = bundle.channel();
fd = bundle.fd();
externalChannelHolder = bundle.externalChannelHolder();
} else {
fd = new FileDescriptor();
fd.attach(this);
open(name, imode);
FileCleanable.register(fd); // open sets the fd, register the cleanup
externalChannelHolder = null;
}
if (DEBUG.writeTraces()) {
System.err.printf("Created a RandomAccessFile for %s%n", file);
}
}

View File

@@ -140,7 +140,7 @@ public class FileChannelImpl
this.sync = sync;
this.direct = direct;
if (parent == null) {
parent = IoOverNio.ParentForFileChannelImplHolder.get();
parent = IoOverNio.PARENT_FOR_FILE_CHANNEL_IMPL.get();
}
this.parent = parent;
if (direct) {

View File

@@ -1,80 +0,0 @@
/*
* Copyright 2025 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
package com.jetbrains.desktop;
import com.jetbrains.desktop.image.TextureWrapperSurfaceManager;
import com.jetbrains.exported.JBRApi;
import sun.awt.image.SurfaceManager;
import sun.java2d.SurfaceData;
import sun.java2d.metal.MTLGraphicsConfig;
import sun.java2d.metal.MTLTextureWrapperSurfaceData;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
@JBRApi.Service
@JBRApi.Provides("SharedTextures")
public class SharedTexturesService extends SharedTextures {
private final int textureType;
public SharedTexturesService() {
textureType = getTextureTypeImpl();
if (textureType == UNDEFINED_TEXTURE_TYPE) {
throw new JBRApi.ServiceNotAvailableException();
}
}
@Override
public int getTextureType() {
return textureType;
}
private static int getTextureTypeImpl() {
GraphicsConfiguration gc = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.getDefaultConfiguration();
if (gc instanceof MTLGraphicsConfig) {
return METAL_TEXTURE_TYPE;
}
return 0;
}
@Override
protected SurfaceManager createSurfaceManager(GraphicsConfiguration gc, Image image, long texture) {
SurfaceData sd;
if (gc instanceof MTLGraphicsConfig mtlGraphicsConfig) {
sd = new MTLTextureWrapperSurfaceData(mtlGraphicsConfig, image, texture);
} else {
throw new IllegalArgumentException("Unsupported graphics configuration: " + gc);
}
return new TextureWrapperSurfaceManager(sd);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, 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
@@ -31,6 +31,7 @@ import sun.awt.CGraphicsEnvironment;
import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.SurfaceManager;
import sun.awt.image.TextureWrapperSurfaceManager;
import sun.awt.image.VolatileSurfaceManager;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
@@ -48,6 +49,7 @@ import java.awt.BufferCapabilities;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.ImageCapabilities;
import java.awt.Rectangle;
@@ -69,7 +71,7 @@ import static sun.java2d.pipe.hw.ContextCapabilities.*;
import static sun.java2d.metal.MTLContext.MTLContextCaps.CAPS_EXT_BIOP_SHADER;
public final class MTLGraphicsConfig extends CGraphicsConfig
implements AccelGraphicsConfig, SurfaceManager.Factory
implements AccelGraphicsConfig, SurfaceManager.Factory, SurfaceManager.TextureWrapperFactory
{
private static ImageCapabilities imageCaps = new MTLImageCaps();
@@ -378,4 +380,11 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
Object context) {
return new MTLVolatileSurfaceManager(image, context);
}
@Override
public SurfaceManager createTextureWrapperSurfaceManager(
GraphicsConfiguration gc, Image image, long texture) {
SurfaceData sd = MTLSurfaceData.createData(this, image, texture);
return new TextureWrapperSurfaceManager(sd);
}
}

View File

@@ -50,6 +50,7 @@ import java.awt.Transparency;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import java.util.concurrent.atomic.AtomicBoolean;
import static sun.java2d.pipe.BufferedOpCodes.DISPOSE_SURFACE;
import static sun.java2d.pipe.BufferedOpCodes.FLUSH_SURFACE;
@@ -151,7 +152,7 @@ public abstract class MTLSurfaceData extends SurfaceData
private native void initOps(MTLGraphicsConfig gc, long pConfigInfo, long pPeerData, long layerPtr,
int xoff, int yoff, boolean isOpaque);
protected MTLSurfaceData(MTLLayer layer, MTLGraphicsConfig gc,
private MTLSurfaceData(MTLLayer layer, MTLGraphicsConfig gc,
ColorModel cm, int type, int width, int height)
{
super(getCustomSurfaceType(type), cm);
@@ -200,6 +201,10 @@ public abstract class MTLSurfaceData extends SurfaceData
type);
}
public static MTLTextureWrapperSurfaceData createData(MTLGraphicsConfig gc, Image image, long pTexture) {
return new MTLTextureWrapperSurfaceData(gc, image, pTexture);
}
@Override
public double getDefaultScaleX() {
return scale;
@@ -219,6 +224,8 @@ public abstract class MTLSurfaceData extends SurfaceData
protected native boolean initTexture(long pData, boolean isOpaque, int width, int height);
protected native boolean initWithTexture(long pData, boolean isOpaque, long texturePtr);
protected native boolean initRTexture(long pData, boolean isOpaque, int width, int height);
protected native boolean initFlipBackbuffer(long pData, boolean isOpaque, int width, int height);
@@ -674,4 +681,46 @@ public abstract class MTLSurfaceData extends SurfaceData
}
private static native boolean loadNativeRasterWithRects(long sdops, long pRaster, int width, int height, long pRects, int rectsCount);
/**
* Surface data for an existing texture
*/
public static final class MTLTextureWrapperSurfaceData extends MTLSurfaceData {
private final Image myImage;
private MTLTextureWrapperSurfaceData(MTLGraphicsConfig gc, Image image, long pTexture) throws IllegalArgumentException {
super(null, gc, ColorModel.getRGBdefault(), RT_TEXTURE, /*width=*/ 0, /*height=*/ 0);
myImage = image;
MTLRenderQueue rq = MTLRenderQueue.getInstance();
AtomicBoolean success = new AtomicBoolean(false);
rq.lock();
try {
MTLContext.setScratchSurface(gc);
rq.flushAndInvokeNow(() -> success.set(initWithTexture(getNativeOps(), false, pTexture)));
} finally {
rq.unlock();
}
if (!success.get()) {
throw new IllegalArgumentException("Failed to init the surface data");
}
}
@Override
public SurfaceData getReplacement() {
throw new UnsupportedOperationException("not implemented");
}
@Override
public Object getDestination() {
return myImage;
}
@Override
public Rectangle getBounds() {
return getNativeBounds();
}
}
}

View File

@@ -1,9 +0,0 @@
package sun.java2d.metal;
public class MTLSurfaceDataExt {
public static boolean initWithTexture(MTLSurfaceData sd, long texturePtr) {
return initWithTexture(sd.getNativeOps(), false, texturePtr);
}
private static native boolean initWithTexture(long pData, boolean isOpaque, long texturePtr);
}

View File

@@ -1,49 +0,0 @@
package sun.java2d.metal;
import sun.java2d.SurfaceData;
import java.awt.*;
import java.awt.image.ColorModel;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Surface data for an existing texture
*/
public final class MTLTextureWrapperSurfaceData extends MTLSurfaceData {
private final Image myImage;
public MTLTextureWrapperSurfaceData(MTLGraphicsConfig gc, Image image, long pTexture) throws IllegalArgumentException {
super(null, gc, gc.getColorModel(TRANSLUCENT), RT_TEXTURE, /*width=*/ 0, /*height=*/ 0);
myImage = image;
MTLRenderQueue rq = MTLRenderQueue.getInstance();
AtomicBoolean success = new AtomicBoolean(false);
rq.lock();
try {
MTLContext.setScratchSurface(gc);
rq.flushAndInvokeNow(() -> success.set(MTLSurfaceDataExt.initWithTexture(this, pTexture)));
} finally {
rq.unlock();
}
if (!success.get()) {
throw new IllegalArgumentException("Failed to init the surface data");
}
}
@Override
public SurfaceData getReplacement() {
throw new UnsupportedOperationException("not implemented");
}
@Override
public Object getDestination() {
return myImage;
}
@Override
public Rectangle getBounds() {
return getNativeBounds();
}
}

View File

@@ -107,6 +107,81 @@ static jboolean MTLSurfaceData_initTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque
}
}
static jboolean MTLSurfaceData_initWithTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque, void* pTexture) {
@autoreleasepool {
if (bmtlsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: ops are null");
return JNI_FALSE;
}
if (pTexture == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: texture is null");
return JNI_FALSE;
}
id <MTLTexture> texture = (__bridge id <MTLTexture>) pTexture;
if (texture == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: failed to cast texture to MTLTexture");
return JNI_FALSE;
}
if (texture.width >= MTL_GPU_FAMILY_MAC_TXT_SIZE || texture.height >= MTL_GPU_FAMILY_MAC_TXT_SIZE ||
texture.width == 0 || texture.height == 0) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: wrong texture size %d x %d",
texture.width, texture.height);
return JNI_FALSE;
}
if (texture.pixelFormat != MTLPixelFormatBGRA8Unorm) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: unsupported pixel format: %d",
texture.pixelFormat);
return JNI_FALSE;
}
bmtlsdo->pTexture = texture;
bmtlsdo->pOutTexture = NULL;
MTLSDOps *mtlsdo = (MTLSDOps *)bmtlsdo->privOps;
if (mtlsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: MTLSDOps are null");
return JNI_FALSE;
}
if (mtlsdo->configInfo == NULL || mtlsdo->configInfo->context == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: MTLSDOps wasn't initialized (context is null)");
return JNI_FALSE;
}
MTLContext* ctx = mtlsdo->configInfo->context;
MTLTextureDescriptor *stencilDataDescriptor =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR8Uint
width:texture.width
height:texture.height
mipmapped:NO];
stencilDataDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
stencilDataDescriptor.storageMode = MTLStorageModePrivate;
bmtlsdo->pStencilData = [ctx.device newTextureWithDescriptor:stencilDataDescriptor];
MTLTextureDescriptor *stencilTextureDescriptor =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatStencil8
width:texture.width
height:texture.height
mipmapped:NO];
stencilTextureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite;
stencilTextureDescriptor.storageMode = MTLStorageModePrivate;
bmtlsdo->pStencilTexture = [ctx.device newTextureWithDescriptor:stencilTextureDescriptor];
bmtlsdo->isOpaque = isOpaque;
bmtlsdo->width = texture.width;
bmtlsdo->height = texture.height;
bmtlsdo->drawableType = MTLSD_RT_TEXTURE;
[texture retain];
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLSurfaceData_initTexture: w=%d h=%d bp=%p [tex=%p] opaque=%d sfType=%d",
bmtlsdo->width, bmtlsdo->height, bmtlsdo, bmtlsdo->pTexture, isOpaque, bmtlsdo->drawableType);
return JNI_TRUE;
}
}
/**
* Initializes an MTL texture, using the given width and height as
* a guide.
@@ -123,6 +198,19 @@ Java_sun_java2d_metal_MTLSurfaceData_initTexture(
return JNI_TRUE;
}
JNIEXPORT jboolean JNICALL
Java_sun_java2d_metal_MTLSurfaceData_initWithTexture(
JNIEnv *env, jobject mtlds,
jlong pData, jboolean isOpaque,
jlong pTexture) {
BMTLSDOps *bmtlsdops = (BMTLSDOps *) pData;
if (!MTLSurfaceData_initWithTexture(bmtlsdops, isOpaque, jlong_to_ptr(pTexture))) {
return JNI_FALSE;
}
MTLSD_SetNativeDimensions(env, (BMTLSDOps *) pData, bmtlsdops->width, bmtlsdops->height);
return JNI_TRUE;
}
/**
* Initializes a framebuffer object, using the given width and height as
* a guide. See MTLSD_InitTextureObject() and MTLSD_initRTexture()

View File

@@ -1,102 +0,0 @@
#import "MTLSurfaceData.h"
#import "jni_util.h"
// From MTLSurfaceData.m
extern void MTLSD_SetNativeDimensions(JNIEnv *env, BMTLSDOps *bmtlsdo, jint w, jint h);
static jboolean MTLSurfaceData_initWithTexture(
BMTLSDOps *bmtlsdo,
jboolean isOpaque,
void* pTexture
) {
@autoreleasepool {
if (bmtlsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: ops are null");
return JNI_FALSE;
}
if (pTexture == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: texture is null");
return JNI_FALSE;
}
id <MTLTexture> texture = (__bridge id <MTLTexture>) pTexture;
if (texture == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: failed to cast texture to MTLTexture");
return JNI_FALSE;
}
if (texture.width >= MTL_GPU_FAMILY_MAC_TXT_SIZE || texture.height >= MTL_GPU_FAMILY_MAC_TXT_SIZE ||
texture.width == 0 || texture.height == 0) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: wrong texture size %d x %d",
texture.width, texture.height);
return JNI_FALSE;
}
if (texture.pixelFormat != MTLPixelFormatBGRA8Unorm) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: unsupported pixel format: %d",
texture.pixelFormat);
return JNI_FALSE;
}
bmtlsdo->pTexture = texture;
bmtlsdo->pOutTexture = NULL;
MTLSDOps *mtlsdo = (MTLSDOps *)bmtlsdo->privOps;
if (mtlsdo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: MTLSDOps are null");
return JNI_FALSE;
}
if (mtlsdo->configInfo == NULL || mtlsdo->configInfo->context == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "MTLSurfaceData_initWithTexture: MTLSDOps wasn't initialized (context is null)");
return JNI_FALSE;
}
MTLContext* ctx = mtlsdo->configInfo->context;
MTLTextureDescriptor *stencilDataDescriptor =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR8Uint
width:texture.width
height:texture.height
mipmapped:NO];
stencilDataDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
stencilDataDescriptor.storageMode = MTLStorageModePrivate;
bmtlsdo->pStencilData = [ctx.device newTextureWithDescriptor:stencilDataDescriptor];
MTLTextureDescriptor *stencilTextureDescriptor =
[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatStencil8
width:texture.width
height:texture.height
mipmapped:NO];
stencilTextureDescriptor.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite;
stencilTextureDescriptor.storageMode = MTLStorageModePrivate;
bmtlsdo->pStencilTexture = [ctx.device newTextureWithDescriptor:stencilTextureDescriptor];
bmtlsdo->isOpaque = isOpaque;
bmtlsdo->width = texture.width;
bmtlsdo->height = texture.height;
bmtlsdo->drawableType = MTLSD_RT_TEXTURE;
[texture retain];
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLSurfaceData_initTexture: w=%d h=%d bp=%p [tex=%p] opaque=%d sfType=%d",
bmtlsdo->width, bmtlsdo->height, bmtlsdo, bmtlsdo->pTexture, isOpaque, bmtlsdo->drawableType);
return JNI_TRUE;
}
}
JNIEXPORT jboolean JNICALL
Java_sun_java2d_metal_MTLSurfaceDataExt_initWithTexture(
JNIEnv *env,
jclass cls,
jlong pData,
jboolean isOpaque,
jlong pTexture
) {
BMTLSDOps *bmtlsdops = (BMTLSDOps *) pData;
if (!MTLSurfaceData_initWithTexture(bmtlsdops, isOpaque, jlong_to_ptr(pTexture))) {
return JNI_FALSE;
}
MTLSD_SetNativeDimensions(env, (BMTLSDOps *) pData, bmtlsdops->width, bmtlsdops->height);
return JNI_TRUE;
}

View File

@@ -26,19 +26,52 @@
package com.jetbrains.desktop;
import com.jetbrains.desktop.image.TextureWrapperImage;
import sun.awt.image.SurfaceManager;
import com.jetbrains.exported.JBRApi;
import sun.awt.SunToolkit;
import java.awt.*;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
public abstract class SharedTextures {
public final static int UNDEFINED_TEXTURE_TYPE = 0;
@JBRApi.Service
@JBRApi.Provides("SharedTextures")
public class SharedTextures {
public final static int METAL_TEXTURE_TYPE = 1;
public abstract int getTextureType();
private final int textureType;
public final Image wrapTexture(GraphicsConfiguration gc, long texture) {
return new TextureWrapperImage((img) -> createSurfaceManager(gc, img, texture));
public static SharedTextures create() {
return new SharedTextures();
}
protected abstract SurfaceManager createSurfaceManager(GraphicsConfiguration gc, Image image, long texture);
private SharedTextures() {
textureType = getTextureTypeImpl();
if (textureType == 0) {
throw new JBRApi.ServiceNotAvailableException();
}
}
public int getTextureType() {
return textureType;
}
public Image wrapTexture(GraphicsConfiguration gc, long texture) {
return new TextureWrapperImage(gc, texture);
}
private static int getTextureTypeImpl() {
GraphicsConfiguration gc = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.getDefaultConfiguration();
try {
if (SunToolkit.isInstanceOf(gc, "sun.java2d.metal.MTLGraphicsConfig")) {
return METAL_TEXTURE_TYPE;
}
} catch (Exception e) {
throw new InternalError("Unexpected exception during reflection", e);
}
return 0;
}
}

View File

@@ -37,7 +37,6 @@ import java.awt.ImageCapabilities;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.util.function.Function;
/**
* This class is a wrapper for a GPU texture-based image.
@@ -52,14 +51,31 @@ import java.util.function.Function;
* the surface flushing.
*/
public class TextureWrapperImage extends Image {
final GraphicsConfiguration gc;
final SurfaceData sd;
final static ImageCapabilities capabilities = new ImageCapabilities(true);
public TextureWrapperImage(Function<Image, SurfaceManager> surfaceManagerFactory)
/**
* Constructs a TextureWrapperImage instance with the specified graphics configuration
* and a texture.
*
* @param gc the graphics configuration
* @param texture the texture that will be wrapped by this instance.
* Platform-specific details:
* macOS (with the Metal rendering pipeline) - a pointer to an MTLTexture object is expected
*
* @throws UnsupportedOperationException if the current pipeline is not supported
* @throws IllegalArgumentException if the texture cannot be wrapped
*/
public TextureWrapperImage(GraphicsConfiguration gc, long texture)
throws UnsupportedOperationException, IllegalArgumentException {
SurfaceManager sm = surfaceManagerFactory.apply(this);
sd = sm.getPrimarySurfaceData();
SurfaceManager.setManager(this, sm);
this.gc = gc;
SurfaceManager surfaceManager;
if (gc instanceof SurfaceManager.TextureWrapperFactory factory) {
surfaceManager = factory.createTextureWrapperSurfaceManager(gc, this, texture);
} else throw new UnsupportedOperationException();
sd = surfaceManager.getPrimarySurfaceData();
SurfaceManager.setManager(this, surfaceManager);
}
@Override

View File

@@ -184,6 +184,14 @@ public abstract class SurfaceManager {
}
}
/**
* See TextureWrapperImage.
*/
public interface TextureWrapperFactory {
SurfaceManager createTextureWrapperSurfaceManager(
GraphicsConfiguration gc, Image image, long texture);
}
/**
* An interface for GraphicsConfiguration objects to implement if
* they create their own VolatileSurfaceManager implementations.

View File

@@ -23,9 +23,8 @@
* questions.
*/
package com.jetbrains.desktop.image;
package sun.awt.image;
import sun.awt.image.SurfaceManager;
import sun.java2d.SurfaceData;
import java.awt.GraphicsConfiguration;

View File

@@ -1944,15 +1944,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
awtLock();
try {
if (numberOfButtons == 0) {
// The commented-out code is introduced in 8351907 and causes inability to use
// any mouse extra buttons under XWayland GNOME of version >= 47,
// thus causing JBR-9713, JBR-9714, JBR-9715.
// Please don't enable it back until a proper fix appears in OpenJDK.
//
//if (XdgDesktopPortal.isRemoteDesktop()
// && ScreencastHelper.isAvailable()) {
// numberOfButtons = 3;
//} else {
if (XdgDesktopPortal.isRemoteDesktop()
&& ScreencastHelper.isAvailable()) {
numberOfButtons = 3;
} else {
numberOfButtons = getNumberOfButtonsImpl();
numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED) ? MAX_BUTTONS_SUPPORTED : numberOfButtons;
//4th and 5th buttons are for wheel and shouldn't be reported as buttons.
@@ -1964,7 +1959,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
} else if (numberOfButtons == 4 || numberOfButtons == 5) {
numberOfButtons = 3;
}
//}
}
}
//Assume don't have to re-query the number again and again.
return numberOfButtons;

View File

@@ -164,7 +164,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
@Override
public void paint(Graphics g) {
assert isRepaintNeeded() : "paint() called when no repaint needed";
assert isRepaintNeeded();
int width = peer.getWidth();
int height = peer.getHeight();
@@ -196,7 +196,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
}
private boolean isSignificantDrag(Point p) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
Objects.requireNonNull(p);
return pressedLocation != null && isSignificantDragDistance(pressedLocation, p);
@@ -208,7 +208,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
@Override
boolean processMouseEvent(MouseEvent e) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
if (super.processMouseEvent(e)) return true;
@@ -326,7 +326,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
}
private boolean processMouseEvent(MouseEvent e) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
Rectangle buttonBounds = bounds.get();
boolean ourLocation = buttonBounds != null && e.getID() != MouseEvent.MOUSE_EXITED &&

View File

@@ -68,7 +68,7 @@ public class GtkFrameDecoration extends FullFrameDecorationHelper {
public GtkFrameDecoration(WLDecoratedPeer peer, boolean showMinimize, boolean showMaximize) {
super(peer, showMinimize, showMaximize);
nativePtr = nativeCreateDecoration(showMinimize, showMaximize, isDarkTheme());
assert nativePtr != 0 : "Failed to create the native part of the decoration";
assert nativePtr != 0;
int t = nativeGetIntProperty(nativePtr, "gtk-dnd-drag-threshold");
dndThreshold = t > 0 ? t : 4;
}
@@ -87,8 +87,8 @@ public class GtkFrameDecoration extends FullFrameDecorationHelper {
int width = peer.getWidth();
int height = titleBarHeight;
assert width >= titleBarMinWidth : "The frame width is too small to display the title bar";
assert peer.getHeight() >= titleBarHeight : "The frame height is too small to display the title bar";
assert width >= titleBarMinWidth;
assert peer.getHeight() >= titleBarHeight;
double scale = ((WLGraphicsConfig) peer.getGraphicsConfiguration()).getEffectiveScale();
g2d.setBackground(new Color(0, true));

View File

@@ -96,7 +96,7 @@ public class ServerSideFrameDecoration extends FrameDecoration {
@Override
public void dispose() {
// Native resources must have been already disposed when the window was hidden
assert nativeDecorPtr == 0 : "Native resources must have been already disposed";
assert nativeDecorPtr == 0;
}
private native long createToplevelDecorationImpl(long nativeFramePtr);

View File

@@ -88,8 +88,6 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.wl.focus.WLComponentPeer");
private static final PlatformLogger popupLog = PlatformLogger.getLogger("sun.awt.wl.popup.WLComponentPeer");
public static final String POPUP_POSITION_UNCONSTRAINED_CLIENT_PROPERTY = "wlawt.popup_position_unconstrained";
protected static final int MINIMUM_WIDTH = 1;
protected static final int MINIMUM_HEIGHT = 1;
@@ -320,7 +318,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
if (what.getMinY() >= where.getMaxY()) {
what.y -= what.getMinY() - where.getMaxY();
}
assert what.intersects(where) : String.format("Failed to move %s to overlap %s", what, where);
assert what.intersects(where);
}
Point nativeLocationForPopup(Window popup, Component popupParent, Window toplevel) {
@@ -353,18 +351,6 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
return popupBounds.getLocation();
}
private boolean isPopupPositionUnconstrained() {
if (SunToolkit.isInstanceOf(target, "javax.swing.RootPaneContainer")) {
javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer) target).getRootPane();
Object prop = rootpane.getClientProperty(POPUP_POSITION_UNCONSTRAINED_CLIENT_PROPERTY);
if (prop instanceof Boolean booleanProp) {
return booleanProp;
}
}
return false;
}
protected void wlSetVisible(boolean v) {
// TODO: this whole method should be moved to WLWindowPeer
synchronized (getStateLock()) {
@@ -384,10 +370,9 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
: Frame.NORMAL;
boolean isMaximized = (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH;
boolean isMinimized = (state & Frame.ICONIFIED) == Frame.ICONIFIED;
boolean isUnconstrained = isPopupPositionUnconstrained();
performLocked(() -> {
assert wlSurface == null : "Invisible window already has a Wayland surface attached";
assert wlSurface == null;
wlSurface = new WLMainSurface((WLWindowPeer) this);
long wlSurfacePtr = wlSurface.getWlSurfacePtr();
if (isWlPopup) {
@@ -396,7 +381,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
Window toplevel = getToplevelFor(popupParent);
Point nativeLocation = nativeLocationForPopup(popup, popupParent, toplevel);
nativeCreatePopup(nativePtr, getNativePtrFor(toplevel), wlSurfacePtr,
thisWidth, thisHeight, nativeLocation.x, nativeLocation.y, isUnconstrained);
thisWidth, thisHeight, nativeLocation.x, nativeLocation.y);
} else {
nativeCreateWindow(nativePtr, getParentNativePtr(target), wlSurfacePtr,
isModal, isMaximized, isMinimized, title, WLToolkit.getApplicationID());
@@ -414,7 +399,6 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
// without any buffer attached"
shadow.commitSurface();
wlSurface.commit();
if (!isWlPopup && target.getParent() != null) activate();
((WLToolkit) Toolkit.getDefaultToolkit()).flush();
});
@@ -463,12 +447,10 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
void updateSurfaceData() {
performLocked(() -> {
SurfaceData.convertTo(WLSurfaceDataExt.class, surfaceData).revalidate(
getGraphicsConfiguration(), getBufferWidth(), getBufferHeight(), getDisplayScale());
SurfaceData.convertTo(WLSurfaceDataExt.class, surfaceData).revalidate(
getGraphicsConfiguration(), getBufferWidth(), getBufferHeight(), getDisplayScale());
shadow.updateSurfaceData();
});
shadow.updateSurfaceData();
}
public boolean isResizable() {
@@ -477,7 +459,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
@Override
public void updateSurfaceSize() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
// Note: must be called after a buffer of proper size has been attached to the surface,
// but the surface has not yet been committed. Otherwise, the sizes will get out of sync,
// which may result in visual artifacts.
@@ -515,8 +497,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
final Component popupParent = AWTAccessor.getWindowAccessor().getPopupParent(popup);
final Window toplevel = getToplevelFor(popupParent);
Point nativeLocation = nativeLocationForPopup(popup, popupParent, toplevel);
boolean isUnconstrained = isPopupPositionUnconstrained();
nativeRepositionWLPopup(nativePtr, surfaceWidth, surfaceHeight, nativeLocation.x, nativeLocation.y, isUnconstrained);
nativeRepositionWLPopup(nativePtr, surfaceWidth, surfaceHeight, nativeLocation.x, nativeLocation.y);
}
}
@@ -910,17 +891,13 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
// a button press, key press, or touch down event."
// So 'serial' must appertain to such an event.
assert serial != 0 : "The serial number of the event requesting the window menu must be non-zero";
assert serial != 0;
int xNative = javaUnitsToSurfaceUnits(x);
int yNative = javaUnitsToSurfaceUnits(y);
performLocked(() -> nativeShowWindowMenu(serial, nativePtr, xNative, yNative));
}
void setIcon(int size, int[] pixels) {
performLocked(() -> nativeSetIcon(nativePtr, size, pixels));
}
@Override
public ColorModel getColorModel() {
GraphicsConfiguration graphicsConfig = target.getGraphicsConfiguration();
@@ -970,7 +947,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
WLToolkit.targetDisposedPeer(target, this);
performLocked(() -> {
assert !isVisible() : "Disposed window must have been already hidden";
assert !isVisible();
nativeDisposeFrame(nativePtr);
nativePtr = 0;
@@ -1083,11 +1060,10 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
log.fine(String.format("%s is updating buffer to %dx%d pixels", this, getBufferWidth(), getBufferHeight()));
}
}
updateSurfaceData();
postPaintEvent();
}
updateSurfaceData();
postPaintEvent();
// Not sure what would need to have changed in Wayland's graphics configuration
// to warrant destroying the peer and creating a new one from scratch.
// So return "never recreate" here.
@@ -1139,20 +1115,15 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
private static long getSerialForActivation() {
long serial;
if (WLToolkit.isKDE()) {
serial = WLToolkit.getInputState().latestInputSerial();
} else {
serial = WLToolkit.getInputState().keyboardEnterSerial(); // a focus event
if (serial == 0) { // may have just left one surface and not yet entered another
serial = WLToolkit.getInputState().keySerial(); // an input event
}
if (serial == 0) {
// The pointer button serial seems to not work with Mutter but may work
// with other implementations, so let's keep it as an input event serial
// of the last resort.
serial = WLToolkit.getInputState().pointerButtonSerial();
}
long serial = WLToolkit.isKDE() ? 0 : WLToolkit.getInputState().keyboardEnterSerial(); // a focus event
if (serial == 0) { // may have just left one surface and not yet entered another
serial = WLToolkit.getInputState().keySerial(); // an input event
}
if (serial == 0) {
// The pointer button serial seems to not work with Mutter, but may work
// with other implementations, so let's keep it as an input event serial
// of the last resort.
serial = WLToolkit.getInputState().pointerButtonSerial();
}
return serial;
}
@@ -1166,14 +1137,12 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
String title, String appID);
protected native void nativeCreatePopup(long ptr, long parentPtr, long wlSurfacePtr,
int width, int height,
int offsetX, int offsetY,
boolean isUnconstrained);
int width, int height,
int offsetX, int offsetY);
protected native void nativeRepositionWLPopup(long ptr,
int width, int height,
int offsetX, int offsetY,
boolean isUnconstrained);
int offsetX, int offsetY);
protected native void nativeHideFrame(long ptr);
protected native void nativeDisposeFrame(long ptr);
@@ -1192,7 +1161,6 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
private native void nativeSetMinimumSize(long ptr, int width, int height);
private native void nativeSetMaximumSize(long ptr, int width, int height);
private native void nativeShowWindowMenu(long serial, long ptr, int x, int y);
private native void nativeSetIcon(long ptr, int size, int[] pixels);
static long getNativePtrFor(Component component) {
final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
@@ -1373,8 +1341,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
if (verticalMWERoundRotations != 0 || verticalMWEPreciseRotations != 0) {
assert verticalMWEScrollAmount > 0
: String.format("Vertical scrolling event has negative scroll amount: %d", verticalMWEScrollAmount);
assert(verticalMWEScrollAmount > 0);
final MouseEvent mouseEvent = new MouseWheelEvent(getTarget(),
MouseEvent.MOUSE_WHEEL,
@@ -1393,8 +1360,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
if (horizontalMWERoundRotations != 0 || horizontalMWEPreciseRotations != 0) {
assert horizontalMWEScrollAmount > 0
: String.format("Horizontal scrolling event has negative scroll amount: %d", horizontalMWEScrollAmount);;
assert(horizontalMWEScrollAmount > 0);
final MouseEvent mouseEvent = new MouseWheelEvent(getTarget(),
MouseEvent.MOUSE_WHEEL,
@@ -1605,7 +1571,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
// "This request must be used in response to some sort of user action like a button press,
// key press, or touch down event. The passed serial is used to determine the type
// of interactive move (touch, pointer, etc)."
assert serial != 0 : "The serial number of the event requesting the drag must be non-zero";
assert serial != 0;
performLocked(() -> nativeStartDrag(serial, nativePtr));
}
@@ -1614,7 +1580,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
// "This request must be used in response to some sort of user action like a button press,
// key press, or touch down event. The passed serial is used to determine the type
// of interactive resize (touch, pointer, etc)."
assert serial != 0 : "The serial number of the event requesting the resize must be non-zero";
assert serial != 0;
performLocked(() -> nativeStartResize(serial, nativePtr, edges));
}
@@ -1694,7 +1660,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
void notifyConfigured(int newSurfaceX, int newSurfaceY, int newSurfaceWidth, int newSurfaceHeight,
boolean active, boolean maximized, boolean fullscreen) {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
// NB: The width and height, as well as X and Y arguments, specify the size and the location
// of the window in surface-local coordinates.
@@ -1775,12 +1741,12 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
void notifyPopupDone() {
assert targetIsWlPopup() : "This method must be invoked only for popups";
assert(targetIsWlPopup());
target.setVisible(false);
}
void checkIfOnNewScreen() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
if (wlSurface == null) return;
final WLGraphicsDevice newDevice = wlSurface.getGraphicsDevice();
@@ -2025,7 +1991,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
@Override
public void updateSurfaceSize() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
shadowSurface.updateSurfaceSize(shadowWlSize.getSurfaceWidth(), shadowWlSize.getSurfaceHeight());
}
@@ -2037,8 +2003,8 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
public void createSurface() {
assert shadowSurface == null : "The shadow surface must not be created twice";
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert shadowSurface == null;
assert SunToolkit.isAWTLockHeldByCurrentThread();
int shadowOffset = -javaUnitsToSurfaceUnits(shadowSize);
shadowSurface = new WLSubSurface(wlSurface, shadowOffset, shadowOffset);
@@ -2046,13 +2012,13 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
public void commitSurface() {
assert shadowSurface != null;
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
shadowSurface.commit();
}
public void dispose() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
if (shadowSurface != null) {
shadowSurface.dispose();
@@ -2067,7 +2033,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
public void hide() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
if (shadowSurface != null) {
shadowSurface.dispose();
@@ -2076,7 +2042,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
public void updateSurfaceData() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
needsRepaint = true;
SurfaceData.convertTo(WLSurfaceDataExt.class, shadowSurfaceData).revalidate(
@@ -2084,7 +2050,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
}
public void paint() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
if (!needsRepaint) {
return;
@@ -2110,7 +2076,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
public void notifyConfigured(boolean active, boolean maximized, boolean fullscreen) {
assert shadowSurface != null;
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
needsRepaint |= active ^ isActive;

View File

@@ -77,8 +77,7 @@ public class WLDataOffer {
fd = openReceivePipe(nativePtr, mime);
// Otherwise an exception should be thrown from native code
assert fd != -1 : "An invalid file descriptor received from the native code";
assert(fd != -1); // Otherwise an exception should be thrown from native code
FileDescriptor javaFD = new FileDescriptor();
jdk.internal.access.SharedSecrets.getJavaIOFileDescriptorAccess().set(javaFD, fd);

View File

@@ -53,7 +53,7 @@ public class WLDataSource {
var wlDataTransferer = (WLDataTransferer) WLDataTransferer.getInstance();
nativePtr = initNative(dataDevice.getNativePtr(), protocol);
assert nativePtr != 0 : "Failed to initialize the native part of the source"; // should've already thrown in native
assert nativePtr != 0; // should've already thrown in native
this.data = data;
try {

View File

@@ -128,10 +128,10 @@ public class WLGraphicsDevice extends GraphicsDevice {
int widthLogical, int heightLogical,
int widthMm, int heightMm,
int displayScale) {
assert width > 0 && height > 0 : String.format("Invalid device size: %dx%d", width, height);
assert widthLogical > 0 && heightLogical > 0 : String.format("Invalid logical device size: %dx%d", widthLogical, heightLogical);
assert widthMm > 0 && heightMm > 0 : String.format("Invalid physical device size: %dx%d", widthMm, heightMm);
assert displayScale > 0 : String.format("Invalid display scale: %d", displayScale);
assert width > 0 && height > 0;
assert widthLogical > 0 && heightLogical > 0;
assert widthMm > 0 && heightMm > 0;
assert displayScale > 0;
this.wlID = id;
this.name = name;
@@ -176,10 +176,10 @@ public class WLGraphicsDevice extends GraphicsDevice {
int widthLogical, int heightLogical,
int widthMm, int heightMm,
int scale) {
assert width > 0 && height > 0 : String.format("Invalid device size: %dx%d", width, height);
assert widthLogical > 0 && heightLogical > 0 : String.format("Invalid logical device size: %dx%d", widthLogical, heightLogical);
assert widthMm > 0 && heightMm > 0 : String.format("Invalid physical device size: %dx%d", widthMm, heightMm);
assert scale > 0 : String.format("Invalid display scale: %d", scale);
assert width > 0 && height > 0;
assert widthLogical > 0 && heightLogical > 0;
assert widthMm > 0 && heightMm > 0;
assert scale > 0;
this.name = name;
this.x = x;

View File

@@ -133,16 +133,8 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment implements HiD
}
// Logical size comes from an optional protocol, so take the data from the main one, if absent
if (widthLogical <= 0) widthLogical = width;
if (heightLogical <= 0) heightLogical = height;
// Physical size may be absent for virtual outputs.
if (widthMm <= 0 || heightMm <= 0) {
// Assume a 92 DPI display
widthMm = (int) Math.ceil(25.4 * width / 92.0);
heightMm = (int) Math.ceil(25.4 * height / 92.0);
}
if (widthLogical == 0) widthLogical = width;
if (heightLogical == 0) heightLogical = height;
String humanID = deviceNameFrom(name, make, model);
WLGraphicsDevice gd = deviceWithID(wlID);

View File

@@ -43,8 +43,6 @@ import java.awt.event.InputEvent;
* @param pointerButtonPressedEvent null or the latest PointerButtonEvent such that getIsButtonPressed() == true
* @param modifiers a bit set of modifiers reflecting currently pressed keys (@see WLInputState.getNewModifiers())
* @param surfaceForKeyboardInput represents 'struct wl_surface*' that keyboards events should go to
* @param isPointerOverSurface true if the mouse pointer has entered a surface and has not left yet
* @param latestInputSerial the serial of the latest input event (key or pointer button press)
*/
record WLInputState(WLPointerEvent eventWithSurface,
long pointerEnterSerial,
@@ -56,8 +54,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
PointerButtonEvent pointerButtonPressedEvent,
int modifiers,
long surfaceForKeyboardInput,
boolean isPointerOverSurface,
long latestInputSerial) {
boolean isPointerOverSurface) {
/**
* Groups together information about a mouse pointer button event.
* @param surface 'struct wl_surface*' the button was pressed over
@@ -78,7 +75,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
static WLInputState initialState() {
return new WLInputState(null, 0, 0, 0, 0, null, null,
null, 0, 0, false, 0);
null, 0, 0, false);
}
/**
@@ -104,9 +101,6 @@ record WLInputState(WLPointerEvent eventWithSurface,
boolean newPointerOverSurface = (pointerEvent.hasEnterEvent() || isPointerOverSurface)
&& !pointerEvent.hasLeaveEvent();
final long newLatestInputEventSerial = pointerEvent.hasButtonEvent()
? pointerEvent.getSerial() : latestInputSerial;
return new WLInputState(
newEventWithSurface,
newPointerEnterSerial,
@@ -118,8 +112,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
newPointerButtonEvent,
newModifiers,
surfaceForKeyboardInput,
newPointerOverSurface,
newLatestInputEventSerial);
newPointerOverSurface);
}
public WLInputState updatedFromKeyEvent(long serial) {
@@ -134,8 +127,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
pointerButtonPressedEvent,
modifiers,
surfaceForKeyboardInput,
isPointerOverSurface,
serial);
isPointerOverSurface);
}
public WLInputState updatedFromKeyboardEnterEvent(long serial, long surfacePtr) {
@@ -151,8 +143,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
pointerButtonPressedEvent,
modifiers,
surfacePtr,
isPointerOverSurface,
latestInputSerial);
isPointerOverSurface);
}
public WLInputState updatedFromKeyboardModifiersEvent(long serial, int keyboardModifiers) {
@@ -170,8 +161,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
pointerButtonPressedEvent,
newModifiers,
surfaceForKeyboardInput,
isPointerOverSurface,
latestInputSerial);
isPointerOverSurface);
}
public WLInputState updatedFromKeyboardLeaveEvent(long serial, long surfacePtr) {
@@ -195,8 +185,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
pointerButtonPressedEvent,
newModifiers,
0,
isPointerOverSurface,
latestInputSerial);
isPointerOverSurface);
}
public WLInputState updatedFromUnregisteredSurface(long surfacePtr) {
@@ -214,8 +203,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
pointerButtonPressedEvent,
modifiers,
0,
isPointerOverSurface,
latestInputSerial);
isPointerOverSurface);
} else {
return this;
}
@@ -233,8 +221,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
pointerButtonPressedEvent,
modifiers & ~WLPointerEvent.PointerButtonCodes.combinedMask(),
surfaceForKeyboardInput,
false,
latestInputSerial);
false);
}
private PointerButtonEvent getNewPointerButtonEvent(WLPointerEvent pointerEvent,
@@ -242,9 +229,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
WLPointerEvent newEventWithTimestamp,
WLPointerEvent newEventWithPosition) {
if (pointerEvent.hasButtonEvent() && pointerEvent.getIsButtonPressed() && newEventWithSurface != null) {
assert newEventWithTimestamp != null && newEventWithPosition != null
: "Events with timestamp and position are both required to be present";
assert newEventWithTimestamp != null && newEventWithPosition != null;
int clickCount = 1;
final boolean pressedSameButton = pointerButtonPressedEvent != null
&& pointerEvent.getButtonCode() == pointerButtonPressedEvent.linuxCode;

View File

@@ -48,7 +48,7 @@ class WLKeyboard {
// called from native code
void setRepeatInfo(int charsPerSecond, int delayMillis) {
// this function receives (0, 0) when key repeat is disabled
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
this.delayBeforeRepeatMillis = delayMillis;
if (charsPerSecond > 0) {
this.delayBetweenRepeatMillis = (int) (1000.0 / charsPerSecond);
@@ -64,7 +64,7 @@ class WLKeyboard {
}
void cancelRepeat() {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
if (currentRepeatTask != null) {
currentRepeatTask.cancel();
currentRepeatTask = null;
@@ -74,7 +74,7 @@ class WLKeyboard {
// called from native code
void stopRepeat(int keycode) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
if (currentRepeatKeycode == keycode) {
cancelRepeat();
}
@@ -82,7 +82,7 @@ class WLKeyboard {
// called from native code
void startRepeat(long serial, long timestamp, int keycode) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
cancelRepeat();
if (keycode == 0 || !isRepeatEnabled()) {
return;
@@ -123,7 +123,7 @@ class WLKeyboard {
public native boolean isNumLockPressed();
public void onLostFocus() {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
keyRepeatManager.cancelRepeat();
cancelCompose();
}

View File

@@ -91,7 +91,7 @@ public class WLMainSurface extends WLSurface {
}
public void activateByAnotherSurface(long serial, long activatingSurfacePtr) {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
nativeActivate(getNativePtr(), serial, activatingSurfacePtr);

View File

@@ -217,37 +217,37 @@ class WLPointerEvent {
}
public long getSurface() {
assert hasSurface() : "The event must have a valid surface";
assert hasSurface();
return surface;
}
public long getSerial() {
assert hasSerial() : "The event must have a valid serial";
assert hasSerial();
return serial;
}
public long getTimestamp() {
assert hasTimestamp() : "The event must have a valid timestamp";
assert hasTimestamp();
return timestamp;
}
public int getSurfaceX() {
assert hasCoordinates() : "The event must have valid coordinates";
assert hasCoordinates();
return surface_x;
}
public int getSurfaceY() {
assert hasCoordinates() : "The event must have valid coordinates";
assert hasCoordinates();
return surface_y;
}
public int getButtonCode() {
assert hasButtonEvent() : "Must have a button event to get the button code";
assert hasButtonEvent();
return buttonCode;
}
public boolean getIsButtonPressed() {
assert hasButtonEvent() : "Must have a button event to get the button state";
assert hasButtonEvent();
return isButtonPressed;
}
@@ -270,12 +270,12 @@ class WLPointerEvent {
}
public double getXAxisVectorValue() {
assert xAxisHasVectorValue() : "Must have an X axis vector value";
assert xAxisHasVectorValue();
return xAxis_vectorValue;
}
public int getXAxisSteps120Value() {
assert xAxisHasSteps120Value() : "Must have an X axis steps120 value";
assert xAxisHasSteps120Value();
return xAxis_steps120Value;
}
@@ -298,12 +298,12 @@ class WLPointerEvent {
}
public double getYAxisVectorValue() {
assert yAxisHasVectorValue() : "Must have an Y axis vector value";
assert yAxisHasVectorValue();
return yAxis_vectorValue;
}
public int getYAxisSteps120Value() {
assert yAxisHasSteps120Value(): "Must have an Y axis steps120 value";
assert yAxisHasSteps120Value();
return yAxis_steps120Value;
}

View File

@@ -171,7 +171,7 @@ public class WLRobotPeer implements RobotPeer {
static Point getLocationOfWLSurface(WLSurface wlSurface) {
checkExtensionPresent();
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
final long wlSurfacePtr = wlSurface.getWlSurfacePtr();
// The native implementation allows for just one such request at a time

View File

@@ -57,7 +57,7 @@ public class WLSurface {
}
public void dispose() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
if (isValid) {
hide();
@@ -67,7 +67,7 @@ public class WLSurface {
}
public void hide() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
if (surfaceData == null) return;
@@ -85,14 +85,14 @@ public class WLSurface {
}
public boolean hasSurfaceData() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
return surfaceData != null;
}
public void associateWithSurfaceData(SurfaceData data) {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
Objects.requireNonNull(data);
assertIsValid();
@@ -103,7 +103,7 @@ public class WLSurface {
}
public void commit() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
nativeCommitWlSurface(nativePtr);
@@ -115,28 +115,28 @@ public class WLSurface {
* @return a pointer to wl_surface native object
*/
public long getWlSurfacePtr() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
return wlSurfacePtr;
}
protected long getNativePtr() {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
return nativePtr;
}
public void setSize(int width, int height) {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
nativeSetSize(nativePtr, width, height);
}
public void setOpaqueRegion(int x, int y, int width, int height) {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
nativeSetOpaqueRegion(nativePtr, x, y, width, height);
@@ -151,7 +151,7 @@ public class WLSurface {
}
public void updateSurfaceSize(int surfaceWidth, int surfaceHeight) {
assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assert SunToolkit.isAWTLockHeldByCurrentThread();
assertIsValid();
setSize(surfaceWidth, surfaceHeight);

View File

@@ -143,11 +143,6 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
private static final boolean isKDE;
// NOTE: xdg_toplevel_icon_v1 is pretty much only supported on KDE, and KWin always sends 96px as the icon size,
// regardless of the display resolution, scale, or anything else.
// TODO: this is currently unused
private static final java.util.List<Integer> preferredIconSizes = new ArrayList<>();
private static native void initIDs(long displayPtr);
static {
@@ -331,7 +326,7 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
private static void dispatchPointerEvent(WLPointerEvent e) {
// Invoked from the native code
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
if (log.isLoggable(PlatformLogger.Level.FINE)) log.fine("dispatchPointerEvent: " + e);
@@ -362,7 +357,7 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
char keyChar,
int modifiers) {
// Invoked from the native code
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
inputState = inputState.updatedFromKeyEvent(serial);
@@ -425,14 +420,14 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
}
private static void dispatchKeyboardModifiersEvent(long serial) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
inputState = inputState.updatedFromKeyboardModifiersEvent(serial, keyboard.getModifiers());
WLDropTargetContextPeer.getInstance().handleModifiersUpdate();
}
private static void dispatchKeyboardEnterEvent(long serial, long surfacePtr) {
// Invoked from the native code
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
if (logKeys.isLoggable(PlatformLogger.Level.FINE)) {
logKeys.fine("dispatchKeyboardEnterEvent: " + serial + ", surface 0x"
@@ -461,7 +456,7 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
private static void dispatchKeyboardLeaveEvent(long serial, long surfacePtr) {
// Invoked from the native code
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
if (logKeys.isLoggable(PlatformLogger.Level.FINE)) {
logKeys.fine("dispatchKeyboardLeaveEvent: " + serial + ", surface 0x"
@@ -1146,9 +1141,4 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
public static boolean isKDE() {
return isKDE;
}
// called from native
private static void handleToplevelIconSize(int size) {
preferredIconSizes.add(size);
}
}

View File

@@ -39,9 +39,7 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.RenderingHints;
@@ -53,7 +51,6 @@ import java.awt.image.BufferedImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.WindowPeer;
import java.lang.ref.WeakReference;
import java.util.List;
public class WLWindowPeer extends WLComponentPeer implements WindowPeer, SurfacePixelGrabber {
private static Font defaultFont;
@@ -183,38 +180,7 @@ public class WLWindowPeer extends WLComponentPeer implements WindowPeer, Surface
@Override
public void updateIconImages() {
List<Image> iconImages = getWindow().getIconImages();
if (iconImages == null || iconImages.isEmpty()) {
setIcon(0, null);
return;
}
Image image = iconImages.stream()
.filter(x -> x.getWidth(null) > 0 && x.getHeight(null) > 0)
.filter(x -> x.getWidth(null) == x.getHeight(null))
.max((a, b) -> Integer.compare(a.getWidth(null), b.getWidth(null)))
.orElse(null);
if (image == null) {
return;
}
int width = image.getWidth(null);
int height = image.getHeight(null);
int size = width;
BufferedImage bufferedImage;
if (image instanceof BufferedImage && ((BufferedImage) image).getType() == BufferedImage.TYPE_INT_ARGB) {
bufferedImage = (BufferedImage) image;
} else {
bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bufferedImage.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
}
int[] pixels = new int[width * height];
bufferedImage.getRGB(0, 0, width, height, pixels, 0, width);
setIcon(size, pixels);
// No support for this from Wayland, icon is a desktop integration feature.
}
@Override

View File

@@ -67,7 +67,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
public void startTracking(final Component component) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer(
@@ -108,7 +108,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
}
public void stopTrackingCurrentComponent() {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer(String.format("stopTrackingCurrentComponent(): this=%s.", this), new Throwable("Stacktrace"));
@@ -160,7 +160,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
}
public Component getTrackedComponentIfTracking() {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
final Component trackedComponentStrong;
if (trackedComponent == null) {
@@ -188,7 +188,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
public void deferUpdates() {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer(String.format("deferUpdates(): this=%s.", this), new Throwable("Stacktrace"));
@@ -198,7 +198,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
}
public void resumeUpdates(final boolean discardDeferredUpdates) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer(String.format("resumeUpdates(%b): this=%s.", discardDeferredUpdates, this), new Throwable("Stacktrace"));
@@ -215,7 +215,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
}
public boolean areUpdatesDeferred() {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
return updatesAreDeferred;
}
@@ -225,7 +225,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
/** This method is intended to be called from the owning IM's {@link java.awt.im.spi.InputMethod#dispatchEvent(AWTEvent)}. */
public void onIMDispatchEvent(AWTEvent event) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("onIMDispatchEvent(event={0}): this={1}.", event, this);
@@ -254,7 +254,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
/** This method is intended to be called from the owning IM's {@link java.awt.im.spi.InputMethod#notifyClientWindowChange(Rectangle)}. */
public void onIMNotifyClientWindowChange(Rectangle location) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("onIMNotifyClientWindowChange(location={0}): this={1}.", location, this);
@@ -333,7 +333,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
private WLInputMethodZwpTextInputV3 getOwnerIm() {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
final WLInputMethodZwpTextInputV3 thisImStrong;
if (this.im == null) {

View File

@@ -40,7 +40,7 @@ final class InputContextState {
public InputContextState(long nativeContextPtr) {
assert nativeContextPtr != 0 : "Cannot create an input context from a NULL pointer";
assert(nativeContextPtr != 0);
this.nativeContextPtr = nativeContextPtr;
}

View File

@@ -82,8 +82,8 @@ record JavaPreeditString(String text, int cursorBeginCodeUnit, int cursorEndCode
}
if (resultText == null) {
assert fixedCursorBeginUtf8Byte == 0 : "Cursor begin byte must be zero for an empty string";
assert fixedCursorEndUtf8Byte == 0 : "Cursor end byte must be zero for an empty string";
assert(fixedCursorBeginUtf8Byte == 0);
assert(fixedCursorEndUtf8Byte == 0);
return JavaPreeditString.EMPTY;
}

View File

@@ -71,7 +71,7 @@ public final class WLInputMethodDescriptorZwpTextInputV3 implements InputMethodD
@Override
public String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) {
assert isAvailableOnPlatform() : "IM must be available on the platform";
assert isAvailableOnPlatform();
// This is how it's implemented in all other Toolkits.
//
@@ -183,7 +183,7 @@ public final class WLInputMethodDescriptorZwpTextInputV3 implements InputMethodD
private WLInputMethodDescriptorZwpTextInputV3() {
assert isAvailableOnPlatform() : "IM must be available on the platform";
assert isAvailableOnPlatform();
initAndGetToolkitStartupLocale();
}

View File

@@ -243,7 +243,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
}
// "The method is only called when the input method is inactive."
assert this.awtActivationStatus != AWTActivationStatus.ACTIVATED : "The method is called when the IM is active";
assert(this.awtActivationStatus != AWTActivationStatus.ACTIVATED);
// The protocol doesn't provide a separate method for hiding the IM window(s),
// but this effect can be achieved by disabling the native context.
@@ -259,7 +259,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
}
// "The method is only called when the input method is inactive."
assert this.awtActivationStatus != AWTActivationStatus.ACTIVATED : "The method is called when the IM is active";
assert(this.awtActivationStatus != AWTActivationStatus.ACTIVATED);
wlDisableContextNow();
}
@@ -374,10 +374,10 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/* AWT-side methods section */
private static void awtFillWlContentTypeOf(Component component, OutgoingChanges out) {
assert component != null : "Component must not be null";
assert out != null : "OutgoingChanges must not be null";
assert(component != null);
assert(out != null);
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
// TODO: there's no dedicated AWT/Swing API for that, but we can make a few guesses, e.g.
// (component instanceof JPasswordField) ? ContentPurpose.PASSWORD
@@ -389,7 +389,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* compatible with {@code zwp_text_input_v3::set_cursor_rectangle} API;
*/
private static Rectangle awtGetWlCursorRectangleOf(Component component) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
Rectangle result = null;
@@ -434,7 +434,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* @throws IllegalArgumentException if {@code visibleComponent} is {@code null} or isn't showing on the screen.
*/
private static Rectangle awtGetCaretOf(Component visibleComponent) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (!Objects.requireNonNull(visibleComponent, "visibleComponent").isShowing()) {
throw new IllegalArgumentException("visibleComponent must be showing");
@@ -474,7 +474,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
}
private static Rectangle awtGetVisibleRectOf(final Component component) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (component instanceof javax.swing.JComponent jComponent) {
return jComponent.getVisibleRect();
@@ -488,7 +488,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* or {@code null} if the rectangle couldn't be determined.
*/
private static Rectangle awtConvertRectOnComponentToRectOnWlSurface(Component component, Rectangle rectOnComponent) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
Objects.requireNonNull(component, "component");
@@ -536,7 +536,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* or its closest ancestor meeting these requirements.
*/
private static Window awtGetWlSurfaceComponentOf(Component component) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
return WLComponentPeer.getToplevelFor(component);
}
@@ -557,8 +557,8 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
log.finer("awtPostIMESafely(preeditString={0}, commitString={1}): this={2}.", preeditString, commitString, this);
}
assert preeditString != null : "Pre-edit string must be present";
assert commitString != null : "Commit string must be present";
assert(preeditString != null);
assert(commitString != null);
try {
if (awtActivationStatus != AWTActivationStatus.ACTIVATED) {
@@ -699,10 +699,6 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
String.format("awtPostIMESafely(...): posting a new InputMethodEvent=%s. this=%s.", ime, this),
new Throwable("Stacktrace")
);
// JBR-9719: reset ime's text iterator after logging
final var textIterToReset = ime.getText();
if (textIterToReset != null) textIterToReset.first();
}
SunToolkit.postEvent(SunToolkit.targetToAppContext(clientComponent), ime);
@@ -769,8 +765,8 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
specialPreeditHighlightingBegin = swapTemp;
}
assert specialPreeditHighlightingBegin >= 0 : "specialPreeditHighlightingBegin is invalid";
assert specialPreeditHighlightingEnd <= preeditTextLength : "specialPreeditHighlightingEnd is out of range";
assert(specialPreeditHighlightingBegin >= 0);
assert(specialPreeditHighlightingEnd <= preeditTextLength);
// v
// |BASIC+SPECIAL...|
@@ -827,10 +823,10 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
// The methods in this section implement the core logic of working with the "text-input-unstable-v3" protocol.
private void wlInitializeContext() throws AWTException {
assert wlInputContextState == null : "Must not initialize input context twice";
assert wlPendingChanges == null : "Must not initialize pending changes twice";
assert wlBeingCommittedChanges == null : "Must not initialize being-committed changes twice";
assert wlIncomingChanges == null : "Must not initialize incoming changes twice";
assert(wlInputContextState == null);
assert(wlPendingChanges == null);
assert(wlBeingCommittedChanges == null);
assert(wlIncomingChanges == null);
long nativeCtxPtr = 0;
@@ -878,7 +874,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* followed by a {@code zwp_text_input_v3::commit} request.
*/
private void wlSendPendingChangesNow() {
assert wlCanSendChangesNow() : "Must be able to send pending changes now";
assert(wlCanSendChangesNow());
final OutgoingChanges changesToSend = wlPendingChanges;
wlPendingChanges = null;
@@ -997,7 +993,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
throw new IllegalStateException("Attempt to enable an input context which hasn't entered any surface");
}
assert wlContextCanBeEnabledNow() : "Can't enable InputContext";
assert(wlContextCanBeEnabledNow());
// This way we guarantee the context won't accidentally get disabled because such a change has been scheduled earlier.
// Anyway we consider any previously scheduled changes outdated because an 'enable' request is supposed to
@@ -1029,7 +1025,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
awtFillWlContentTypeOf(getClientComponent(), changeSet);
wlScheduleContextNewChanges(changeSet);
assert wlPendingChanges != null : "Must have non-empty pending changes";
assert(wlPendingChanges != null);
// Pretending there are no committed, but not applied yet changes, so that wlCanSendChangesNow() is true.
// We can do that because the assumption #1 and because any previously committed changes get lost when a
@@ -1038,7 +1034,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
// set_surrounding_text, set_text_change_cause, set_content_type, and set_cursor_rectangle requests [...]"
wlBeingCommittedChanges = null;
assert wlCanSendChangesNow() : "Must be able to send pending changes now";
assert(wlCanSendChangesNow());
wlSendPendingChangesNow();
// See the assumption #2 above.
@@ -1103,10 +1099,10 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
}
}
assert wlInputContextState.getCurrentWlSurfacePtr() != 0 : "InputContext must have a valid current surface pointer";
assert(wlInputContextState.getCurrentWlSurfacePtr() != 0);
wlScheduleContextNewChanges(new OutgoingChanges().setEnabledState(false));
assert wlPendingChanges != null : "Must have non-empty pending changes";
assert(wlPendingChanges != null);
// Pretending there are no committed, but not applied yet changes, so that wlCanSendChangesNow() is true.
// We can do that because the assumption #1 and because any previously committed changes get lost when a
@@ -1114,7 +1110,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
// "After an enter event or disable request all state information is invalidated and needs to be resent by the client."
wlBeingCommittedChanges = null;
assert wlCanSendChangesNow() : "Must be able to send pending changes now";
assert(wlCanSendChangesNow());
wlSendPendingChangesNow();
// See the assumption #2 above.
@@ -1206,7 +1202,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called by {@link ClientComponentCaretPositionTracker} */
boolean wlUpdateCursorRectangle(final boolean forceUpdate) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert(EventQueue.isDispatchThread());
if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("wlUpdateCursorRectangle(): forceUpdate={0}, this={1}.", forceUpdate, this);
@@ -1290,7 +1286,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::enter} events. */
private void zwp_text_input_v3_onEnter(long enteredWlSurfacePtr) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
try {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1312,7 +1308,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::leave} events. */
private void zwp_text_input_v3_onLeave(long leftWlSurfacePtr) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
try {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1335,7 +1331,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::preedit_string} events. */
private void zwp_text_input_v3_onPreeditString(byte[] preeditStrUtf8, int cursorBeginUtf8Byte, int cursorEndUtf8Byte) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
try {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1355,7 +1351,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::commit_string} events. */
private void zwp_text_input_v3_onCommitString(byte[] commitStrUtf8) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
try {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1375,7 +1371,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::delete_surrounding_text} events. */
private void zwp_text_input_v3_onDeleteSurroundingText(long numberOfUtf8BytesBeforeToDelete, long numberOfUtf8BytesAfterToDelete) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
// TODO: support the surrounding text API (set_surrounding_text + set_text_change_cause | delete_surrounding text)
// at least for particular cases.
@@ -1394,7 +1390,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::done} events. */
private void zwp_text_input_v3_onDone(long doneSerial) {
assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
assert EventQueue.isDispatchThread();
try {
if (log.isLoggable(PlatformLogger.Level.FINE)) {

View File

@@ -36,8 +36,6 @@
#include "WLGraphicsEnvironment.h"
#include "xdg-decoration-unstable-v1.h"
#include <stdbool.h>
#ifdef WAKEFIELD_ROBOT
#include "wakefield.h"
#endif
@@ -69,9 +67,6 @@ struct WLFrame {
jboolean configuredActive;
jboolean configuredMaximized;
jboolean configuredFullscreen;
struct wl_buffer* iconBuffer;
struct wl_shm_pool* iconPool;
};
static void
@@ -387,7 +382,7 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreateWindow
static struct xdg_positioner *
newPositioner
(jint width, jint height, jint offsetX, jint offsetY, jboolean isUnconstrained)
(jint width, jint height, jint offsetX, jint offsetY)
{
struct xdg_positioner *xdg_positioner = xdg_wm_base_create_positioner(xdg_wm_base);
CHECK_NULL_RETURN(xdg_positioner, NULL);
@@ -400,15 +395,10 @@ newPositioner
xdg_positioner_set_offset(xdg_positioner, 0, 0);
xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT);
xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
if (isUnconstrained) {
xdg_positioner_set_constraint_adjustment(xdg_positioner,
XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE);
} else {
xdg_positioner_set_constraint_adjustment(xdg_positioner,
XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y
| XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X
| XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y);
}
xdg_positioner_set_constraint_adjustment(xdg_positioner,
XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y
| XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X
| XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y);
return xdg_positioner;
}
@@ -416,8 +406,7 @@ JNIEXPORT void JNICALL
Java_sun_awt_wl_WLComponentPeer_nativeCreatePopup
(JNIEnv *env, jobject obj, jlong ptr, jlong parentPtr, jlong wlSurfacePtr,
jint width, jint height,
jint offsetX, jint offsetY,
jboolean isUnconstrained)
jint offsetX, jint offsetY)
{
struct WLFrame *frame = (struct WLFrame *) ptr;
struct WLFrame *parentFrame = (struct WLFrame*) parentPtr;
@@ -429,7 +418,7 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreatePopup
frame->toplevel = JNI_FALSE;
assert(parentFrame);
struct xdg_positioner *xdg_positioner = newPositioner(width, height, offsetX, offsetY, isUnconstrained);
struct xdg_positioner *xdg_positioner = newPositioner(width, height, offsetX, offsetY);
CHECK_NULL(xdg_positioner);
JNU_RUNTIME_ASSERT(env, parentFrame->toplevel, "Popup's parent surface must be a toplevel");
frame->xdg_popup = xdg_surface_get_popup(frame->xdg_surface, parentFrame->xdg_surface, xdg_positioner);
@@ -442,14 +431,13 @@ JNIEXPORT void JNICALL
Java_sun_awt_wl_WLComponentPeer_nativeRepositionWLPopup
(JNIEnv *env, jobject obj, jlong ptr,
jint width, jint height,
jint offsetX, jint offsetY,
jboolean isUnconstrained)
jint offsetX, jint offsetY)
{
struct WLFrame *frame = jlong_to_ptr(ptr);
assert (!frame->toplevel);
if (wl_proxy_get_version((struct wl_proxy *)xdg_wm_base) >= 3) {
struct xdg_positioner *xdg_positioner = newPositioner(width, height, offsetX, offsetY, isUnconstrained);
struct xdg_positioner *xdg_positioner = newPositioner(width, height, offsetX, offsetY);
CHECK_NULL(xdg_positioner);
static int token = 42; // This will be received by xdg_popup_repositioned(); unused for now.
xdg_popup_reposition(frame->xdg_popup, xdg_positioner, token++);
@@ -583,57 +571,3 @@ JNIEXPORT void JNICALL Java_sun_awt_wl_ServerSideFrameDecoration_disposeImpl
}
}
JNIEXPORT void JNICALL Java_sun_awt_wl_WLComponentPeer_nativeSetIcon
(JNIEnv *env, jobject obj, jlong ptr, jint size, jobject pixelArray)
{
struct WLFrame *frame = jlong_to_ptr(ptr);
if (frame == NULL || !frame->toplevel || xdg_toplevel_icon_manager == NULL) {
return;
}
bool hasIcon = frame->iconBuffer != NULL;
bool willHaveIcon = size > 0 && pixelArray != NULL;
size_t iconByteSize = size * size * 4;
if (!willHaveIcon) {
xdg_toplevel_icon_manager_v1_set_icon(xdg_toplevel_icon_manager, frame->xdg_toplevel, NULL);
}
if (hasIcon) {
if (frame->iconBuffer != NULL) {
wl_buffer_destroy(frame->iconBuffer);
frame->iconBuffer = NULL;
}
if (frame->iconPool != NULL) {
wl_shm_pool_destroy(frame->iconPool);
frame->iconPool = NULL;
}
}
if (willHaveIcon) {
void* poolData = NULL;
struct wl_shm_pool* pool = CreateShmPool(iconByteSize, "toplevel_icon", &poolData, NULL);
if (pool == NULL) {
return;
}
(*env)->GetIntArrayRegion(env, pixelArray, 0, size * size, poolData);
struct wl_buffer* buffer = wl_shm_pool_create_buffer(pool, 0, size, size, size * 4, WL_SHM_FORMAT_ARGB8888);
if (buffer == NULL) {
wl_shm_pool_destroy(pool);
return;
}
struct xdg_toplevel_icon_v1* icon = xdg_toplevel_icon_manager_v1_create_icon(xdg_toplevel_icon_manager);
if (icon == NULL) {
wl_buffer_destroy(buffer);
wl_shm_pool_destroy(pool);
return;
}
xdg_toplevel_icon_v1_add_buffer(icon, buffer, 1);
xdg_toplevel_icon_manager_v1_set_icon(xdg_toplevel_icon_manager, frame->xdg_toplevel, icon);
xdg_toplevel_icon_v1_destroy(icon);
frame->iconPool = pool;
frame->iconBuffer = buffer;
}
}

View File

@@ -93,10 +93,8 @@ struct zwp_primary_selection_device_manager_v1 *zwp_selection_dm = NULL; // opti
struct zxdg_output_manager_v1 *zxdg_output_manager_v1 = NULL; // optional, check for NULL before use
struct zwp_text_input_manager_v3 *zwp_text_input_manager = NULL; // optional, check for NULL before use
struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager; // optional, check for NULL before use
static uint32_t num_of_outstanding_sync = 0;
static bool waiting_for_xdg_toplevel_icon_manager_done = false;
// This group of definitions corresponds to declarations from awt.h
jclass tkClass = NULL;
@@ -137,7 +135,6 @@ static jmethodID dispatchKeyboardModifiersEventMID;
static jmethodID dispatchKeyboardEnterEventMID;
static jmethodID dispatchKeyboardLeaveEventMID;
static jmethodID dispatchRelativePointerEventMID;
static jmethodID handleToplevelIconSizeMID;
JNIEnv *getEnv() {
JNIEnv *env;
@@ -573,36 +570,6 @@ static const struct wl_seat_listener wl_seat_listener = {
.name = wl_seat_name
};
static void
xdg_toplevel_icon_manager_icon_size(void *data,
struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1,
int32_t size)
{
(void)data;
(void)xdg_toplevel_icon_manager_v1;
JNIEnv* env = getEnv();
if (env == NULL) {
return;
}
(*env)->CallStaticVoidMethod(env, tkClass, handleToplevelIconSizeMID, size);
JNU_CHECK_EXCEPTION(env);
}
static void
xdg_toplevel_icon_manager_icon_size_done(void *data,
struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1)
{
(void)data;
(void)xdg_toplevel_icon_manager_v1;
waiting_for_xdg_toplevel_icon_manager_done = false;
}
static const struct xdg_toplevel_icon_manager_v1_listener xdg_toplevel_icon_manager_v1_listener = {
.icon_size = xdg_toplevel_icon_manager_icon_size,
.done = xdg_toplevel_icon_manager_icon_size_done,
};
static void
registry_global(void *data, struct wl_registry *wl_registry,
uint32_t name, const char *interface, uint32_t version)
@@ -669,12 +636,6 @@ registry_global(void *data, struct wl_registry *wl_registry,
}
} else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
xdg_decoration_manager = wl_registry_bind(wl_registry, name, &zxdg_decoration_manager_v1_interface, 1);
} else if (strcmp(interface, xdg_toplevel_icon_manager_v1_interface.name) == 0) {
xdg_toplevel_icon_manager = wl_registry_bind(wl_registry, name, &xdg_toplevel_icon_manager_v1_interface, 1);
if (xdg_toplevel_icon_manager != NULL) {
waiting_for_xdg_toplevel_icon_manager_done = true;
xdg_toplevel_icon_manager_v1_add_listener(xdg_toplevel_icon_manager, &xdg_toplevel_icon_manager_v1_listener, NULL);
}
}
#ifdef WAKEFIELD_ROBOT
@@ -749,11 +710,6 @@ initJavaRefs(JNIEnv *env, jclass clazz)
"(Lsun/awt/wl/WLPointerEvent;)V"),
JNI_FALSE);
CHECK_NULL_RETURN(handleToplevelIconSizeMID = (*env)->GetStaticMethodID(env, tkClass,
"handleToplevelIconSize",
"(I)V"),
JNI_FALSE);
CHECK_NULL_RETURN(pointerEventClass = (*env)->FindClass(env,
"sun/awt/wl/WLPointerEvent"),
JNI_FALSE);
@@ -888,7 +844,7 @@ getCursorTheme(int scale) {
static void
finalizeInit(JNIEnv *env) {
// NB: we are NOT on EDT here so shouldn't dispatch EDT-sensitive stuff
while (num_of_outstanding_sync > 0 || waiting_for_xdg_toplevel_icon_manager_done) {
while (num_of_outstanding_sync > 0) {
// There are outstanding events that carry information essential for the toolkit
// to be fully operational, such as, for example, the number of outputs.
// Those events were subscribed to when handling globals in registry_global().

View File

@@ -33,7 +33,7 @@
#include "relative-pointer-unstable-v1.h"
#include "text-input-unstable-v3.h"
#include "xdg-decoration-unstable-v1.h"
#include "xdg-toplevel-icon-v1.h"
#include "jvm_md.h"
#include "jni_util.h"
@@ -73,7 +73,6 @@ extern struct zxdg_output_manager_v1 *zxdg_output_manager_v1; // optional, check
extern struct zwp_relative_pointer_manager_v1* relative_pointer_manager;
extern struct zwp_text_input_manager_v3 *zwp_text_input_manager; // optional, check for NULL before use
extern struct zxdg_decoration_manager_v1* xdg_decoration_manager; // optional, check for NULL before use
extern struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager; // optional, check for NULL before use
JNIEnv *getEnv();

View File

@@ -1,5 +1,4 @@
import com.jetbrains.desktop.SharedTextures;
import com.jetbrains.desktop.SharedTexturesService;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@@ -32,8 +31,8 @@ public class SharedTexturesTest {
BufferedImage originalImage = createImage();
byte[] bytes = getPixelData(originalImage);
SharedTextures sharedTexturesService = new SharedTexturesService();
Asserts.assertEquals(sharedTexturesService.getTextureType(), SharedTexturesService.METAL_TEXTURE_TYPE);
SharedTextures sharedTexturesService = SharedTextures.create();
Asserts.assertEquals(sharedTexturesService.getTextureType(), SharedTextures.METAL_TEXTURE_TYPE);
BufferedImage bufferedImageContent;
BufferedImage volatileImageContent;
@@ -147,4 +146,4 @@ public class SharedTexturesTest {
return count;
}
}
}

View File

@@ -1,178 +0,0 @@
/*
* Copyright 2025 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 if the machine is equipped with mouse then all the buttons were pressed and released
* @key headful
* @run main/othervm/manual MouseBackForwardButtonsTest
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class MouseBackForwardButtonsTest extends JFrame {
static final CompletableFuture<RuntimeException> swingError = new CompletableFuture<>();
public static void main(String[] args) throws InterruptedException, InvocationTargetException, ExecutionException {
final MouseBackForwardButtonsTest frame;
{
final CompletableFuture<MouseBackForwardButtonsTest> frameFuture = new CompletableFuture<>();
SwingUtilities.invokeAndWait(() -> {
try {
final var result = new MouseBackForwardButtonsTest();
result.setVisible(true);
frameFuture.complete(result);
} catch (Throwable err) {
frameFuture.completeExceptionally(err);
}
});
frame = frameFuture.get();
}
try {
final var err = swingError.get();
if (err != null) {
throw err;
}
} finally {
if (frame != null) {
SwingUtilities.invokeAndWait(frame::dispose);
}
}
}
public MouseBackForwardButtonsTest() {
super("Test mouse buttons");
setDefaultCloseOperation(HIDE_ON_CLOSE);
mouseButtonsTextArea = new JTextArea();
mouseButtonsTextArea.setLineWrap(true);
mouseButtonsTextArea.setWrapStyleWord(true);
mouseButtonsTextArea.setText(
"""
INSTRUCTION:
1. Hover mouse cursor over this text area
2. Press each mouse button one by one
3. Verify the accuracy of the displayed information regarding the button pressed.
"""
);
mouseButtonsTextArea.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
final int button = e.getButton();
// On X11, ButtonPress/ButtonRelease native events use the following button indices for different buttons:
// 1: left mouse button
// 2: middle mouse button (the primary wheel)
// 3: right mouse button
// 4, 5: rotations of the primary mouse wheel (depending on the rotation direction)
// 6, 7: rotations of the secondary mouse wheel (it's usually used for horizontal scrolling)
// >= 8: all extra buttons
//
// XToolkit handles them as the following:
// 1, 2, 3: mapped to MouseEvent as-is
// 4, 5: mapped to MouseWheelEvent
// >= 6: mapped to MouseEvent with the button set to 2 less
//
// In other words, MouseEvent.getButton() under XToolkit means the following:
// 1, 2, 3: left mouse button, middle mouse button, right mouse button respectively
// 4, 5: rotations of the secondary mouse wheel
// >= 6: extra buttons
if ("sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
if (button == MouseEvent.BUTTON1) {
mouseButtonsTextArea.append("-->Left mouse button pressed.\n");
} else if (button == MouseEvent.BUTTON2) {
mouseButtonsTextArea.append("-->Middle mouse button pressed.\n");
} else if (button == MouseEvent.BUTTON3) {
mouseButtonsTextArea.append("-->Right mouse button pressed.\n");
} else if (button == 4) {
mouseButtonsTextArea.append("-->Horizontal scrolling (direction 1).\n");
} else if (button == 5) {
mouseButtonsTextArea.append("-->Horizontal scrolling (direction 2).\n");
} else if (button == 6) {
mouseButtonsTextArea.append("-->Mouse button 6 (Back) pressed.\n");
} else if (button == 7) {
mouseButtonsTextArea.append("-->Mouse button 7 (Forward) pressed.\n");
} else {
mouseButtonsTextArea.append("Other mouse button pressed: " + button + "\n");
}
} else {
if (button == MouseEvent.BUTTON1) {
mouseButtonsTextArea.append("-->Left mouse button pressed.\n");
} else if (button == MouseEvent.BUTTON2) {
mouseButtonsTextArea.append("-->Middle mouse button pressed.\n");
} else if (button == MouseEvent.BUTTON3) {
mouseButtonsTextArea.append("-->Right mouse button pressed.\n");
} else if (button == 4) { // Check for button 4
mouseButtonsTextArea.append("-->Mouse button 4 (Back) pressed.\n");
} else if (button == 5) { // Check for button 5
mouseButtonsTextArea.append("-->Mouse button 5 (Forward) pressed.\n");
} else {
mouseButtonsTextArea.append("Other mouse button pressed: " + button + "\n");
}
}
}
});
mouseButtonsTextArea.setEditable(false);
final JScrollPane mouseButtonTextAreaScrollPane = new JScrollPane(mouseButtonsTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(mouseButtonTextAreaScrollPane, BorderLayout.CENTER);
final JPanel southContainer = new JPanel(new BorderLayout());
JButton failTestButton = new JButton("FAIL");
JButton passTestButton = new JButton("PASS");
southContainer.add(failTestButton, BorderLayout.LINE_START);
southContainer.add(passTestButton, BorderLayout.LINE_END);
add(southContainer, BorderLayout.SOUTH);
pack();
setSize(400, 250);
setLocationRelativeTo(null);
failTestButton.addActionListener(ignored -> swingError.completeExceptionally(new RuntimeException("The tester has pressed FAILED")));
passTestButton.addActionListener(ignored -> swingError.complete(null));
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
swingError.completeExceptionally(new RuntimeException("The window was closed not through the \"PASS\"/\"FAIL\" buttons"));
}
});
}
private final JTextArea mouseButtonsTextArea;
}

View File

@@ -49,19 +49,16 @@ public class ManglingFileSystem extends FileSystem {
@Override
public void close() throws IOException {
ManglingFileSystemProvider.triggerSporadicFileAccess();
provider.defaultFs.close();
}
@Override
public boolean isOpen() {
ManglingFileSystemProvider.triggerSporadicFileAccess();
return provider.defaultFs.isOpen();
}
@Override
public boolean isReadOnly() {
ManglingFileSystemProvider.triggerSporadicFileAccess();
return provider.defaultFs.isReadOnly();
}
@@ -72,7 +69,6 @@ public class ManglingFileSystem extends FileSystem {
@Override
public Iterable<Path> getRootDirectories() {
ManglingFileSystemProvider.triggerSporadicFileAccess();
Iterable<Path> delegateRoots = provider.defaultFs.getRootDirectories();
List<Path> result = new ArrayList<>();
for (Path delegateRoot : delegateRoots) {
@@ -90,13 +86,11 @@ public class ManglingFileSystem extends FileSystem {
@Override
public Iterable<FileStore> getFileStores() {
ManglingFileSystemProvider.triggerSporadicFileAccess();
return provider.defaultFs.getFileStores();
}
@Override
public Set<String> supportedFileAttributeViews() {
ManglingFileSystemProvider.triggerSporadicFileAccess();
return provider.defaultFs.supportedFileAttributeViews();
}

View File

@@ -23,12 +23,19 @@
package testNio;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.channels.FileChannel;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.*;
import java.nio.file.AccessDeniedException;
import java.nio.file.AccessMode;
import java.nio.file.CopyOption;
import java.nio.file.DirectoryStream;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.DosFileAttributeView;
@@ -41,7 +48,6 @@ import java.nio.file.spi.FileSystemProvider;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
public class ManglingFileSystemProvider extends FileSystemProvider {
public static final String extraContent = "3x7r4";
@@ -162,7 +168,6 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
triggerSporadicFileAccess();
return new ManglingFileChannel(defaultProvider.newFileChannel(unwrap(path), options, attrs));
}
@@ -173,13 +178,11 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException {
triggerSporadicFileAccess();
return new ManglingDirectoryStream(manglingFs, (ManglingPath) dir, defaultProvider.newDirectoryStream(unwrap(dir), filter));
}
@Override
public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException {
triggerSporadicFileAccess();
if (prohibitFileTreeModifications) {
throw new AccessDeniedException(dir.toString(), null, "Test: All file tree modifications are prohibited");
}
@@ -188,7 +191,6 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public void delete(Path path) throws IOException {
triggerSporadicFileAccess();
if (prohibitFileTreeModifications) {
throw new AccessDeniedException(path.toString(), null, "Test: All file tree modifications are prohibited");
}
@@ -197,7 +199,6 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public void copy(Path source, Path target, CopyOption... options) throws IOException {
triggerSporadicFileAccess();
if (prohibitFileTreeModifications) {
throw new AccessDeniedException(source.toString(), null, "Test: All file tree modifications are prohibited");
}
@@ -208,7 +209,6 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
triggerSporadicFileAccess();
if (prohibitFileTreeModifications) {
throw new AccessDeniedException(source.toString(), null, "Test: All file tree modifications are prohibited");
}
@@ -219,7 +219,6 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public boolean isSameFile(Path path, Path path2) throws IOException {
triggerSporadicFileAccess();
Path source2 = unwrap(path);
Path target2 = unwrap(path2);
return defaultProvider.isSameFile(source2, target2);
@@ -227,19 +226,16 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public boolean isHidden(Path path) throws IOException {
triggerSporadicFileAccess();
return defaultProvider.isHidden(unwrap(path));
}
@Override
public FileStore getFileStore(Path path) throws IOException {
triggerSporadicFileAccess();
return defaultProvider.getFileStore(unwrap(path));
}
@Override
public void checkAccess(Path path, AccessMode... modes) throws IOException {
triggerSporadicFileAccess();
defaultProvider.checkAccess(unwrap(path), modes);
if (denyAccessToEverything) {
throw new AccessDeniedException(path.toString(), null, "Test: No access rules to anything");
@@ -248,13 +244,11 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
triggerSporadicFileAccess();
return wrap(defaultProvider.getFileAttributeView(unwrap(path), type, options));
}
@Override
public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException {
triggerSporadicFileAccess();
return wrap(defaultProvider.readAttributes(unwrap(path), type, options));
}
@@ -265,7 +259,6 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException {
triggerSporadicFileAccess();
if (prohibitFileTreeModifications) {
throw new AccessDeniedException(path.toString(), null, "Test: All file tree modifications are prohibited");
}
@@ -274,13 +267,11 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
@Override
public boolean exists(Path path, LinkOption... options) {
triggerSporadicFileAccess();
return defaultProvider.exists(unwrap(path), options);
}
@Override
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException {
triggerSporadicFileAccess();
if (prohibitFileTreeModifications) {
throw new AccessDeniedException(link.toString(), null, "Test: All file tree modifications are prohibited");
}
@@ -312,26 +303,4 @@ public class ManglingFileSystemProvider extends FileSystemProvider {
}
return view;
}
private static final AtomicLong counter = new AtomicLong();
static void triggerSporadicFileAccess() {
if (FileSystems.getDefault() != null) {
try {
var tempFile = new File(System.getProperty("java.io.tmpdir"), "test.tmp." + counter.incrementAndGet());
try {
try (var out = new java.io.FileOutputStream(tempFile)) {
out.write(1);
}
try (var in = new java.io.FileInputStream(tempFile)) {
in.read();
}
} finally {
tempFile.delete();
}
} catch (Exception e) {
throw new Error(e);
}
}
}
}

View File

@@ -166,7 +166,6 @@ public class ManglingPath implements Path {
@Override
public Path toRealPath(LinkOption... options) throws IOException {
ManglingFileSystemProvider.triggerSporadicFileAccess();
return new ManglingPath(fileSystem, delegate.toRealPath(options));
}

View File

@@ -1,95 +0,0 @@
/*
* Copyright 2025 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.
*/
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import java.awt.GridLayout;
import java.awt.Window;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.util.concurrent.CompletableFuture;
/**
* @test
* @summary Verifies popups can be located regardless of the screen edge proximity
* @requires os.family == "linux"
* @key headful
* @modules java.desktop/sun.awt
* @run main/manual WLPopupUnconstrained
*/
public class WLPopupUnconstrained {
static final CompletableFuture<RuntimeException> swingError = new CompletableFuture<>();
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(WLPopupUnconstrained::showUI);
swingError.get();
}
private static void showUI() {
JFrame frame = new JFrame("Unconstrained popup test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Right-click here for a popup.");
JPanel popupContents = new JPanel();
popupContents.add(new JLabel("test popup"));
JWindow popup = new JWindow(frame);
popup.setType(Window.Type.POPUP);
sun.awt.AWTAccessor.getWindowAccessor().setPopupParent(popup, label);
popup.getRootPane().putClientProperty("wlawt.popup_position_unconstrained", Boolean.TRUE);
popup.setSize(300, 250);
popup.add(popupContents);
label.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
popup.setLocation(e.getX(), e.getY());
popup.setVisible(true);
} else {
popup.setVisible(false);
}
}
});
JPanel content = new JPanel();
var layout = new GridLayout(3, 2, 10, 10);
content.setLayout(layout);
content.add(new JLabel("<html><h1>INSTRUCTIONS</h1>" +
"<p>Locate this window close to the bottom-right edge of the screen.</p>" +
"<p>Make the popup appear (on the right) such that it is partially outside the screen.</p>" +
"<p>Press Pass iff the popup indeed crossed the screen edge.</p>" +
"<p>Otherwise press Fail.</p></html>"));
content.add(label);
JButton passButton = new JButton("Pass");
passButton.addActionListener(e -> {swingError.complete(null);});
JButton failButton = new JButton("Fail");
failButton.addActionListener(e -> {swingError.completeExceptionally(new RuntimeException("The tester has pressed FAILED"));});
content.add(failButton);
content.add(passButton);
frame.setContentPane(content);
frame.pack();
frame.setVisible(true);
}
}

View File

@@ -53,7 +53,6 @@ javax/swing/JFileChooser/4966171/bug4966171.java JBR-8855 windows-x64
javax/swing/JFileChooser/bug4759934.java JBR-9711 windows-x64
javax/swing/JFileChooser/FileChooserListenerLeak.java JBR-8855 windows-x64
javax/swing/JFileChooser/JFileChooserFontReset.java JBR-8855 windows-x64
javax/swing/JFileChooser/JFileChooserSetLocationTest.java JBR-9702 windows-x64
javax/swing/JInternalFrame/Test6505027.java nobug macosx-all,linux-all,windows-all
javax/swing/JMenuBar/MenuBarRTLBug.java JBR-7385 windows-x64
javax/swing/JPopupMenu/4634626/bug4634626.java nobug macosx-all,linux-all,windows-all

View File

@@ -126,7 +126,7 @@ javax/swing/JButton/TestMnemonicAction.java JBR-6508 windows-all,linux-all,macos
javax/swing/JComboBox/8072767/bug8072767.java JBR-5540 windows-all,macosx-all
javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentCanvas.java JBR-7404 macosx-all
javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java JBR-9446 macosx-all
javax/swing/plaf/synth/7158712/bug7158712.java 8322653,JBR-9061 macosx-all,linux-6.8.0-1033-aws,linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws
javax/swing/plaf/synth/7158712/bug7158712.java 8322653,JBR-9061 macosx-all,linux-6.8.0-1033-aws,linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws
javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java JBR-5952,JBR-6274 windows-all,macosx-all
jb/build/ResolveSymbolsTest/ResolveSymbolsRealEnv.java JBR-8544 linux-all

View File

@@ -128,7 +128,7 @@ java/awt/event/StressTest/MouseAndKeyEventStressTest.java JBR-6479 generic-all
java/awt/FileDialog/8003399/bug8003399.java JBR-6930 windows-all
java/awt/FlowLayout/PreferredLayoutSize.java JBR-6349 linux-all
java/awt/Focus/EmptyWindowKeyTest.java JBR-7913 windows-all
java/awt/Focus/FocusKeepTest.java JBR-9487 linux-6.8.0-1040-aws,linux-6.8.0-1043-aws
java/awt/Focus/FocusKeepTest.java JBR-9487 linux-6.8.0-1040-aws
java/awt/Focus/FocusOwnerFrameOnClick/FocusOwnerFrameOnClick.java 8081489 generic-all
java/awt/Focus/FocusSubRequestTest/FocusSubRequestTest.java JBR-5178 windows-all
java/awt/Focus/FocusTransitionTest/FocusTransitionTest.java JBR-5809 linux-all
@@ -136,7 +136,7 @@ java/awt/Focus/FocusTraversalPolicy/ButtonGroupLayoutTraversal/ButtonGroupLayout
java/awt/Focus/FrameMinimizeTest/FrameMinimizeTest.java 8016266 linux-all
java/awt/Focus/IconifiedFrameFocusChangeTest/IconifiedFrameFocusChangeTest.java 6849364 generic-all
java/awt/Focus/InactiveFocusRace.java 8023263,JBR-8586 linux-all,windows-x64
java/awt/Focus/InputVerifierTest3/InputVerifierTest3.java JBR-7311 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws
java/awt/Focus/InputVerifierTest3/InputVerifierTest3.java JBR-7311 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws
java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusToFrontTest.java 6848406 generic-all
java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java 6848407 generic-all
java/awt/Focus/LabelScrollBarFocus.java JBR-8027 linux-all
@@ -584,7 +584,7 @@ java/awt/Modal/ModalFocusTransferTests/FocusTransferWDFNonModal1Test.java 825318
java/awt/Modal/ModalFocusTransferTests/FocusTransferWDFNonModal2Test.java 8253184,8196432 windows-all,linux-all
java/awt/Modal/ModalFocusTransferTests/FocusTransferWDFNonModal3Test.java 8253184 windows-all
java/awt/Modal/ModalInternalFrameTest/ModalInternalFrameTest.java 8253184,JBR-6302 windows-all,linux-all
java/awt/Modal/MultipleDialogs/MixOfModalAndNonModalDialogs.java JBR-9317 linux-6.16.7-100.fc41.x86_64,linux-linux-6.16.7-200.fc42.x86_64,linux-6.17.7-200.fc42.x86_64,linux-6.17.8-200.fc42.x86_64,linux-6.17.8-200.fc42.aarch64
java/awt/Modal/MultipleDialogs/MixOfModalAndNonModalDialogs.java JBR-9317 linux-6.16.7-100.fc41.x86_64,linux-linux-6.16.7-200.fc42.x86_64,linux-6.17.7-200.fc42.x86_64,linux-6.17.8-200.fc42.x86_64
java/awt/Modal/MultipleDialogs/MultipleDialogs1Test.java 8198665,8253184 macosx-all,windows-all
java/awt/Modal/MultipleDialogs/MultipleDialogs2Test.java 8198665,8253184 macosx-all,windows-all
java/awt/Modal/MultipleDialogs/MultipleDialogs3Test.java 8198665,8253184 macosx-all,windows-all,linux-all

View File

@@ -8,7 +8,7 @@ java/awt/dnd/DnDAWTLockTest.java JBR-8745 linux-all
java/awt/dnd/DragOverDropTargetPerformanceTest.java JBR-5799 windows-all
java/awt/dnd/DragSourceGCrashTest.java JBR-8745 linux-all
java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java JBR-8745 linux-all
java/awt/dnd/InterJVMLinkTest.java JBR-9255 linux-6.15.8-100.fc41.x86_64,linux-6.16.7-100.fc41.x86_64,linux-linux-6.16.7-200.fc42.x86_64,linux-6.17.7-200.fc42.x86_64,linux-6.17.8-200.fc42.x86_64,linux-6.17.8-200.fc42.aarch64
java/awt/dnd/InterJVMLinkTest.java JBR-9255 linux-6.15.8-100.fc41.x86_64,linux-6.16.7-100.fc41.x86_64,linux-linux-6.16.7-200.fc42.x86_64,linux-6.17.7-200.fc42.x86_64,linux-6.17.8-200.fc42.x86_64
java/awt/Dialog/ChoiceModalDialogTest.java JBR-8724 windows-all
java/awt/dnd/MozillaDnDTest.java JBR-6442 linux-all
java/awt/event/ComponentEvent/TextComponentTextEventTest.java JBR-6287 windows-all
@@ -70,7 +70,7 @@ javax/swing/JButton/bug4490179.java JBR-8925 windows-all
javax/swing/JFileChooser/JFileChooserSetLocationTest.java JBR-8098 linux-all,windows-all
javax/swing/JInternalFrame/4202966/IntFrameCoord.java JBR-9006 window-all
javax/swing/JMenu/bug4342646.java JBR-8727 linux-all,windows-all
javax/swing/JPopupMenu/6580930/bug6580930.java JBR-5071 linux-6.8.0-1033-aws,linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws,linux-6.15.8-100.fc41.x86_64,linux-6.16.7-100.fc41.x86_64
javax/swing/JPopupMenu/6580930/bug6580930.java JBR-5071 linux-6.8.0-1033-aws,linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.15.8-100.fc41.x86_64,linux-6.16.7-100.fc41.x86_64
javax/swing/JTable/JTableRightOrientationTest.java JBR-8102 linux-all,windows-all
javax/swing/text/ParagraphView/6364882/bug6364882.java JBR-8747 linux-all
javax/swing/plaf/basic/BasicGraphicsUtils/8132119/bug8132119.java JBR-8357 linux-all

View File

@@ -7,8 +7,8 @@ java/awt/image/DrawImage/BlitRotateClippedArea.java JBR-9026 linux-all
java/awt/image/DrawImage/EABlitTest.java JBR-9027 linux-all
javax/swing/GraphicsConfigNotifier/StalePreferredSize.java JBR-9031 linux-all
javax/swing/GraphicsConfigNotifier/TestMultiScreenGConfigNotify.java JBR-8266 linux-x64
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id0 JBR-7928,JBR-9341 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws,linux-6.14.9-arch1-1
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id2 JBR-7928 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id0 JBR-7928,JBR-9341 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.14.9-arch1-1
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id2 JBR-7928 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws
javax/swing/JEditorPane/JEditorPaneFontFallback.java JBR-8305 linux-all
javax/swing/JFormattedTextField/bug4741926.java JBR-9321 linux-6.14.9-arch1-1
javax/swing/JPasswordField/TestSelectedTextBackgroundColor.java JBR-9277 linux-6.14.9-arch1-1

View File

@@ -5,9 +5,9 @@ java/awt/Multiscreen/MultiScreenCheckScreenIDTest.java JBR-8263 linux-x64
javax/swing/JComponent/6989617/bug6989617.java JBR-8796 linux-6.14.0-1010-aws,linux-6.14.0-1012-aws,linux-6.14.0-1014-aws,linux-6.14.0-1015-aws
javax/swing/JDesktopPane/TestDesktopManagerNPE.java JBR-8449 linux-x64
javax/swing/GraphicsConfigNotifier/TestMultiScreenGConfigNotify.java JBR-8266 linux-x64
javax/swing/InputVerifier/VerifyTarget/VerifyTargetTest.java JBR-7520,JBR-9320 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws,linux-6.14.9-arch1-1
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id0 JBR-7928,JBR-9341 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws,linux-6.14.9-arch1-1
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id2 JBR-7928,JBR-9341 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.8.0-1043-aws,linux-6.14.9-arch1-1
javax/swing/InputVerifier/VerifyTarget/VerifyTargetTest.java JBR-7520,JBR-9320 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.14.9-arch1-1
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id0 JBR-7928,JBR-9341 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.14.9-arch1-1
javax/swing/JButton/SwingButtonResizeTestWithOpenGL.java#id2 JBR-7928,JBR-9341 linux-6.8.0-1036-aws,linux-6.8.0-1039-aws,linux-6.8.0-1040-aws,linux-6.14.9-arch1-1
javax/swing/JEditorPane/JEditorPaneFontFallback.java JBR-8305 linux-all
javax/swing/JFormattedTextField/bug4741926.java JBR-7530,JBR-9321 linux-all,linux-6.14.9-arch1-1
javax/swing/JFormattedTextField/TestSelectedTextBackgroundColor.java JBR-8790 linux-all