Compare commits

..

3 Commits

Author SHA1 Message Date
Vitaly Provodin
082e7010fe JBR-5989 Wayland: excluded failing tests came with 21.0.3 2024-04-24 04:39:19 +07:00
David Holmes
bb516821ba update exclude list on results of 21.0.3_b436.1 test runs 2024-04-24 04:39:19 +07:00
Vitaly Provodin
d9821157ff Revert "JBR-6372: implement detecting of OS theme on linux"
This reverts commit 51d67613bb.
2024-04-20 15:37:38 +07:00
37 changed files with 143 additions and 1279 deletions

View File

@@ -1,55 +0,0 @@
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2024, JetBrains s.r.o.. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. 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.
#
################################################################################
# Check if a potential dbus library match is correct and usable
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_DBUS],
[
AC_ARG_WITH(dbus-includes, [AS_HELP_STRING([--with-dbus-includes],
[specify include directories for the dbus files as list separated by space])])
if test "x$NEEDS_LIB_DBUS" = xfalse; then
DBUS_CFLAGS=
DBUS_FOUND=false
else
if test "x${with_dbus_includes}" != x; then
DBUS_FOUND=true
DBUS_CFLAGS=""
for include in $with_dbus_includes; do
DBUS_CFLAGS="${DBUS_CFLAGS}-I${include} "
done
else
PKG_CHECK_MODULES(DBUS, dbus-1, [DBUS_FOUND=true], [
DBUS_FOUND=false
AC_MSG_NOTICE([Can't find dbus-1 library. This library is needed to use some features. You can install dbus-1 library or specify include directories manually by giving --with-dbus-includes option.])
])
fi
fi
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_FOUND)
])

View File

@@ -37,7 +37,7 @@ m4_include([lib-fontconfig.m4])
m4_include([lib-speechd.m4])
m4_include([lib-nvdacontrollerclient.m4])
m4_include([lib-wayland.m4])
m4_include([lib-dbus.m4])
m4_include([lib-tests.m4])
################################################################################
@@ -90,13 +90,11 @@ AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES],
NEEDS_LIB_FREETYPE=true
fi
# Check if alsa and dbus is needed
# Check if alsa is needed
if test "x$OPENJDK_TARGET_OS" = xlinux; then
NEEDS_LIB_ALSA=true
NEEDS_LIB_DBUS=true
else
NEEDS_LIB_ALSA=false
NEEDS_LIB_DBUS=false
fi
# Check if ffi is needed
@@ -154,7 +152,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
LIB_SETUP_SPEECHD
LIB_SETUP_NVDACONTROLLERCLIENT
LIB_SETUP_WAYLAND
LIB_SETUP_DBUS
LIB_TESTS_SETUP_GTEST
BASIC_JDKLIB_LIBS=""

View File

@@ -467,10 +467,6 @@ UBSAN_LDFLAGS:=@UBSAN_LDFLAGS@
X_CFLAGS:=@X_CFLAGS@
X_LIBS:=@X_LIBS@
# Necessary additional compiler flags to compile dbus
DBUS_CFLAGS := @DBUS_CFLAGS@
DBUS_FOUND := @DBUS_FOUND@
# Linux speechd a11y announcer
A11Y_SPEECHD_ANNOUNCING_ENABLED:=@A11Y_SPEECHD_ANNOUNCING_ENABLED@
SPEECHD_CFLAGS:=@SPEECHD_CFLAGS@

View File

@@ -78,10 +78,6 @@ ifeq ($(call isTargetOs, windows), true)
#
endif
ifeq ($(DBUS_FOUND), false)
LIBAWT_EXFILES += dbus_interface.c dbus_interface.h
endif
ifeq ($(call isTargetOs, linux macosx aix), true)
LIBAWT_EXFILES += awt_Font.c CUPSfuncs.c fontpath.c X11Color.c
endif
@@ -115,10 +111,6 @@ LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES $(X_CFLAGS)
LIBAWT_CFLAGS += -DMLIB_NO_LIBSUNMATH
ifeq ($(DBUS_FOUND), true)
LIBAWT_CFLAGS += -DDBUS_FOUND
endif
ifeq ($(call isTargetOs, windows), true)
LIBAWT_CFLAGS += -EHsc -DUNICODE -D_UNICODE
ifeq ($(call isTargetCpuBits, 64), true)
@@ -170,7 +162,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
EXCLUDES := $(LIBAWT_EXCLUDES), \
EXCLUDE_FILES := $(LIBAWT_EXFILES), \
OPTIMIZATION := HIGHEST, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_CFLAGS) $(DBUS_CFLAGS), \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_CFLAGS), \
EXTRA_HEADER_DIRS := $(LIBAWT_EXTRA_HEADER_DIRS), \
DISABLED_WARNINGS_gcc_awt_LoadLibrary.c := unused-result, \
DISABLED_WARNINGS_gcc_debug_mem.c := format-nonliteral, \
@@ -321,7 +313,7 @@ ifeq ($(call isTargetOs, windows macosx), false)
EXTRA_HEADER_DIRS := $(LIBAWT_XAWT_EXTRA_HEADER_DIRS), \
EXCLUDES := $(LIBAWT_XAWT_EXCLUDES), \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_XAWT_CFLAGS) $(DBUS_CFLAGS) \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_XAWT_CFLAGS) \
$(X_CFLAGS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := int-to-pointer-cast, \
@@ -579,7 +571,7 @@ ifeq ($(call isTargetOs, windows macosx), false)
EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) \
$(LIBAWT_HEADLESS_CFLAGS) $(DBUS_CFLAGS), \
$(LIBAWT_HEADLESS_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB), \
EXTRA_HEADER_DIRS := $(LIBAWT_HEADLESS_EXTRA_HEADER_DIRS), \
DISABLED_WARNINGS_gcc_X11Renderer.c := unused-function, \

View File

