Compare commits

..

4 Commits
1659 ... 1665

Author SHA1 Message Date
Maxim Kartashev
5aa26c75b2 JBR-3772 java/beans/PropertyEditor/TestFontClass.java: access denied ("java.util.PropertyPermission" "sun.awt.x11.trace" "read")
Instead of using System.getProperty() directly, wrap the call into
GetPropertyAction and use AccessController to execute it.

(cherry picked from commit 3092ca0461)
2021-09-16 09:27:16 +03:00
Dmitry Batrak
f0ed32fca4 JBR-3726 Modal windows 'disappear' on minimize in KDE
revert changes not needed anymore
2021-09-14 18:21:37 +03:00
Dmitry Batrak
5c4fd9ceaf JBR-3726 Modal windows 'disappear' on minimize in KDE
re-implement the fix without using _NET_WM_STATE_MODAL - it causes other issues
2021-09-14 17:20:53 +03:00
Vitaly Provodin
16267bd573 add the link to JBR build targeted for 213 EAP 2021-09-14 15:19:31 +07:00
6 changed files with 166 additions and 33 deletions

View File

@@ -11,9 +11,10 @@ can be found on the [releases page](https://github.com/JetBrains/JetBrainsRuntim
| IDE Version | Latest JBR | Date Released |
| --- | --- | --- |
| 2021.2 | [11_0_11-b1504.28](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jb11_0_12-b1504.28) | 10-Aug-2021 |
| 2021.1 | [11.0.11+9-b1341.60](https://confluence.jetbrains.com/pages/viewpage.action?pageId=218857477) | 15-Jun-2021 |
| 2020.3 | [11_0_11-b1145.115](https://confluence.jetbrains.com/pages/viewpage.action?pageId=219349001) | 21-Jun-2021 |
| 2021.3 | [11_0_12-b1649.1](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jb11_0_12-b11_0_12b1649.1) | 13-Sep-2021 |
| 2021.2 | [11_0_12-b1504.28](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jb11_0_12-b1504.28) | 07-Sep-2021 |
| 2021.1 | [11.0.11+9-b1341.60](https://confluence.jetbrains.com/pages/viewpage.action?pageId=218857477) | 15-Jun-2021 |
| 2020.3 | [11_0_11-b1145.115](https://confluence.jetbrains.com/pages/viewpage.action?pageId=219349001) | 21-Jun-2021 |
## Contents
- [Welcome to JetBrains Runtime](#jetbrains-runtime)

View File

@@ -110,13 +110,6 @@ class XAtomList {
atoms.remove(atom);
}
/**
* Adds or removes (depending on {@code set} value) atom to the list. Returns {@code true} if the list contents
* has changed after the operation.
*/
public boolean update(XAtom atom, boolean set) {
return set ? atoms.add(atom) : atoms.remove(atom);
}
/**
* Returns size of the list

View File

@@ -63,27 +63,11 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer {
try {
Dialog target = (Dialog)this.target;
if (vis) {
boolean modal = target.getModalityType() != Dialog.ModalityType.MODELESS;
if (modal) {
if (target.getModalityType() != Dialog.ModalityType.MODELESS) {
if (!isModalBlocked()) {
XBaseWindow.ungrabInput();
}
}
if (XWM.getWMID() == XWM.KDE2_WM) {
// In case of KDE, we inform window manager that our window is a modal dialog
// so that it's minimized along with its parent window.
// This is not needed for other WMs, as it seems only KDE allows minimizing 'transient'
// windows, and setting _NET_WM_STATE_MODAL causes other WMs' undesirable behaviour.
// GNOME (mutter WM), for example, enforces centering of modal dialogs with respect
// to their parent, which breaks SiblingChildOrderTest.
XNETProtocol protocol = XWM.getWM().getNETProtocol();
if (protocol != null && protocol.doModalityProtocol()) {
XAtomList net_wm_state = getNETWMState();
if (net_wm_state.update(protocol.XA_NET_WM_STATE_MODAL, modal)) {
setNETWMState(net_wm_state);
}
}
}
} else {
restoreTransientFor(this);
prevTransientFor = null;
@@ -171,4 +155,25 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer {
}
return super.isFocusedWindowModalBlocker();
}
@Override
public void handleUnmapNotifyEvent(XEvent xev) {
super.handleUnmapNotifyEvent(xev);
if (visible && ((Dialog)target).isModal() && XWM.getWMID() == XWM.KDE2_WM) {
// the case of modal dialog window being minimized (iconified) on KDE
// (other WMs don't seem to allow minimizing)
Vector<XWindowPeer> windowPeers = collectJavaToplevels();
for (XWindowPeer peer : windowPeers) {
if (peer.modalBlocker == target) {
XToolkit.awtLock();
try {
XlibWrapper.XIconifyWindow(XToolkit.getDisplay(), peer.getWindow(), peer.getScreenNumber());
}
finally {
XToolkit.awtUnlock();
}
}
}
}
}
}

View File

@@ -1335,9 +1335,12 @@ static int getRemoteX11WorkaroundProperty() {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jstring name = (*env)->NewStringUTF(env, WORKAROUND_PROPERTY_NAME);
CHECK_NULL_RETURN(name, ret);
jstring jPropValue = JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "getProperty",
"(Ljava/lang/String;)Ljava/lang/String;", name).l;
if (jPropValue != NULL) {
jobject jPropGetAction = JNU_NewObjectByName(env, "sun/security/action/GetPropertyAction", "(Ljava/lang/String;)V", name);
CHECK_NULL_RETURN(name, ret);
jboolean ignoreExc;
jstring jPropValue = JNU_CallStaticMethodByName(env, &ignoreExc, "java/security/AccessController", "doPrivileged",
"(Ljava/security/PrivilegedAction;)Ljava/lang/Object;", jPropGetAction).l;
if (jPropValue != NULL && JNU_IsInstanceOfByName(env, jPropValue, "java/lang/String")) {
const char * utf8string = (*env)->GetStringUTFChars(env, jPropValue, NULL);
if (utf8string != NULL) {
if (strcmp(utf8string, "true") == 0) {
@@ -1348,7 +1351,6 @@ static int getRemoteX11WorkaroundProperty() {
}
(*env)->ReleaseStringUTFChars(env, jPropValue, utf8string);
}
(*env)->DeleteLocalRef(env, name);
return ret;
}

View File

@@ -52,9 +52,7 @@ public class SiblingChildOrderTest
frame.setVisible(true);
});
Robot robot = new Robot();
for (int i = 0; i < colors.length; i++) {
robot.delay(100);
int finalI = i;
SwingUtilities.invokeLater(() -> {
dlgs[finalI] = new JDialog(frame, "DLG " + finalI, true);
@@ -65,6 +63,7 @@ public class SiblingChildOrderTest
});
}
Robot robot = new Robot();
robot.waitForIdle();
robot.delay(1000);

View File

@@ -0,0 +1,133 @@
/*
* Copyright 2021 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.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
/**
* @test
* @summary Regression test for JBR-3726 Modal windows 'disappear' on minimize in KDE
* @key headful
* @requires os.family == "linux"
* @modules java.desktop/java.awt:open
* java.desktop/sun.awt
* java.desktop/sun.awt.X11:open
*/
public class ModalDialogMinimizeOnKDE {
private static final CompletableFuture<Boolean> dialogShown = new CompletableFuture<>();
private static JFrame frame;
private static JDialog dialog;
public static void main(String[] args) throws Exception {
if (!isKDE()) {
System.out.println("This test is only valid for KDE");
return;
}
Robot robot = new Robot();
try {
SwingUtilities.invokeLater(ModalDialogMinimizeOnKDE::initUI);
dialogShown.get(5, TimeUnit.SECONDS);
robot.delay(1000);
minimize(dialog);
robot.delay(1000);
if (frame.getState() != Frame.ICONIFIED) {
throw new RuntimeException("Parent frame isn't minimized");
}
} finally {
SwingUtilities.invokeAndWait(ModalDialogMinimizeOnKDE::disposeUI);
}
}
private static void initUI() {
frame = new JFrame("ModalDialogMinimizeOnKDE");
frame.setSize(300, 200);
frame.setVisible(true);
dialog = new JDialog(frame, true);
dialog.setSize(200, 100);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
dialogShown.complete(true);
}
});
dialog.setVisible(true);
}
private static void disposeUI() {
if (frame != null) frame.dispose();
}
private static boolean isKDE() throws Exception {
Class<?> xwmCls = Class.forName("sun.awt.X11.XWM");
Field kdeField = xwmCls.getDeclaredField("KDE2_WM");
kdeField.setAccessible(true);
Method wmidMethod = xwmCls.getDeclaredMethod("getWMID");
wmidMethod.setAccessible(true);
return kdeField.get(null).equals(wmidMethod.invoke(null));
}
// We need to simulate user minimizing the dialog using button in title bar.
// As we don't know the location of the button (and it can depend on KDE version),
// we'll just use Xlib to minimize the window.
private static void minimize(JDialog dialog) throws Exception {
Class<?> toolkitCls = Class.forName("sun.awt.SunToolkit");
Method lockMethod = toolkitCls.getDeclaredMethod("awtLock");
Method unlockMethod = toolkitCls.getDeclaredMethod("awtUnlock");
Class<?> xToolkitClass = Class.forName("sun.awt.X11.XToolkit");
Method displayMethod = xToolkitClass.getDeclaredMethod("getDisplay");
Class<?> wrapperClass = Class.forName("sun.awt.X11.XlibWrapper");
Method iconifyMethod = wrapperClass.getDeclaredMethod("XIconifyWindow",
long.class, long.class, long.class);
iconifyMethod.setAccessible(true);
Class<?> windowClass = Class.forName("sun.awt.X11.XBaseWindow");
Method windowMethod = windowClass.getDeclaredMethod("getWindow");
Method screenMethod = windowClass.getDeclaredMethod("getScreenNumber");
screenMethod.setAccessible(true);
Field peerField = Component.class.getDeclaredField("peer");
peerField.setAccessible(true);
Object peer = peerField.get(dialog);
lockMethod.invoke(null);
try {
iconifyMethod.invoke(null,
displayMethod.invoke(null),
windowMethod.invoke(peer),
screenMethod.invoke(peer));
} finally {
unlockMethod.invoke(null);
}
}
}