mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-3751 Window content isn't rendered with some window managers on Linux
(cherry picked from commit8d22e4dcb0) includes fix for JBR-5046 Incorrect initial window's location in Xfce (cherry picked from commits234e705134,02bc54f864) includes fix for JBR-5458 Exception at dialog closing (cherry picked from commitacde759572)
This commit is contained in:
@@ -403,6 +403,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
insLog.fine(xe.toString());
|
||||
}
|
||||
|
||||
setPendingConfigureEvent(null);
|
||||
|
||||
reparent_serial = xe.get_serial();
|
||||
long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
|
||||
|
||||
@@ -744,6 +747,29 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
content.setContentBounds(dims);
|
||||
}
|
||||
|
||||
private XEvent pendingConfigureEvent;
|
||||
|
||||
private void setPendingConfigureEvent(XConfigureEvent xev) {
|
||||
if (pendingConfigureEvent != null) {
|
||||
pendingConfigureEvent.dispose();
|
||||
}
|
||||
pendingConfigureEvent = xev == null ? null : xev.clone();
|
||||
}
|
||||
|
||||
private void processPendingConfigureEvent() {
|
||||
if (pendingConfigureEvent != null) {
|
||||
processConfigureEvent(pendingConfigureEvent.get_xconfigure());
|
||||
pendingConfigureEvent.dispose();
|
||||
pendingConfigureEvent = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMapNotifyEvent(XEvent xev) {
|
||||
processPendingConfigureEvent();
|
||||
super.handleMapNotifyEvent(xev);
|
||||
}
|
||||
|
||||
boolean no_reparent_artifacts = false;
|
||||
public void handleConfigureNotifyEvent(XEvent xev) {
|
||||
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM && !insets_corrected) {
|
||||
@@ -782,24 +808,30 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some window managers configure before we are reparented and
|
||||
* the send event flag is set! ugh... (Enlightenment for one,
|
||||
* possibly MWM as well). If we haven't been reparented yet
|
||||
* this is just the WM shuffling us into position. Ignore
|
||||
* it!!!! or we wind up in a bogus location.
|
||||
*/
|
||||
int runningWM = XWM.getWMID();
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
insLog.fine("reparented={0}, visible={1}, WM={2}, decorations={3}",
|
||||
isReparented(), isVisible(), runningWM, getDecorations());
|
||||
}
|
||||
if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
|
||||
&& !XWM.isNonReparentingWM()
|
||||
&& getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
|
||||
insLog.fine("- visible but not reparented, skipping");
|
||||
return;
|
||||
if (!isReparented() && isVisible() && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
|
||||
if (ENABLE_REPARENTING_CHECK) {
|
||||
if (runningWM != XWM.NO_WM && !XWM.isNonReparentingWM()) {
|
||||
insLog.fine("- visible but not reparented, skipping");
|
||||
return;
|
||||
}
|
||||
} else if (!isMapped()) {
|
||||
// For reparenting window managers we're not processing ConfigureNotify events received before
|
||||
// ReparentNotify. But we cannot know for sure whether WM is reparenting or not, so we remember
|
||||
// the last received ConfigureNotify event, and process it at the time MapNotify is received.
|
||||
setPendingConfigureEvent(xe);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
processConfigureEvent(xe);
|
||||
}
|
||||
|
||||
private void processConfigureEvent(XConfigureEvent xe) {
|
||||
//Last chance to correct insets
|
||||
if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
|
||||
long parent = XlibUtil.getParentWindow(window);
|
||||
@@ -825,13 +857,13 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
|
||||
WindowDimensions newDimensions =
|
||||
new WindowDimensions(newLocation,
|
||||
new Dimension(scaleDown(xe.get_width()),
|
||||
scaleDown(xe.get_height())),
|
||||
copy(currentInsets), true);
|
||||
new Dimension(scaleDown(xe.get_width()),
|
||||
scaleDown(xe.get_height())),
|
||||
copy(currentInsets), true);
|
||||
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
insLog.finer("Insets are {0}, new dimensions {1}",
|
||||
currentInsets, newDimensions);
|
||||
currentInsets, newDimensions);
|
||||
}
|
||||
|
||||
checkIfOnNewScreen(newDimensions.getBounds());
|
||||
|
||||
@@ -45,6 +45,8 @@ import sun.awt.X11GraphicsEnvironment;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
@@ -56,6 +58,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
private static final PlatformLogger grabLog = PlatformLogger.getLogger("sun.awt.X11.grab.XWindowPeer");
|
||||
private static final PlatformLogger iconLog = PlatformLogger.getLogger("sun.awt.X11.icon.XWindowPeer");
|
||||
|
||||
static final boolean ENABLE_REPARENTING_CHECK
|
||||
= "true".equals(GetPropertyAction.privilegedGetProperty("reparenting.check"));
|
||||
|
||||
// should be synchronized on awtLock
|
||||
private static Set<XWindowPeer> windows = new HashSet<XWindowPeer>();
|
||||
|
||||
@@ -731,7 +736,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
|
||||
int runningWM = XWM.getWMID();
|
||||
Point newLocation = targetBounds.getLocation();
|
||||
if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
|
||||
if (xe.get_send_event() ||
|
||||
(ENABLE_REPARENTING_CHECK ? (runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) : !isReparented())) {
|
||||
// Location, Client size + insets
|
||||
newLocation = new Point(scaleDown(xe.get_x()) - leftInset,
|
||||
scaleDown(xe.get_y()) - topInset);
|
||||
@@ -1410,6 +1416,14 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
isUnhiding |= isWMStateNetHidden();
|
||||
|
||||
super.handleMapNotifyEvent(xev);
|
||||
|
||||
if (!ENABLE_REPARENTING_CHECK && delayedModalBlocking) {
|
||||
// case of non-re-parenting WM
|
||||
// (for a re-parenting WM this should have been already done on ReparentNotify processing)
|
||||
addToTransientFors(AWTAccessor.getComponentAccessor().getPeer(modalBlocker));
|
||||
delayedModalBlocking = false;
|
||||
}
|
||||
|
||||
if (isBeforeFirstMapNotify && !winAttr.initialFocus && shouldSuppressWmTakeFocus()) {
|
||||
suppressWmTakeFocus(false); // restore the protocol.
|
||||
if (!XWM.isKDE2()) {
|
||||
@@ -1627,7 +1641,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
modalBlocker = d;
|
||||
|
||||
if (isReparented() || XWM.isNonReparentingWM()) {
|
||||
if (isReparented() ||
|
||||
ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM() ||
|
||||
!ENABLE_REPARENTING_CHECK && isMapped()) {
|
||||
addToTransientFors(blockerPeer, javaToplevels);
|
||||
} else {
|
||||
delayedModalBlocking = true;
|
||||
@@ -1638,7 +1654,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
modalBlocker = null;
|
||||
|
||||
if (isReparented() || XWM.isNonReparentingWM()) {
|
||||
if (isReparented() ||
|
||||
ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM() ||
|
||||
!ENABLE_REPARENTING_CHECK && isMapped()) {
|
||||
removeFromTransientFors();
|
||||
} else {
|
||||
delayedModalBlocking = false;
|
||||
|
||||
@@ -63,8 +63,8 @@ abstract class XWrapperBase {
|
||||
}
|
||||
public abstract long getPData();
|
||||
public XEvent clone() {
|
||||
long copy = XlibWrapper.unsafe.allocateMemory(getDataSize());
|
||||
XlibWrapper.unsafe.copyMemory(getPData(), copy, getDataSize());
|
||||
return new XEvent(copy);
|
||||
XEvent copy = new XEvent();
|
||||
XlibWrapper.unsafe.copyMemory(getPData(), copy.getPData(), getDataSize());
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2023 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-5458 Exception at dialog closing
|
||||
* @key headful
|
||||
*/
|
||||
|
||||
public class UndecoratedDialogInTransientsChain {
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
try {
|
||||
SwingUtilities.invokeLater(UndecoratedDialogInTransientsChain::initUI);
|
||||
robot.delay(1000);
|
||||
clickAtCenter();
|
||||
robot.delay(2000);
|
||||
clickAtCenter();
|
||||
robot.delay(1000);
|
||||
if (frame.isDisplayable()) {
|
||||
throw new IllegalStateException("Frame should have been closed");
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(UndecoratedDialogInTransientsChain::disposeUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
frame = new JFrame("UndecoratedDialogInTransientsChain");
|
||||
JButton b1 = new JButton("Close");
|
||||
b1.addActionListener(e -> frame.dispose());
|
||||
frame.add(b1);
|
||||
frame.setBounds(200, 200, 400, 400);
|
||||
frame.setVisible(true);
|
||||
JDialog d = new JDialog(frame, "Dialog", true);
|
||||
JButton b2 = new JButton("Close");
|
||||
b2.addActionListener(e -> {
|
||||
JDialog d2 = new JDialog(frame);
|
||||
d2.setUndecorated(true);
|
||||
d2.setVisible(true);
|
||||
robot.delay(1000); // wait for the window to be realized natively
|
||||
d2.dispose();
|
||||
d.dispose();
|
||||
});
|
||||
d.add(b2);
|
||||
d.setBounds(300, 300, 200, 200);
|
||||
d.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeUI() {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
|
||||
private static void clickAtCenter() {
|
||||
robot.mouseMove(400, 400);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user