@@ -1,101 +0,0 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, JetBrains s.r.o.. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. 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.
*/
#include "dbus_interface.h"
#include <dlfcn.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdbool.h>
#include "jvm_md.h"
#define DBUS_LIB JNI_LIB_NAME("dbus-1")
#define DBUS_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("dbus-1", "3")
static bool isCurrentVersionSupported(DBusApi* dBusApi) {
int major = 0, minor = 0, micro = 0;
dBusApi->dbus_get_version(&major, &minor, &micro);
return major == 1;
}
static bool DBusApi_init(DBusApi* dBusApi, void *libhandle) {
dBusApi->dbus_get_version = dlsym(libhandle, "dbus_get_version");
if (dBusApi->dbus_get_version == NULL || !isCurrentVersionSupported(dBusApi)) {
return false;
}
dBusApi->dbus_error_init = dlsym(libhandle, "dbus_error_init");
dBusApi->dbus_bus_get = dlsym(libhandle, "dbus_bus_get");
dBusApi->dbus_error_is_set = dlsym(libhandle, "dbus_error_is_set");
dBusApi->dbus_bus_request_name = dlsym(libhandle, "dbus_bus_request_name");
dBusApi->dbus_connection_flush = dlsym(libhandle, "dbus_connection_flush");
dBusApi->dbus_message_new_method_call = dlsym(libhandle, "dbus_message_new_method_call");
dBusApi->dbus_message_set_destination = dlsym(libhandle, "dbus_message_set_destination");
dBusApi->dbus_message_iter_init_append = dlsym(libhandle, "dbus_message_iter_init_append");
dBusApi->dbus_message_iter_append_basic = dlsym(libhandle, "dbus_message_iter_append_basic");
dBusApi->dbus_connection_send_with_reply_and_block = dlsym(libhandle, "dbus_connection_send_with_reply_and_block");
dBusApi->dbus_message_iter_init = dlsym(libhandle, "dbus_message_iter_init");
dBusApi->dbus_message_iter_get_arg_type = dlsym(libhandle, "dbus_message_iter_get_arg_type");
dBusApi->dbus_message_iter_get_basic = dlsym(libhandle, "dbus_message_iter_get_basic");
dBusApi->dbus_message_iter_recurse = dlsym(libhandle, "dbus_message_iter_recurse");
dBusApi->dbus_message_iter_next = dlsym(libhandle, "dbus_message_iter_next");
dBusApi->dbus_message_unref = dlsym(libhandle, "dbus_message_unref");
dBusApi->dbus_error_free = dlsym(libhandle, "dbus_error_free");
return dBusApi->dbus_error_init != NULL && dBusApi->dbus_bus_get != NULL && dBusApi->dbus_error_is_set != NULL &&
dBusApi->dbus_bus_request_name != NULL && dBusApi->dbus_connection_flush != NULL &&
dBusApi->dbus_message_set_destination != NULL && dBusApi->dbus_message_iter_init_append != NULL &&
dBusApi->dbus_message_iter_append_basic != NULL && dBusApi->dbus_connection_send_with_reply_and_block != NULL &&
dBusApi->dbus_message_iter_init != NULL && dBusApi->dbus_message_iter_get_arg_type != NULL &&
dBusApi->dbus_message_iter_get_basic != NULL && dBusApi->dbus_message_iter_recurse != NULL &&
dBusApi->dbus_message_iter_next != NULL && dBusApi->dbus_message_unref != NULL &&
dBusApi->dbus_message_new_method_call != NULL && dBusApi->dbus_error_free != NULL;
}
DBusApi* DBusApi_setupDBus(void *libhandle) {
DBusApi *dBusApi = (DBusApi*)malloc(sizeof(DBusApi));
if (dBusApi == NULL || !DBusApi_init(dBusApi, libhandle)) {
free(dBusApi);
dBusApi = NULL;
}
return dBusApi;
}
DBusApi* DBusApi_setupDBusDefault() {
void *dbus_libhandle = dlopen(DBUS_LIB, RTLD_LAZY | RTLD_LOCAL);
if (dbus_libhandle == NULL) {
dbus_libhandle = dlopen(DBUS_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
if (dbus_libhandle == NULL) {
return NULL;
}
}
return DBusApi_setupDBus(dbus_libhandle);
}

View File

@@ -1,76 +0,0 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, JetBrains s.r.o.. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. 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.
*/
#ifndef JETBRAINSRUNTIME_DBUS_INTERFACE_H
#define JETBRAINSRUNTIME_DBUS_INTERFACE_H
#include <dbus/dbus.h>
typedef struct DBusApi {
void (*dbus_get_version)(int *major_version_p, int *minor_version_p, int *micro_version_p);
void (*dbus_error_init)(DBusError *error);
DBusConnection *(*dbus_bus_get)(DBusBusType type, DBusError *error);
dbus_bool_t (*dbus_error_is_set)(const DBusError *error);
void (*dbus_error_free)(DBusError *error);
int (*dbus_bus_request_name)(DBusConnection *connection, const char *name, unsigned int flags, DBusError *error);
void (*dbus_connection_flush)(DBusConnection *connection);
DBusMessage* (*dbus_message_new_method_call)(const char *bus_name, const char *path,
const char *iface, const char *method);
dbus_bool_t (*dbus_message_set_destination)(DBusMessage *message, const char *destination);
void (*dbus_message_iter_init_append)(DBusMessage *message, DBusMessageIter *iter);
dbus_bool_t (*dbus_message_iter_append_basic)(DBusMessageIter *iter, int type, const void *value);
DBusMessage *(*dbus_connection_send_with_reply_and_block)(DBusConnection *connection, DBusMessage *message,
int timeout_milliseconds, DBusError *error);
dbus_bool_t (*dbus_message_iter_init)(DBusMessage *message, DBusMessageIter *iter);
int (*dbus_message_iter_get_arg_type)(DBusMessageIter *iter);
void (*dbus_message_iter_get_basic)(DBusMessageIter *iter, void *value);
void (*dbus_message_iter_recurse)(DBusMessageIter *iter, DBusMessageIter *sub);
dbus_bool_t (*dbus_message_iter_next)(DBusMessageIter *iter);
void (*dbus_message_unref)(DBusMessage *message);
} DBusApi;
DBusApi* DBusApi_setupDBus(void *libhandle);
DBusApi* DBusApi_setupDBusDefault();
#endif //JETBRAINSRUNTIME_DBUS_INTERFACE_H

View File

@@ -1,262 +0,0 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, JetBrains s.r.o.. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. 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.
*/
#include "system_properties.h"
#ifdef DBUS_FOUND
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define UNKNOWN_RESULT -1
#define SETTING_INTERFACE "org.freedesktop.portal.Settings"
#define SETTING_INTERFACE_METHOD "Read"
#define DESKTOP_DESTINATION "org.freedesktop.portal.Desktop"
#define DESKTOP_PATH "/org/freedesktop/portal/desktop"
#define REPLY_TIMEOUT 150
static DBusConnection *connection = NULL;
static JNIEnv *env = NULL;
static DBusApi *dBus = NULL;
static DBusMessage *msg_freedesktop_appearance = NULL;
static DBusMessage *msg_gnome_desktop = NULL;
static bool initialized = false;
static bool logEnabled = true;
extern JavaVM *jvm;
static void printError(const char* fmt, ...) {
if (!logEnabled) {
return;
}
env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
char* buf = (char*)malloc(1024);
if (env && buf) {
va_list vargs;
va_start(vargs, fmt);
vsnprintf(buf, 1024, fmt, vargs);
jstring text = JNU_NewStringPlatform(env, buf);
free(buf);
va_end(vargs);
jboolean ignoreException;
JNU_CallStaticMethodByName(env, &ignoreException, "sun/awt/UNIXToolkit", "printError",
"(Ljava/lang/String;)V", text);
}
}
static bool dbusCheckError(DBusError *err, const char *msg) {
bool is_error_set = dBus->dbus_error_is_set(err);
if (is_error_set) {
printError("DBus error: %s. %s\n", msg, err->message);
dBus->dbus_error_free(err);
}
return is_error_set;
}
// current implementation of object decomposition supports only
// primitive types (including a recursive type wrapper)
static bool decomposeDBusReply(void *val, DBusMessageIter *iter, int demand_type) {
int cur_type = dBus->dbus_message_iter_get_arg_type(iter);
switch (cur_type)
{
case DBUS_TYPE_INT16:
case DBUS_TYPE_UINT16:
case DBUS_TYPE_INT32:
case DBUS_TYPE_UINT32:
case DBUS_TYPE_INT64:
case DBUS_TYPE_UINT64:
case DBUS_TYPE_STRING:
{
if (cur_type != demand_type) {
return false;
}
dBus->dbus_message_iter_get_basic(iter, val);
return true;
}
case DBUS_TYPE_VARIANT:
{
DBusMessageIter unwrap_iter;
dBus->dbus_message_iter_recurse(iter, &unwrap_iter);
bool res = decomposeDBusReply(val, &unwrap_iter, demand_type);
// current implementation doesn't support types with multiple fields
if (dBus->dbus_message_iter_next(iter)) {
return false;
}
return res;
}
case DBUS_TYPE_INVALID:
default:
return false;
}
}
static DBusMessage *createDBusMessage(const char *messages[], int message_count) {
DBusMessage *msg = NULL;
DBusMessageIter msg_iter;
if ((msg = dBus->dbus_message_new_method_call(NULL, DESKTOP_PATH, SETTING_INTERFACE, SETTING_INTERFACE_METHOD)) == NULL) {
printError("DBus error: cannot allocate message\n");
goto cleanup;
}
if (!dBus->dbus_message_set_destination(msg, DESKTOP_DESTINATION)) {
printError("DBus error: cannot set destination\n");
goto cleanup;
}
dBus->dbus_message_iter_init_append(msg, &msg_iter);
for (int i = 0; i < message_count; i++) {
if (!dBus->dbus_message_iter_append_basic(&msg_iter, DBUS_TYPE_STRING, &messages[i])) {
printError("DBus error: cannot append to message\n");
goto cleanup;
}
}
return msg;
cleanup:
if (msg) {
dBus->dbus_message_unref(msg);
}
return NULL;
}
static bool sendDBusMessageWithReply(DBusMessage *msg, void *val, int demand_type) {
DBusError error;
DBusMessage *msg_reply = NULL;
DBusMessageIter msg_iter;
bool res = false;
dBus->dbus_error_init(&error);
if ((msg_reply = dBus->dbus_connection_send_with_reply_and_block(connection, msg, REPLY_TIMEOUT, &error)) == NULL) {
printError("DBus error: cannot get msg_reply or sent message. %s\n", dBus->dbus_error_is_set(&error) ? error.message : "");
goto cleanup;
}
if (!dBus->dbus_message_iter_init(msg_reply, &msg_iter)) {
printError("DBus error: cannot process message\n");
goto cleanup;
}
res = decomposeDBusReply(val, &msg_iter, demand_type);
cleanup:
if (msg_reply) {
dBus->dbus_message_unref(msg_reply);
}
return res;
}
JNIEXPORT jint JNICALL Java_sun_awt_UNIXToolkit_isSystemDarkColorScheme() {
static int use_freedesktop_appearance = -1;
if (!initialized) {
return UNKNOWN_RESULT;
}
if (use_freedesktop_appearance == -1) {
unsigned int res = 0;
logEnabled = false;
use_freedesktop_appearance =
sendDBusMessageWithReply(msg_freedesktop_appearance, &res, DBUS_TYPE_UINT32);
logEnabled = true;
}
if (use_freedesktop_appearance) {
unsigned int res = 0;
if (!sendDBusMessageWithReply(msg_freedesktop_appearance, &res, DBUS_TYPE_UINT32)) {
return UNKNOWN_RESULT;
}
return res;
} else {
char *res = NULL;
if (!sendDBusMessageWithReply(msg_gnome_desktop, &res, DBUS_TYPE_STRING)) {
return UNKNOWN_RESULT;
}
return (res != NULL) ? strstr(res, "dark") != NULL : UNKNOWN_RESULT;
}
}
jboolean SystemProperties_setup(DBusApi *dBus_, JNIEnv *env_) {
env = env_;
dBus = dBus_;
DBusError err;
int ret;
dBus->dbus_error_init(&err);
if ((connection = dBus->dbus_bus_get(DBUS_BUS_SESSION, &err)) == NULL) {
printError("DBus error: connection is Null\n");
return JNI_FALSE;
}
if (dbusCheckError(&err, "connection error")) {
return JNI_FALSE;
}
ret = dBus->dbus_bus_request_name(connection, "dbus.JBR.server", DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER && ret != DBUS_REQUEST_NAME_REPLY_IN_QUEUE) {
printError("DBus error: Failed to acquire service name \n");
return JNI_FALSE;
}
if (dbusCheckError(&err, "error request 'dbus.JBR.server' name on the bus")) {
return JNI_FALSE;
}
dBus->dbus_connection_flush(connection);
const char *freedesktop_appearance_messages[] = {"org.freedesktop.appearance", "color-scheme"};
const char *gnome_desktop_messages[] = {"org.gnome.desktop.interface", "gtk-theme"};
msg_freedesktop_appearance = createDBusMessage(freedesktop_appearance_messages, 2);
msg_gnome_desktop = createDBusMessage(gnome_desktop_messages, 2);
if (msg_freedesktop_appearance == NULL || msg_gnome_desktop == NULL) {
return JNI_FALSE;
}
initialized = true;
return JNI_TRUE;
}
JNIEXPORT jboolean JNICALL Java_sun_awt_UNIXToolkit_dbusInit() {
DBusApi *dBus = DBusApi_setupDBusDefault();
if (dBus) {
return SystemProperties_setup(dBus, env);
}
return JNI_FALSE;
}
#else
JNIEXPORT jint JNICALL Java_sun_awt_UNIXToolkit_isSystemDarkColorScheme() {
return -1;
}
JNIEXPORT jboolean JNICALL Java_sun_awt_UNIXToolkit_dbusInit() {
return JNI_FALSE;
}
#endif

View File

@@ -1,44 +0,0 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, JetBrains s.r.o.. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. 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.
*/
#ifndef JETBRAINSRUNTIME_SYSTEM_PROPERTIES_H
#define JETBRAINSRUNTIME_SYSTEM_PROPERTIES_H
#include <stdbool.h>
#include <jni.h>
#include <jni_util.h>
#ifdef DBUS_FOUND
#include "dbus_interface.h"
jboolean SystemProperties_setup(DBusApi *dBus_, JNIEnv *env_);
void SystemProperties_pullEvent(void);
#endif
#endif //JETBRAINSRUNTIME_SYSTEM_PROPERTIES_H

View File

@@ -215,6 +215,37 @@
}
return JNI_FALSE;
}
/**
* Invalidates all cells in the cache. Note that this method does not
* attempt to compact the cache in any way; it just invalidates any cells
* that already exist.
*/
- (void) invalidate
{
MTLCacheCellInfo *cellinfo;
J2dTraceLn(J2D_TRACE_INFO, "MTLGlyphCache.invalidate");
if (_cacheInfo == NULL) {
return;
}
// flush any pending vertices that may be depending on the current
// glyph cache layout
if (_cacheInfo->Flush != NULL) {
_cacheInfo->Flush(_cacheInfo->mtlc);
}
cellinfo = _cacheInfo->head;
while (cellinfo != NULL) {
if (cellinfo->glyphInfo != NULL) {
// if the cell is occupied, notify the base glyph that its
// cached version for this cache is about to be invalidated
MTLGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo);
}
cellinfo = cellinfo->next;
}
}
/**
* Invalidates and frees all cells and the cache itself. The "cache" pointer

View File

@@ -372,17 +372,17 @@ MTLTR_DrawLCDGlyphViaCache(MTLContext *mtlc, BMTLSDOps *dstOps,
DisableColorGlyphPainting(mtlc);
}
if (!MTLTR_ValidateGlyphCache(mtlc, dstOps, JNI_TRUE)) {
return JNI_FALSE;
}
if (rgbOrder != lastRGBOrder) {
// need to invalidate the cache in this case; see comments
// for lastRGBOrder above
[mtlc.glyphCacheLCD free];
[mtlc.glyphCacheLCD invalidate];
lastRGBOrder = rgbOrder;
}
if (!MTLTR_ValidateGlyphCache(mtlc, dstOps, JNI_TRUE)) {
return JNI_FALSE;
}
glyphMode = MODE_USE_CACHE_LCD;
}
@@ -660,17 +660,19 @@ MTLTR_DrawGlyphList(JNIEnv *env, MTLContext *mtlc, BMTLSDOps *dstOps,
int ry = ginfo->subpixelResolutionY;
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphx, rx);
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphy, ry);
float fx = floor(glyphx);
float fy = floor(glyphy);
x = (int) fx;
y = (int) fy;
int subimage;
if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
subimage = 0;
int subx = 0, suby = 0;
// see DrawGlyphList.c FLOOR_ASSIGN & getSubpixelGlyphImage
if (glyphx >= 0.0f && glyphy >= 0.0f) {
x = (int) glyphx;
y = (int) glyphy;
subx = ((int) (glyphx * (float) rx)) % rx;
suby = ((int) (glyphy * (float) ry)) % ry;
} else {
int subx = (int) ((glyphx - fx) * (float) rx);
int suby = (int) ((glyphy - fy) * (float) ry);
subimage = subx + suby * rx;
float fx = floor(glyphx), fy = floor(glyphy);
x = (int) fx;
y = (int) fy;
subx = (int) ((glyphx - fx) * (float) rx);
suby = (int) ((glyphy - fy) * (float) ry);
}
if (ginfo->image == NULL) {
@@ -682,6 +684,12 @@ MTLTR_DrawGlyphList(JNIEnv *env, MTLContext *mtlc, BMTLSDOps *dstOps,
J2dTraceLn1(J2D_TRACE_INFO, "rowBytes = %d", ginfo->rowBytes);
if (ginfo->format == sun_font_StrikeCache_PIXEL_FORMAT_GREYSCALE) {
// grayscale or monochrome glyph data
int subimage;
if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
subimage = 0;
} else {
subimage = subx + suby * rx;
}
if (ginfo->width <= MTLTR_CACHE_CELL_WIDTH &&
ginfo->height <= MTLTR_CACHE_CELL_HEIGHT)
{

View File

@@ -4996,15 +4996,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (treeModel != null) {
index = treeModel.getIndexOfChild(objParent, obj);
}
// If the root is not visible and the parent is the root,
// don't create an accessible node for it.
if (!isRootVisible() && parentPath.getParentPath() == null) {
accessibleParent = tree;
} else {
accessibleParent = new AccessibleJTreeNode(tree,
parentPath,
null);
}
accessibleParent = new AccessibleJTreeNode(tree,
parentPath,
null);
this.setAccessibleParent(accessibleParent);
} else if (treeModel != null) {
accessibleParent = tree; // we're the top!

View File

@@ -1297,17 +1297,19 @@ OGLTR_DrawGlyphList(JNIEnv *env, OGLContext *oglc, OGLSDOps *dstOps,
int ry = ginfo->subpixelResolutionY;
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphx, rx);
ADJUST_SUBPIXEL_GLYPH_POSITION(glyphy, ry);
float fx = floor(glyphx);
float fy = floor(glyphy);
x = (int) fx;
y = (int) fy;
int subimage;
if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
subimage = 0;
int subx = 0, suby = 0;
// see DrawGlyphList.c FLOOR_ASSIGN & getSubpixelGlyphImage
if (glyphx >= 0.0f && glyphy >= 0.0f) {
x = (int) glyphx;
y = (int) glyphy;
subx = ((int) (glyphx * (float) rx)) % rx;
suby = ((int) (glyphy * (float) ry)) % ry;
} else {
int subx = (int) ((glyphx - fx) * (float) rx);
int suby = (int) ((glyphy - fy) * (float) ry);
subimage = subx + suby * rx;
float fx = floor(glyphx), fy = floor(glyphy);
x = (int) fx;
y = (int) fy;
subx = (int) ((glyphx - fx) * (float) rx);
suby = (int) ((glyphy - fy) * (float) ry);
}
if (ginfo->image == NULL) {
@@ -1319,6 +1321,12 @@ OGLTR_DrawGlyphList(JNIEnv *env, OGLContext *oglc, OGLSDOps *dstOps,
OGLContext_InitGrayRenderHints(env, oglc);
}
// grayscale or monochrome glyph data
int subimage;
if ((rx == 1 && ry == 1) || rx <= 0 || ry <= 0) {
subimage = 0;
} else {
subimage = subx + suby * rx;
}
if (ginfo->width <= OGLTR_CACHE_CELL_WIDTH &&
ginfo->height <= OGLTR_CACHE_CELL_HEIGHT)
{

View File

@@ -55,13 +55,11 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import jdk.internal.misc.InnocuousThread;
import sun.awt.X11.XBaseWindow;
import sun.security.action.GetIntegerAction;
import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection;
import sun.java2d.opengl.OGLRenderQueue;
import sun.security.action.GetPropertyAction;
import sun.util.logging.PlatformLogger;
public abstract class UNIXToolkit extends SunToolkit
{
@@ -114,16 +112,6 @@ public abstract class UNIXToolkit extends SunToolkit
private Boolean nativeGTKAvailable;
private Boolean nativeGTKLoaded;
private BufferedImage tmpImage = null;
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.UNIXToolkit");
private static void printError(String str) {
log.fine(str);
}
@Override
protected void initializeDesktopProperties() {
initSystemPropertyWatcher();
}
public static int getDatatransferTimeout() {
@SuppressWarnings("removal")
@@ -560,8 +548,6 @@ public abstract class UNIXToolkit extends SunToolkit
return result;
}
private static native int isSystemDarkColorScheme();
@Override
public boolean isRunningOnXWayland() {
return isOnXWayland();
@@ -580,43 +566,6 @@ public abstract class UNIXToolkit extends SunToolkit
// application icons).
private static final WindowFocusListener waylandWindowFocusListener;
private static final String OS_THEME_IS_DARK = "awt.os.theme.isDark";
private static Thread systemPropertyWatcher = null;
private static native boolean dbusInit();
private void initSystemPropertyWatcher() {
@SuppressWarnings("removal")
String dbusEnabled = AccessController.doPrivileged(
new GetPropertyAction("jbr.dbus.enabled", "true")).toLowerCase();
if (!"true".equals(dbusEnabled) || !dbusInit()) {
return;
}
int initialSystemDarkColorScheme = isSystemDarkColorScheme();
if (initialSystemDarkColorScheme >= 0) {
setDesktopProperty(OS_THEME_IS_DARK, initialSystemDarkColorScheme != 0);
systemPropertyWatcher = InnocuousThread.newThread("SystemPropertyWatcher",
() -> {
while (true) {
try {
int isSystemDarkColorScheme = isSystemDarkColorScheme();
if (isSystemDarkColorScheme >= 0) {
setDesktopProperty(OS_THEME_IS_DARK, isSystemDarkColorScheme != 0);
}
Thread.sleep(1000);
} catch (Exception ignored) {
}
}
});
systemPropertyWatcher.setDaemon(true);
systemPropertyWatcher.start();
}
}
static {
if (isOnXWayland()) {
waylandWindowFocusListener = new WindowAdapter() {

View File

@@ -33,15 +33,12 @@ import java.awt.im.spi.InputMethodContext;
import java.awt.peer.ComponentPeer;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Objects;
import java.util.Queue;
import java.util.function.Supplier;
import java.util.stream.Stream;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
import sun.awt.X11GraphicsDevice;
import sun.awt.X11GraphicsEnvironment;
import sun.awt.X11InputMethod;
@@ -306,155 +303,6 @@ public class XInputMethod extends X11InputMethod {
}
// JBR-6456: Sudden keyboard death on Linux using iBus.
// xicDestroyMustBeDelayed, XIC_DELAYED_TO_BE_DESTROYED_CAPACITY, xicDelayedToBeDestroyed can only be accessed
// under the AWT lock
// See the #disposeXIC method for the purpose of these fields
private static boolean xicDestroyMustBeDelayed = false;
private static final int XIC_DELAYED_TO_BE_DESTROYED_CAPACITY = 16;
private static final Queue<Long> xicDelayedToBeDestroyed = new ArrayDeque<>(XIC_DELAYED_TO_BE_DESTROYED_CAPACITY);
static void delayAllXICDestroyUntilAFurtherNotice() {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("delayAllXICDestroyUntilAFurtherNotice(): is being called", new Throwable("Stacktrace"));
}
XToolkit.awtLock();
try {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("delayAllXICDestroyUntilAFurtherNotice(): xicDestroyMustBeDelayed=={0}", xicDestroyMustBeDelayed);
}
xicDestroyMustBeDelayed = true;
} finally {
XToolkit.awtUnlock();
}
}
static void delayedXICDestroyShouldBeDone() {
XToolkit.awtLock();
try {
xicDestroyMustBeDelayed = false;
doDelayedXICDestroy(false, -1);
} finally {
XToolkit.awtUnlock();
}
}
private static void doDelayedXICDestroy(boolean forced, int maxCountToDestroy) {
final boolean isFineLoggable = log.isLoggable(PlatformLogger.Level.FINE);
if (isFineLoggable) {
log.fine(
"doDelayedXICDestroy(forced==" + forced + ", maxCountToDestroy==" + maxCountToDestroy + "): is being called",
new Throwable("Stacktrace")
);
}
assert(SunToolkit.isAWTLockHeldByCurrentThread());
assert(forced || !xicDestroyMustBeDelayed);
while ( (maxCountToDestroy != 0) && !xicDelayedToBeDestroyed.isEmpty() ) {
final long pX11IMData = xicDelayedToBeDestroyed.remove();
--maxCountToDestroy;
if (isFineLoggable) {
log.fine("doDelayedXICDestroy(): destroying pX11IMData={0}", pX11IMData);
}
assert(pX11IMData != 0);
delayedDisposeXIC_disposeXICNative(pX11IMData);
}
}
@Override
protected void disposeXIC() {
awtLock();
try {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("disposeXIC(): xicDestroyMustBeDelayed=={0}", xicDestroyMustBeDelayed);
}
if (!xicDestroyMustBeDelayed) {
// JBR-6456: Sudden keyboard death on Linux using iBus.
// iBus's X11 frontend being run in the async mode (IBUS_ENABLE_SYNC_MODE=0) has a bug leading to a
// violation of the communication protocol between iBus and Xlib (so-called "XIM protocol"),
// later causing Xlib to behave unexpectedly from iBus's point of view, breaking iBus's
// internal state. After all, iBus starts to "steal" all the keyboard events
// (so that each call of XFilterEvent(...) with an instance of XKeyEvent returns True).
// The initial iBus's bug only appears when XDestroyIC(...) gets called right after a call of
// XFilterEvent(...) with an instance of XKeyEvent returned True,
// meaning that iBus has started, but hasn't finished yet processing of the key event.
// In case of AWT/Swing apps, XDestroyIC gets called whenever a focused HW window gets closed
// (because it leads to disposing of the associated input context,
// see java.awt.Window#doDispose and sun.awt.im.InputContext#dispose)
// So, to work around iBus's bug, we have to avoid calling XDestroyIC until iBus finishes processing of
// all the keyboard events it has already started processing of, i.e. until a call of
// XFilterEvent(...) returns False.
// To achieve that, the implemented fix delays destroying of input contexts whenever a call of
// XFilterEvent(...) with an instance of XKeyEvent returns True until one of the next calls of
// XFilterEvent(...) with the same instance of XKeyEvent returns False.
// The delaying is implemented via storing the native pointers to the input contexts to
// xicDelayedToBeDestroyed instead of applying XDestroyIC(...) immediately.
// The xicDelayedToBeDestroyed's size is explicitly limited to
// XIC_DELAYED_TO_BE_DESTROYED_CAPACITY. If the limit gets reached, a few input contexts gets
// pulled from there and destroyed regardless of the current value of xicDestroyMustBeDelayed.
// The xicDestroyMustBeDelayed field is responsible for indication whether it's required to delay
// the destroying or not. It gets set in #delayAllXICDestroyUntilAFurtherNotice
// and unset in delayedXICDestroyShouldBeDone; both are called by sun.awt.X11.XToolkit depending on
// the value returned by the calls of sun.awt.X11.XlibWrapper#XFilterEvent.
super.disposeXIC();
return;
}
final long pX11IMData = pData;
// To make sure that the delayed to be destroyed input context won't get used by AWT/Swing or Xlib
// by a mistake, the following things are done:
// 1. The input method focus gets detached from the input context (via a call of XUnsetICFocus)
// 2. All the native pointers to this instance of XInputMethod
// (now it's just the variable currentX11InputMethodInstance in awt_InputMethod.c) get unset
// 3. All the java pointers to the native context (now it's just sun.awt.X11InputMethodBase#pData)
// get unset as well
delayedDisposeXIC_preparation_unsetFocusAndDetachCurrentXICNative();
// 4. The state of the native context gets reset (effectively via a call of XmbResetIC)
delayedDisposeXIC_preparation_resetSpecifiedCtxNative(pX11IMData);
if (pX11IMData == 0) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("disposeXIC(): pX11IMData==NULL, skipped");
}
return;
}
// If the storage is full, a few input context are pulled from there and destroyed regardless of
// the value of xicDestroyMustBeDelayed
if (xicDelayedToBeDestroyed.size() >= XIC_DELAYED_TO_BE_DESTROYED_CAPACITY) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine(
"disposeXIC(): xicDelayedToBeDestroyed.size()=={0} >= XIC_DELAYED_TO_BE_DESTROYED_CAPACITY",
xicDelayedToBeDestroyed.size()
);
}
doDelayedXICDestroy(true, xicDelayedToBeDestroyed.size() - XIC_DELAYED_TO_BE_DESTROYED_CAPACITY + 1);
}
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine(
"disposeXIC(): adding pX11IMData=={0} to xicDelayedToBeDestroyed (which already contains {1} elements)",
pX11IMData, xicDelayedToBeDestroyed.size()
);
}
xicDelayedToBeDestroyed.add(pX11IMData);
} finally {
awtUnlock();
}
}
static void onXKeyEventFiltering(final boolean isXKeyEventFiltered) {
// Fix of JBR-1573, JBR-2444, JBR-4394 (a.k.a. IDEA-246833).
// Input method is considered broken if and only if all the following statements are true:
@@ -768,15 +616,6 @@ public class XInputMethod extends X11InputMethod {
private native void setXICFocusNative(long window, boolean value, boolean active);
private native void adjustStatusWindow(long window);
// 1. Applies XUnsetICFocus to the current input context
// 2. Unsets currentX11InputMethodInstance if it's set to this instance of XInputMethod
// 3. Unsets sun.awt.X11InputMethodBase#pData
private native void delayedDisposeXIC_preparation_unsetFocusAndDetachCurrentXICNative();
// Applies XmbResetIC to the passed input context
private static native void delayedDisposeXIC_preparation_resetSpecifiedCtxNative(long pX11IMData);
// Applies XDestroyIC to the passed input context
private static native void delayedDisposeXIC_disposeXICNative(long pX11IMData);
private native boolean doesFocusedXICSupportMovingCandidatesNativeWindow();
private native void adjustCandidatesNativeWindowPosition(int x, int y);

View File

@@ -1020,22 +1020,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
final boolean isKeyEvent = ( (ev.get_type() == XConstants.KeyPress) ||
(ev.get_type() == XConstants.KeyRelease) );
final long keyEventSerial = isKeyEvent ? ev.get_xkey().get_serial() : -1;
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE) && isKeyEvent) {
keyEventLog.fine("before XFilterEvent:" + ev);
}
if (XlibWrapper.XFilterEvent(ev.getPData(), w)) {
if (isKeyEvent) {
if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
keyEventLog.fine(
"Setting lastFilteredKeyEventSerial=={0} to {1}",
lastFilteredKeyEventSerial, keyEventSerial
);
}
lastFilteredKeyEventSerial = keyEventSerial;
XInputMethod.delayAllXICDestroyUntilAFurtherNotice();
XInputMethod.onXKeyEventFiltering(true);
}
continue;
@@ -1047,14 +1036,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
if (isKeyEvent) {
XInputMethod.onXKeyEventFiltering(false);
if (keyEventSerial == lastFilteredKeyEventSerial) {
// JBR-6456: Sudden keyboard death on Linux using iBus.
// If more than 1 key events are being processed by iBus
// (i.e. more than one in a row calls of XFilterEvent(...) with instances of XKeyEvent have
// returned true),
// we have to postpone destroying until the very last one is completely processed)
XInputMethod.delayedXICDestroyShouldBeDone();
}
}
dispatchEvent(ev);
@@ -1126,14 +1107,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
// JBR-6456: Sudden keyboard death on Linux using iBus.
// The field holds the value of sun.awt.X11.XKeyEvent#get_serial of the last key event, which
// XFilterEvent(...) returned True for.
// See the usages of the variable for more info.
// See sun.awt.X11.XInputMethod#disposeXIC for the detailed explanation of the whole fix.
private long lastFilteredKeyEventSerial = -1;
/**
* Listener installed to detect display changes.
*/
@@ -1242,9 +1215,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
X11GraphicsDevice x11gd = (X11GraphicsDevice) gd;
int screenNum = x11gd.getScreen();
Rectangle screen = gc.getBounds();
boolean isFirstScreen = screen.x == 0 && screen.y == 0;
if (localEnv.runningXinerama() && !isFirstScreen) {
if (localEnv.runningXinerama() && screenNum != 0) {
// We cannot estimate insets for non-default screen,
// there are often none.
return new Insets(0, 0, 0, 0);
@@ -1253,6 +1224,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
XToolkit.awtLock();
try {
Rectangle workArea = getWorkArea(XlibUtil.getRootWindow(screenNum));
Rectangle screen = gc.getBounds();
if (workArea != null) {
Point p = x11gd.scaleDown(workArea.x, workArea.y);
workArea.x = p.x;
@@ -1261,8 +1233,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
workArea.height = x11gd.scaleDown(workArea.height);
workArea = workArea.intersection(screen);
if (!workArea.isEmpty()) {
int top = workArea.y;
int left = workArea.x;
int top = workArea.y - screen.y;
int left = workArea.x - screen.x;
int bottom = screen.height - workArea.height - top;
int right = screen.width - workArea.width - left;
return new Insets(top, left, bottom, right);
@@ -1951,7 +1923,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
localEnv.displayChanged());
}
}
super.initializeDesktopProperties();
}
/**

View File

@@ -55,17 +55,8 @@ record WLInputState(WLPointerEvent eventWithSurface,
* @param clickCount number of consecutive clicks of the same button performed
* within WLToolkit.getMulticlickTime() milliseconds from one another
* @param linuxCode button code corresponding to WLPointerEvent.PointerButtonCodes.linuxCode
* @param surfaceX the X coordinate of the button press relative to the surface
* @param surfaceY the Y coordinate of the button press relative to the surface
*/
record PointerButtonEvent(
long surface,
long serial,
long timestamp,
int clickCount,
int linuxCode,
int surfaceX,
int surfaceY) {}
record PointerButtonEvent(long surface, long serial, long timestamp, int clickCount, int linuxCode) {}
static WLInputState initialState() {
return new WLInputState(null, null, null, null,
@@ -87,8 +78,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
final PointerButtonEvent newPointerButtonEvent = getNewPointerButtonEvent(pointerEvent,
newEventWithSurface,
newEventWithSerial,
newEventWithTimestamp,
newEventWithCoordinates);
newEventWithTimestamp);
final int newModifiers = getNewModifiers(pointerEvent);
boolean newPointerOverSurface = (pointerEvent.hasEnterEvent() || isPointerOverSurface)
@@ -155,7 +145,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
eventWithTimestamp,
eventWithCoordinates,
pointerButtonPressedEvent,
modifiers & ~WLPointerEvent.PointerButtonCodes.combinedMask(),
0,
surfaceForKeyboardInput,
false);
}
@@ -163,10 +153,9 @@ record WLInputState(WLPointerEvent eventWithSurface,
private PointerButtonEvent getNewPointerButtonEvent(WLPointerEvent pointerEvent,
WLPointerEvent newEventWithSurface,
WLPointerEvent newEventWithSerial,
WLPointerEvent newEventWithTimestamp,
WLPointerEvent newEventWithPosition) {
WLPointerEvent newEventWithTimestamp) {
if (pointerEvent.hasButtonEvent() && pointerEvent.getIsButtonPressed() && newEventWithSurface != null) {
assert newEventWithSerial != null && newEventWithTimestamp != null && newEventWithPosition != null;
assert newEventWithSerial != null && newEventWithTimestamp != null;
int clickCount = 1;
final boolean pressedSameButton = pointerButtonPressedEvent != null
&& pointerEvent.getButtonCode() == pointerButtonPressedEvent.linuxCode;
@@ -176,10 +165,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
final boolean clickedQuickly
= (pointerEvent.getTimestamp() - pointerButtonPressedEvent.timestamp)
<= WLToolkit.getMulticlickTime();
final boolean mouseDidNotMove =
newEventWithPosition.getSurfaceX() == pointerButtonPressedEvent.surfaceX &&
newEventWithPosition.getSurfaceY() == pointerButtonPressedEvent.surfaceY;
if (clickedSameSurface && clickedQuickly && mouseDidNotMove) {
if (clickedSameSurface && clickedQuickly) {
clickCount = pointerButtonPressedEvent.clickCount + 1;
}
}
@@ -189,9 +175,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
newEventWithSerial.getSerial(),
newEventWithTimestamp.getTimestamp(),
clickCount,
pointerEvent.getButtonCode(),
newEventWithPosition.getSurfaceX(),
newEventWithPosition.getSurfaceY());
pointerEvent.getButtonCode());
}
return pointerButtonPressedEvent;
@@ -201,7 +185,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
int newModifiers = modifiers;
if (pointerEvent.hasLeaveEvent()) {
return modifiers & ~WLPointerEvent.PointerButtonCodes.combinedMask();
return 0;
}
if (pointerEvent.hasButtonEvent()) {
@@ -209,9 +193,9 @@ record WLInputState(WLPointerEvent eventWithSurface,
= WLPointerEvent.PointerButtonCodes.recognizedOrNull(pointerEvent.getButtonCode());
if (buttonCode != null) {
if (pointerEvent.getIsButtonPressed()) {
newModifiers |= buttonCode.mask();
newModifiers |= buttonCode.javaMask;
} else {
newModifiers &= ~buttonCode.mask();
newModifiers &= ~buttonCode.javaMask;
}
}
}

View File

@@ -70,47 +70,18 @@ class WLPointerEvent {
public enum PointerButtonCodes {
// see <linux/input-event-codes.h>
LEFT(0x110, MouseEvent.BUTTON1),
MIDDLE(0x112, MouseEvent.BUTTON2),
RIGHT(0x111, MouseEvent.BUTTON3),
// Extra mouse buttons
// Most mice use BTN_SIDE for backward, BTN_EXTRA for forward.
// There are also BTN_FORWARD and BTN_BACK, but they are different buttons, it seems.
// On Logitech MX Master 3S, BTN_FORWARD is the thumb button.
// The default X11 configuration has them as mouse button 8 and 9 respectfully,
// XToolkit converts them to Java codes by subtracting 2.
// Then, IDEA converts them to its internal codes by also subtracting 2
// This is because on X11 the mouse button numbering is as follows:
// - 1: Left
// - 2: Middle
// - 3: Right
// - 4: Vertical scroll up
// - 5: Vertical scroll down
// - 6: Horizontal scroll left
// - 7: Horizontal scroll right
// - 8: Backwards
// - 9: Forwards
// Since the buttons 4-7 are not actually buttons, they are ignored
// They will be skipped in WLToolkit
FORWARD(0x115, 6),
BACK(0x116, 7),
SIDE(0x113, 4),
EXTRA(0x114, 5),
;
LEFT(0x110, MouseEvent.BUTTON1, InputEvent.BUTTON1_DOWN_MASK),
MIDDLE(0x112, MouseEvent.BUTTON2, InputEvent.BUTTON2_DOWN_MASK),
RIGHT(0x111, MouseEvent.BUTTON3, InputEvent.BUTTON3_DOWN_MASK);
public final int linuxCode; // The code from <linux/input-event-codes.h>
public final int javaCode; // The code from MouseEvents.BUTTONx
public final int javaMask; // The mask from InputEvent.BUTTONx_DOWN_MASK
PointerButtonCodes(int linuxCode, int javaCode) {
PointerButtonCodes(int linuxCode, int javaCode, int javaMask) {
this.linuxCode = linuxCode;
this.javaCode = javaCode;
}
public int mask() {
return InputEvent.getMaskForButton(javaCode);
this.javaMask = javaMask;
}
static PointerButtonCodes recognizedOrNull(int linuxCode) {
@@ -124,7 +95,7 @@ class WLPointerEvent {
static boolean anyMatchMask(int mask) {
for (var c : values()) {
if ((mask & c.mask()) != 0) {
if ((mask & c.javaMask) != 0) {
return true;
}
}
@@ -135,7 +106,7 @@ class WLPointerEvent {
static int combinedMask() {
int mask = 0;
for (var c : values()) {
mask |= c.mask();
mask |= c.javaMask;
}
return mask;
}
@@ -145,10 +116,6 @@ class WLPointerEvent {
case LEFT -> "left";
case MIDDLE -> "middle";
case RIGHT -> "right";
case FORWARD -> "forward";
case BACK -> "back";
case SIDE -> "side";
case EXTRA -> "extra";
};
}

View File

@@ -128,8 +128,8 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
* related to Wayland are reported via an exception.
*/
private static final int READ_RESULT_ERROR = 2;
private static final int MOUSE_BUTTONS_COUNT = 7;
private static final int MOUSE_BUTTONS_COUNT = 3;
private static final int AWT_MULTICLICK_DEFAULT_TIME_MS = 500;
private static boolean initialized = false;

View File

@@ -73,8 +73,6 @@ AssertDrawLockIsHeld(WLSurfaceBufferManager* manager, const char * file, int lin
#define MUTEX_LOCK(m) if (pthread_mutex_lock(&(m))) { WL_FATAL_ERROR("Failed to lock mutex"); }
#define MUTEX_UNLOCK(m) if (pthread_mutex_unlock(&(m))) { WL_FATAL_ERROR("Failed to unlock mutex"); }
#define CLAMP(val, min, max) ((val) < (min) ? (min) : ((val) > (max) ? (max) : (val)))
/**
* The maximum number of buffers that can be simultaneously in use by Wayland.
* When a new frame is ready to be sent to Wayland and the number of buffers
@@ -495,8 +493,6 @@ SurfaceBufferResize(WLSurfaceBufferManager * manager, WLSurfaceBuffer* buffer)
wl_buffer_destroy(buffer->wlBuffer);
buffer->wlBuffer = NULL;
DamageList_FreeAll(buffer->damageList);
buffer->damageList = NULL;
buffer->width = newWidth;
buffer->height = newHeight;
@@ -800,24 +796,21 @@ CopyDamagedArea(WLSurfaceBufferManager * manager, jint x, jint y, jint width, ji
assert(manager->bufferForDraw.data != NULL);
assert(manager->bufferForDraw.width == manager->bufferForShow.wlSurfaceBuffer->width);
assert(manager->bufferForDraw.height == manager->bufferForShow.wlSurfaceBuffer->height);
assert(manager->bufferForShow.wlSurfaceBuffer->bytesAllocated >= DrawBufferSizeInBytes(manager));
jint bufferWidth = manager->bufferForDraw.width;
jint bufferHeight = manager->bufferForDraw.height;
// Clamp the damaged area to the size of the destination in order not to crash in case of
// an error on the client side that "damaged" an area larger than our buffer.
x = CLAMP(x, 0, bufferWidth - 1);
y = CLAMP(y, 0, bufferHeight - 1);
width = CLAMP(width, 0, bufferWidth - x);
height = CLAMP(height, 0, bufferHeight - y);
assert(x >= 0);
assert(y >= 0);
assert(width >= 0);
assert(height >= 0);
assert(height + y >= 0);
assert(width + x >= 0);
assert(width <= manager->bufferForDraw.width);
assert(height <= manager->bufferForDraw.height);
pixel_t * dest = manager->bufferForShow.wlSurfaceBuffer->data;
pixel_t * src = manager->bufferForDraw.data;
for (jint i = y; i < height + y; i++) {
pixel_t * dest_row = &dest[i * bufferWidth];
pixel_t * src_row = &src [i * bufferWidth];
pixel_t * dest_row = &dest[i * manager->bufferForDraw.width];
pixel_t * src_row = &src [i * manager->bufferForDraw.width];
for (jint j = x; j < width + x; j++) {
dest_row[j] = src_row[j];
}

View File

@@ -1191,15 +1191,6 @@ postKeyTypedEvents(const char *string) {
}
}
static uint16_t
getJavaKeyCharForKeycode(xkb_keycode_t xkbKeycode) {
uint32_t codepoint = xkb.state_key_get_utf32(keyboard.state, xkbKeycode);
if (codepoint == 0 || codepoint >= 0xffff) {
return java_awt_event_KeyEvent_CHAR_UNDEFINED;
}
return (uint16_t)codepoint;
}
// Posts an XKB keysym as KEY_TYPED events, without consulting the current compose state.
static void
handleKeyTypeNoCompose(xkb_keycode_t xkbKeycode) {
@@ -1294,7 +1285,7 @@ handleKey(long timestamp, uint32_t keycode, bool isPressed, bool isRepeat) {
.keyLocation = javaKeyLocation,
.rawCode = keycode,
.extendedKeyCode = javaExtendedKeyCode,
.keyChar = getJavaKeyCharForKeycode(xkbKeycode),
.keyChar = java_awt_event_KeyEvent_CHAR_UNDEFINED,
};
wlPostKeyEvent(&event);

View File

@@ -1638,81 +1638,6 @@ Java_sun_awt_X11_XInputMethod_releaseXICNative(JNIEnv *env,
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XInputMethod_delayedDisposeXIC_1preparation_1unsetFocusAndDetachCurrentXICNative
(JNIEnv *env, jobject this)
{
DASSERT(env != NULL);
X11InputMethodData *pX11IMData = NULL;
AWT_LOCK();
pX11IMData = getX11InputMethodData(env, this);
if (pX11IMData == NULL) {
AWT_UNLOCK();
return;
}
if (pX11IMData->ic_active.xic != (XIC)0) {
setXICFocus(pX11IMData->ic_active.xic, False);
}
if ( (pX11IMData->ic_passive.xic != (XIC)0) && (pX11IMData->ic_passive.xic != pX11IMData->ic_active.xic) ) {
setXICFocus(pX11IMData->ic_passive.xic, False);
}
pX11IMData->current_ic = (XIC)0;
setX11InputMethodData(env, this, NULL);
if ( (*env)->IsSameObject(env, pX11IMData->x11inputmethod, currentX11InputMethodInstance) == JNI_TRUE ) {
// currentX11InputMethodInstance never holds a "unique" java ref - it only holds a "weak" copy of
// _X11InputMethodData::x11inputmethod, so we mustn't DeleteGlobalRef here
currentX11InputMethodInstance = NULL;
currentFocusWindow = 0;
}
AWT_UNLOCK();
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XInputMethod_delayedDisposeXIC_1preparation_1resetSpecifiedCtxNative
(JNIEnv *env, jclass clazz, const jlong pData)
{
X11InputMethodData * const pX11IMData = (X11InputMethodData *)pData;
char* preeditText = NULL;
if (pX11IMData == NULL) {
return;
}
AWT_LOCK();
if (pX11IMData->ic_active.xic != (XIC)0) {
if ( (preeditText = XmbResetIC(pX11IMData->ic_active.xic)) != NULL ) {
(void)XFree(preeditText); preeditText = NULL;
}
}
if ( (pX11IMData->ic_passive.xic != (XIC)0) && (pX11IMData->ic_passive.xic != pX11IMData->ic_active.xic) ) {
if ( (preeditText = XmbResetIC(pX11IMData->ic_passive.xic)) != NULL ) {
(void)XFree(preeditText); preeditText = NULL;
}
}
AWT_UNLOCK();
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XInputMethod_delayedDisposeXIC_1disposeXICNative(JNIEnv *env, jclass clazz, jlong pData)
{
X11InputMethodData *pX11IMData = (X11InputMethodData *)pData;
if (pX11IMData == NULL) {
return;
}
AWT_LOCK();
destroyX11InputMethodData(env, pX11IMData); pX11IMData = NULL; pData = 0;
AWT_UNLOCK();
}
JNIEXPORT void JNICALL
Java_sun_awt_X11_XInputMethod_setXICFocusNative(JNIEnv *env,
jobject this,

View File

@@ -6476,15 +6476,9 @@ public final class AccessBridge {
java.lang.System.arraycopy(objPath, 0, objParentPath,
0, objPath.length-1);
TreePath parentPath = new TreePath(objParentPath);
// If the root is not visible and the parent is the root,
// don't create an accessible node for it.
if (!tree.isRootVisible() && parentPath.getParentPath() == null) {
accessibleParent = tree;
} else {
accessibleParent = new AccessibleJTreeNode(tree,
parentPath,
null);
}
accessibleParent = new AccessibleJTreeNode(tree,
parentPath,
null);
this.setAccessibleParent(accessibleParent);
} else if (treeModel != null) {
accessibleParent = tree; // we're the top!

View File

@@ -257,7 +257,6 @@ vmTestbase/nsk/jdi/LaunchingConnector/launchnosuspend/launchnosuspend001/TestDes
vmTestbase/nsk/jdi/ThreadReference/stop/stop001/TestDescription.java 7034630 generic-all
vmTestbase/nsk/jdi/ReferenceType/instances/instances002/instances002.java initial_run linux-all
vmTestbase/nsk/jdi/Value/type/type003/TestDescription.java time_out_intermittent macosx-all
vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses002/TestDescription.java JBR-6715 macosx-all
vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001/TestDescription.java JBR-6530 macosx-all
vmTestbase/nsk/jdi/VirtualMachine/canGetBytecodes/cangetbytecodes001/TestDescription.java time_out_intermittent macosx-aarch64
vmTestbase/nsk/jdi/VirtualMachine/canGetCurrentContendedMonitor/cangccm001/TestDescription.java JBR-6994 macosx-all

View File

@@ -1118,7 +1118,6 @@ jdk_swing_wayland= \
-javax/swing/JEditorPane/6917744/bug6917744.java \
-javax/swing/JEditorPane/8195095/ImageViewTest.java \
-javax/swing/JEditorPane/TestBrowserBGColor.java \
-javax/swing/JFileChooser/4524490/bug4524490.java \
-javax/swing/JFileChooser/6570445/bug6570445.java \
-javax/swing/JFileChooser/6738668/bug6738668.java \
-javax/swing/JFileChooser/7036025/bug7036025.java \
@@ -1139,8 +1138,6 @@ jdk_swing_wayland= \
-javax/swing/JInternalFrame/8145896/TestJInternalFrameMaximize.java \
-javax/swing/JInternalFrame/8146321/JInternalFrameIconTest.java \
-javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java \
-javax/swing/JInternalFrame/bug4309079.java \
-javax/swing/JInternalFrame/bug4732229.java \
-javax/swing/JInternalFrame/JInternalFrameTest.java \
-javax/swing/JInternalFrame/NormalBoundsTest.java \
-javax/swing/JInternalFrame/Test6325652.java \
@@ -1161,7 +1158,6 @@ jdk_swing_wayland= \
-javax/swing/JMenu/PopupReferenceMemoryLeak.java \
-javax/swing/JMenu/TestDisabledMenuForegroundColor.java \
-javax/swing/JMenuBar/4750590/bug4750590.java \
-javax/swing/JMenuBar/bug4802656.java \
-javax/swing/JMenuBar/MisplacedBorder/MisplacedBorder.java \
-javax/swing/JMenuBar/MenuBarRTLBug.java \
-javax/swing/JMenuItem/4171437/bug4171437.java \
@@ -1278,8 +1274,6 @@ jdk_swing_wayland= \
-javax/swing/text/Caret/TestCaretPosition.java \
-javax/swing/text/Caret/TestCaretPositionJTextPane.java \
-javax/swing/text/CSSBorder/6796710/bug6796710.java \
-javax/swing/text/DefaultCaret/bug4197894.java \
-javax/swing/text/DefaultCaret/bug4203175.java \
-javax/swing/text/DefaultCaret/HidingSelection/HidingSelectionTest.java \
-javax/swing/text/DefaultCaret/HidingSelection/MultiSelectionTest.java \
-javax/swing/text/DefaultEditorKit/4278839/bug4278839.java \
@@ -1290,7 +1284,6 @@ jdk_swing_wayland= \
-javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java \
-javax/swing/text/html/StyleSheet/bug4936917.java \
-javax/swing/text/html/TestFormViewNPE.java \
-javax/swing/text/rtf/bug4178276.java \
-javax/swing/text/JTextComponent/6361367/bug6361367.java \
-javax/swing/text/StyledEditorKit/4506788/bug4506788.java \
-javax/swing/text/Utilities/8142966/SwingFontMetricsTest.java \

View File

@@ -41,36 +41,28 @@ public class CheckDisplayModes {
continue;
}
DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode();
System.out.println("Initial Display mode: " + defaultDisplayMode);
checkDisplayMode(defaultDisplayMode);
graphicDevice.setDisplayMode(defaultDisplayMode);
try {
DisplayMode[] displayModes = graphicDevice.getDisplayModes();
boolean isDefaultDisplayModeIncluded = false;
for (DisplayMode displayMode : displayModes) {
checkDisplayMode(displayMode);
graphicDevice.setDisplayMode(displayMode);
System.out.println("\tDisplay mode changed to " + displayMode);
if (defaultDisplayMode.equals(displayMode)) {
isDefaultDisplayModeIncluded = true;
}
DisplayMode[] displayModes = graphicDevice.getDisplayModes();
boolean isDefaultDisplayModeIncluded = false;
for (DisplayMode displayMode : displayModes) {
checkDisplayMode(displayMode);
graphicDevice.setDisplayMode(displayMode);
if (defaultDisplayMode.equals(displayMode)) {
isDefaultDisplayModeIncluded = true;
}
}
if (!isDefaultDisplayModeIncluded) {
throw new RuntimeException("Default display mode is not included");
}
} finally {
System.out.println("Restoring display mode to " + defaultDisplayMode);
graphicDevice.setDisplayMode(defaultDisplayMode);
System.out.println("Display mode restored " + defaultDisplayMode);
if (!isDefaultDisplayModeIncluded) {
throw new RuntimeException("Default display mode is not included");
}
}
}
static void checkDisplayMode(DisplayMode displayMode) {
if (displayMode == null || displayMode.getWidth() <= 1 || displayMode.getHeight() <= 1) {
throw new RuntimeException("invalid display mode" + displayMode);
throw new RuntimeException("invalid display mode");
}
}
}

View File

@@ -1,99 +0,0 @@
/*
* Copyright (c) 2024, JetBrains s.r.o.. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8249806
* @summary Tests that JTree's root is not set as accessible parent of top-level tree nodes (direct children of root)
* when the JTree has setRootVisible(false).
* @run main AccessibleJTreeNodeAccessibleParentTest
*/
import java.awt.Robot;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
public class AccessibleJTreeNodeAccessibleParentTest {
private static JTree jTree;
private static JFrame jFrame;
private static void createGUI() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
DefaultMutableTreeNode node = new DefaultMutableTreeNode("node");
root.add(node);
jTree = new JTree(root);
jTree.setRootVisible(false);
jFrame = new JFrame();
jFrame.setBounds(100, 100, 300, 300);
jFrame.getContentPane().add(jTree);
jFrame.setVisible(true);
}
private static void doTest() throws Exception {
try {
SwingUtilities.invokeAndWait(() -> createGUI());
Robot robot = new Robot();
robot.waitForIdle();
AtomicBoolean accessibleNodeInitialized = new AtomicBoolean(false);
SwingUtilities.invokeAndWait(() -> {
jTree.getAccessibleContext().addPropertyChangeListener(evt -> {
// When an AccessibleJTreeNode is created for the active descendant change event,
// its parent is not set on initialization but calculated on the first access.
// This imitates the way assistive tools obtain AccessibleJTreeNode objects.
if (AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY.equals(evt.getPropertyName()) &&
evt.getNewValue() instanceof Accessible accessibleNode) {
// Check that the parent of the top-level node is the tree itself instead of the invisible root.
if (!jTree.equals(accessibleNode.getAccessibleContext().getAccessibleParent())) {
throw new RuntimeException("Accessible parent of the top-level node is not the tree.");
}
accessibleNodeInitialized.set(true);
}
});
jTree.setSelectionRow(0);
});
robot.waitForIdle();
if (!accessibleNodeInitialized.get()) {
throw new RuntimeException("The active descendant property change event wasn't fired, " +
"or the accessible node wasn't initialized properly.");
}
} finally {
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
}
}
public static void main(String[] args) throws Exception {
doTest();
System.out.println("Test Passed");
}
}

View File

@@ -1,97 +0,0 @@
/*
* Copyright 2000-2024 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 java.awt.*;
import java.io.*;
/**
* @test
* @summary DetectingOSThemeTest checks that JBR could correctly detect OS theme and notify about theme changing in time
* @run main DetectingOSThemeTest
* @requires (os.family == "linux")
*/
public class DetectingOSThemeTest {
private static final int TIME_TO_WAIT = 2000;
private static final String LIGHT_THEME_NAME = "Light";
private static final String DARK_THEME_NAME = "Dark";
private static final String UNDEFINED_THEME_NAME = "Undefined";
private static String currentTheme() {
Boolean val = (Boolean) Toolkit.getDefaultToolkit().getDesktopProperty("awt.os.theme.isDark");
if (val == null) {
return UNDEFINED_THEME_NAME;
}
return (val) ? DARK_THEME_NAME : LIGHT_THEME_NAME;
}
private static void setOsDarkTheme(String val) {
try {
if (val.equals(DARK_THEME_NAME)) {
Runtime.getRuntime().exec("gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'");
Runtime.getRuntime().exec("gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'");
} else {
Runtime.getRuntime().exec("gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'");
Runtime.getRuntime().exec("gsettings set org.gnome.desktop.interface color-scheme 'default'");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static String currentTheme = null;
public static void main(String[] args) throws Exception {
currentTheme = currentTheme();
if (currentTheme.equals(UNDEFINED_THEME_NAME)) {
throw new RuntimeException("Test Failed! Cannot detect current OS theme");
}
String initialTheme = currentTheme;
try {
setOsDarkTheme(LIGHT_THEME_NAME);
Thread.sleep(TIME_TO_WAIT);
if (!currentTheme().equals(LIGHT_THEME_NAME)) {
throw new RuntimeException("Test Failed! Initial OS theme supposed to be Light");
}
String[] themesOrder = {DARK_THEME_NAME, LIGHT_THEME_NAME, DARK_THEME_NAME};
Toolkit.getDefaultToolkit().addPropertyChangeListener("awt.os.theme.isDark", evt -> {
currentTheme = currentTheme();
});
for (String nextTheme : themesOrder) {
setOsDarkTheme(nextTheme);
Thread.sleep(TIME_TO_WAIT);
if (!currentTheme().equals(nextTheme)) {
throw new RuntimeException("Test Failed! OS theme which was set doesn't match with detected");
}
if (!currentTheme.equals(nextTheme)) {
throw new RuntimeException("Test Failed! Changing OS theme was not detected");
}
}
} finally {
setOsDarkTheme(initialTheme);
}
}
}

View File

@@ -132,14 +132,13 @@ public class KeyCodesTest implements Runnable {
verify("", VK_SHIFT, "com.apple.keylayout.ABC", VK_SHIFT, VK_UNDEFINED, KEY_LOCATION_LEFT, SHIFT_DOWN_MASK);
verify("", VK_SHIFT, "com.apple.keylayout.ABC", ROBOT_KEYCODE_RIGHT_SHIFT, VK_UNDEFINED, KEY_LOCATION_RIGHT, SHIFT_DOWN_MASK);
// TODO: disabled the test because it was flapping and isn't very useful anyways
// // duplicate key codes: Vietnamese ANSI_6 / ANSI_9
// verify(" \u0309", 0x1000000+0x0309, "com.apple.keylayout.Vietnamese", VK_6);
// verify(" \u0323", 0x1000000+0x0323, "com.apple.keylayout.Vietnamese", VK_9);
//
// // duplicated key codes (dead): Apache ANSI_LeftBracket / ANSI_RightBracket
// verify("\u02db", VK_DEAD_OGONEK, "com.apple.keylayout.Apache", VK_OPEN_BRACKET, 0x1000000+0x02DB, KEY_LOCATION_STANDARD, 0);
// verify("\u02db\u0301", 0x1000000+0x0301, "com.apple.keylayout.Apache", VK_CLOSE_BRACKET);
// duplicate key codes: Vietnamese ANSI_6 / ANSI_9
verify(" \u0309", 0x1000000+0x0309, "com.apple.keylayout.Vietnamese", VK_6);
verify(" \u0323", 0x1000000+0x0323, "com.apple.keylayout.Vietnamese", VK_9);
// duplicated key codes (dead): Apache ANSI_LeftBracket / ANSI_RightBracket
verify("\u02db", VK_DEAD_OGONEK, "com.apple.keylayout.Apache", VK_OPEN_BRACKET, 0x1000000+0x02DB, KEY_LOCATION_STANDARD, 0);
verify("\u02db\u0301", 0x1000000+0x0301, "com.apple.keylayout.Apache", VK_CLOSE_BRACKET);
}
private void verify(String typed, int vk, String layout, int key, int charKeyCode, int location, int modifiers) {

View File

@@ -111,7 +111,6 @@ java/awt/Choice/ChoiceFreezeTest.java JBR-6952 windows-x64
java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java JBR-6857,JBR-5505 macosx-all,windows-all
java/awt/Choice/RemoveAllShrinkTest/RemoveAllShrinkTest.java JBR-5510,8310487,JBR-6950 linux-5.18.2-arch1-1,linux-all,windows-x64
java/awt/dnd/Button2DragTest/Button2DragTest.java 8310490,JBR-5505 windows-all,linux-all
java/awt/event/ComponentEvent/TextComponentTextEventTest.java JBR-7141 windows-all
java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java 8233568,JBR-5915,JBR-5505 macosx-all,linux-all,windows-all
java/awt/Focus/6378278/InputVerifierTest.java JBR-5505 windows-all
java/awt/Focus/OwnedWindowFocusIMECrashTest/OwnedWindowFocusIMECrashTest.java 8169110,JBR-5505 linux-all,windows-all

View File

@@ -1,14 +0,0 @@
java/awt/image/multiresolution/MultiresolutionIconTest.java JBR-7146 macosx-12.7.4
java/awt/image/multiresolution/MultiResolutionJOptionPaneIconTest.java JBR-7146 macosx-12.7.4
java/awt/Paint/PaintNativeOnUpdate.java JBR-7146 macosx-12.7.4
java/awt/Robot/HiDPIScreenCapture/ScreenCaptureTest.java JBR-7146 macosx-12.7.4
java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java JBR-7146 macosx-12.7.4
java/awt/Window/WindowTitleVisibleTest/WindowTitleVisibleTest.java JBR-7146 macosx-12.7.4
javax/swing/JButton/8151303/PressedIconTest.java JBR-7146 macosx-12.7.4
javax/swing/JComponent/7154030/bug7154030.java JBR-7146 macosx-12.7.4
javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java JBR-7146 macosx-12.7.4
javax/swing/JInternalFrame/DockIconRepaint/DockIconRepaint.java JBR-7146 macosx-12.7.4
javax/swing/JSpinner/4670051/DateFieldUnderCursorTest.java JBR-7146 macosx-12.7.4
javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentGradient.java JBR-7146 macosx-12.7.4
javax/swing/plaf/metal/MetalBorders/ScaledMetalBorderTest.java#id1 JBR-7146 macosx-12.7.4
jb/java/awt/Window/MacNativeTransparentTitlebarWithCustomHeight.java JBR-7146 macosx-12.7.4

View File

@@ -112,11 +112,10 @@
############################################################################
java/awt/Dialog/CloseDialog/CloseDialogTest.java JBR-6538 windows-all
java/awt/EventQueue/6980209/bug6980209.java 8198615,JBR-6699 macosx-all,linux-all
java/awt/EventQueue/6980209/bug6980209.java JBR-6699 linux-all
java/awt/Focus/6378278/InputVerifierTest.java JBR-6700 linux-all
java/awt/Focus/6382144/EndlessLoopTest.java JBR-6701 linux-all
java/awt/Focus/6981400/Test1.java 8029675,JBR-6702 windows-all,macosx-all,linux-all
java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogTest/EnqueueWithDialogTest.java JBR-5210,JBR-7077 windows-all,linux-all
java/awt/MenuItem/EnableTest.java NOBUG windows-all timeout
java/awt/Mouse/EnterExitEvents/DragWindowTest.java 8253184,JBR-5710 windows-all,linux-all
java/awt/Robot/NonEmptyErrorStream.java JBR-6275,JBR-5510,JBR-6246 macosx-all,linux-5.18.2-arch1-1,generic-all

View File

@@ -90,7 +90,7 @@ java/awt/MouseInfo/MultiscreenPointerInfo.java nobug linux-all
java/awt/Multiscreen/LocationRelativeToTest/LocationRelativeToTest.java 8253184 windows-all,linux-all
java/awt/Multiscreen/UpdateGCTest/UpdateGCTest.java nobug linux-all
java/awt/Paint/PaintNativeOnUpdate.java 8253184,JBR-5510 windows-all,linux-all
java/awt/PopupMenu/PopupMenuLocation.java JBR-7079 linux-x64
java/awt/PopupMenu/PopupMenuStayOpen.java JBR-6286 linux-all
java/awt/Robot/CheckCommonColors/CheckCommonColors.java 8277816,8253184,JBR-5510 macosx-aarch64,windows-all,linux-all
java/awt/Robot/HiDPIScreenCapture/ScreenCaptureTest.java 8277816,8253184 macosx-aarch64,windows-all,linux-all
java/awt/Window/8159168/SetShapeTest.java 8253184,JBR-5510 windows-all,linux-all

View File

@@ -22,7 +22,6 @@ java/awt/image/DrawImage/SimpleUnmanagedImage.java initial_runs generic-all
java/awt/Mixing/AWT_Mixing/JListInGlassPaneOverlapping.java initial_runs generic-all
java/awt/Mixing/AWT_Mixing/JListOverlapping.java initial_runs generic-all
java/awt/Mixing/AWT_Mixing/JPopupMenuOverlapping.java initial_runs generic-all
java/awt/Mouse/MouseWheelAbsXY/MouseWheelAbsXY.java JBR-7076 linux-all
java/awt/PopupMenu/PopupMenuLocation.java initial_runs generic-all
java/awt/PopupMenu/PopupMenuStayOpen.java initial_runs generic-all
java/awt/TextArea/AutoScrollOnSelectAndAppend/AutoScrollOnSelectAndAppend.java initial_runs generic-all

View File

@@ -159,7 +159,6 @@ java/awt/dnd/DropActionChangeTest.java JBR-6489,JBR-6757 generic-all,windows-all
java/awt/dnd/DropTargetEnterExitTest/ExtraDragEnterTest.java 8029680 generic-all
java/awt/dnd/DropTargetEnterExitTest/MissedDragExitTest.java JBR-5730 linux-all
java/awt/dnd/DropTargetingTest.java JBR-6729 windows-all
java/awt/dnd/IntraJVMGetDropSuccessTest.java JBR-6738 windows-all
java/awt/dnd/MissedDragEnterTest.java JBR-6091 windows-all
java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java 8288839,JBR-5727,JBR-5959 windows-all,linux-all
java/awt/dnd/ModalDialogDeadlockTest.java JBR-6776 windows-all
@@ -250,7 +249,7 @@ java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.java 8073636,JBR-4211
java/awt/EventDispatchThread/PropertyPermissionOnEDT/PropertyPermissionOnEDT.java JBR-5225 windows-all
java/awt/FullScreen/AltTabCrashTest/AltTabCrashTest.java JBR-4905 windows-all,linux-all
java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java 7019055,8266245 windows-all,linux-all,macosx-aarch64
java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java JBR-4275,JBR-4880,JBR-7108 linux-all,windows-all,macosx-all
java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java JBR-4275,JBR-4880 linux-all,windows-all
java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java 7188711,8253184 linux-all,windows-all
java/awt/FullScreen/UninitializedDisplayModeChangeTest/UninitializedDisplayModeChangeTest.java 7188711,8273617,JBR-4880,8253184 macosx-all,linux-all,windows-all
java/awt/Focus/8013611/JDK8013611.java 8175366 windows-all,macosx-all
@@ -378,7 +377,7 @@ java/awt/ColorClass/AlphaColorTest.java JBR-5510 linux-5.18.2-arch1-1
java/awt/color/ICC_ColorSpace/MTTransformReplacedProfile.java JBR-6246 generic-all
java/awt/Component/F10TopToplevel/F10TopToplevel.java JBR-5687 linux-all
java/awt/Component/GetScreenLocTest/GetScreenLocTest.java 4753654 generic-all
java/awt/Component/RepaintTest.java JBR-5510,JBR-6872 linux-5.18.2-arch1-1,macosx-all
java/awt/Component/RepaintTest.java JBR-5510 linux-5.18.2-arch1-1
java/awt/Component/SetComponentsBounds/SetComponentsBounds.java JBR-4275 linux-all
java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java 8165863 macosx-all
java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.java 8017454 macosx-all
@@ -980,7 +979,7 @@ javax/swing/JPopupMenu/4760494/bug4760494.java 8253184 windows-all
javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all
javax/swing/JPopupMenu/4966112/bug4966112.java 8253184 windows-all
javax/swing/JPopupMenu/6415145/bug6415145.java 8197552 windows-all
javax/swing/JPopupMenu/6495920/bug6495920.java JBR-6928 linux-all
javax/swing/JPopupMenu/6495920/bug6495920.java JBR-6928 linux-x64
javax/swing/JPopupMenu/6515446/bug6515446.java 8197552,JBR-6531 windows-all,linux-all
javax/swing/JPopupMenu/6544309/bug6544309.java JBR-6532 windows-all,linux-all
javax/swing/JPopupMenu/6675802/bug6675802.java JBR-5767 windows-all

View File

@@ -11,7 +11,6 @@ java/awt/dnd/MozillaDnDTest.java JBR-6442 linux-all
java/awt/event/KeyEvent/ExtendedModifiersTest/ExtendedModifiersTest.java JBR-6292 windows-all
java/awt/event/KeyEvent/KeyMaskTest/KeyMaskTest.java JBR-6292 windows-all
java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.java 8238720,JBR-6095 windows-all,linux-all
java/awt/event/MouseEvent/MouseEnterExitTest.java JBR-7113 linux-all
java/awt/event/StressTest/MouseAndKeyEventStressTest.java JBR-6479,JBR-6090 generic-all
java/awt/Focus/6378278/InputVerifierTest.java JBR-5799,JBR-6090 windows-all
java/awt/Focus/6382144/EndlessLoopTest.java JBR-6090 windows-all
@@ -57,7 +56,6 @@ javax/swing/JComboBox/TestComboBoxComponentRendering.java JBR-6100 linux-all
javax/swing/JComponent/7154030/bug7154030.java JBR-6134 windows-x64
javax/swing/JPopupMenu/6580930/bug6580930.java JBR-5071 linux-all
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 8233582,JBR-6090,JBR-6360 linux-all,windows-all,macosx-all
javax/swing/plaf/basic/BasicGraphicsUtils/8132119/bug8132119.java JBR-5342 linux-all
jb/java/awt/event/MouseEvent/ReleaseAndClickModifiers.java JBR-6589 windows-all
@@ -73,7 +71,6 @@ java/awt/Graphics/XORPaint.java#id0
java/awt/Graphics2D/LargeWindowPaintTest.java#ZGenerational nobug generic-all
java/awt/Graphics2D/LargeWindowPaintTest.java#ZSinglegen nobug generic-all
java/awt/Graphics2D/LargeWindowPaintTest.java#default nobug generic-all
java/awt/image/multiresolution/MultiresolutionIconTest.java nobug generic-all
java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java nobug generic-all
java/awt/Paint/PaintNativeOnUpdate.java nobug generic-all
java/awt/Robot/HiDPIScreenCapture/HiDPIRobotScreenCaptureTest.java nobug generic-all
@@ -103,7 +100,6 @@ jb/java/awt/CustomTitleBar/WindowVisibilityTest.java
java/awt/event/ComponentEvent/TextComponentTextEventTest.java JBR-6287 windows-all
jb/java/awt/Focus/ComplexFocusSequence.java JBR-6728 linux-all,windows-x64
jb/java/awt/Focus/FileDialogClosing.java JBR-5799 windows-all
jb/java/awt/Focus/ModalDialogFromMenuTest.java JBR-5799 windows-all
jb/java/awt/Focus/ModalDialogOverSiblingTest.java JBR-5716 windows-all

View File

@@ -1,4 +1,2 @@
# Fedora & ArchLinux (Wayland) & Ubuntu 21.04
java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java 8279256 linux-all
javax/swing/JFileChooser/6520101/bug6520101.java JBR-7140 linux-all
javax/swing/JInternalFrame/bug5009724.java JBR-7087 linux-all
java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowBlockingTest.java 8279256 linux-all

View File

@@ -4,5 +4,4 @@ javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh nobug generic-
javax/imageio/plugins/external_plugin_tests/TestClassPathPlugin.sh nobug generic-all # line 59: /opt/teamcity-agent/work/efb45cc305c2e813/jbr/Contents/Home/bin/jar: No such file or directory
javax/swing/JInternalFrame/bug5009724.java JBR-7087 linux-all
javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java 8013450 macosx-all,windows-all