mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-5095 Incorrect initial window's location under GNOME
(cherry picked from commit6995ce47fd) with fix for JBR-5189 Can't exit fullscreen mode on ubuntu 22.10 (cherry picked from commitb933660cf1) (cherry picked from commit f4ea24e18d8e6f4cb0420e30344a5cd3f000c021)
This commit is contained in:
@@ -344,19 +344,11 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
|| ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom())
|
||||
{
|
||||
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
|
||||
if ((XWM.getWMID() == XWM.MUTTER_WM && !isTargetUndecorated() && isVisible())
|
||||
|| getMWMDecorTitleProperty().isPresent()) {
|
||||
// Insets might have changed "in-flight" if that property
|
||||
// is present, so we need to get the actual values of
|
||||
// insets from the WM and propagate them through all the
|
||||
// proper channels.
|
||||
wm_set_insets = null;
|
||||
Insets in = getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||
if (in != null && !in.equals(dimensions.getInsets())) {
|
||||
handleCorrectInsets(in);
|
||||
}
|
||||
} else {
|
||||
getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||
wm_set_insets = null;
|
||||
Insets in = getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||
if (isReparented() && (!isMapped() || getMWMDecorTitleProperty().isPresent()) &&
|
||||
in != null && !in.equals(dimensions.getInsets())) {
|
||||
handleCorrectInsets(in);
|
||||
}
|
||||
} else {
|
||||
if (!isReparented()) {
|
||||
|
||||
@@ -1419,9 +1419,6 @@ final class XWM
|
||||
case UNITY_COMPIZ_WM:
|
||||
res = new Insets(28, 1, 1, 1);
|
||||
break;
|
||||
case MUTTER_WM:
|
||||
res = new Insets(37, 0, 0, 0);
|
||||
break;
|
||||
case MOTIF_WM:
|
||||
case OPENLOOK_WM:
|
||||
default:
|
||||
@@ -1433,7 +1430,6 @@ final class XWM
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some buggy WMs ignore window gravity when processing
|
||||
* ConfigureRequest and position window as if the gravity is Static.
|
||||
|
||||
71
test/jdk/jb/java/awt/Window/RestoreFromFullScreen.java
Normal file
71
test/jdk/jb/java/awt/Window/RestoreFromFullScreen.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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 java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-5189 Can't exit fullscreen mode on ubuntu 22.10
|
||||
* @key headful
|
||||
*/
|
||||
|
||||
public class RestoreFromFullScreen {
|
||||
private static final int INITIAL_WIDTH = 400;
|
||||
private static final int INITIAL_HEIGHT = 300;
|
||||
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(RestoreFromFullScreen::initUI);
|
||||
Thread.sleep(1000);
|
||||
SwingUtilities.invokeAndWait(() -> frame.getGraphicsConfiguration().getDevice().setFullScreenWindow(frame));
|
||||
Thread.sleep(1000);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (frame.getWidth() <= INITIAL_WIDTH || frame.getHeight() <= INITIAL_HEIGHT) {
|
||||
throw new RuntimeException("Full screen transition hasn't happened");
|
||||
}
|
||||
frame.getGraphicsConfiguration().getDevice().setFullScreenWindow(null);
|
||||
});
|
||||
Thread.sleep(1000);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (frame.getWidth() != INITIAL_WIDTH || frame.getHeight() != INITIAL_HEIGHT) {
|
||||
throw new RuntimeException("Restoring of the original size hasn't happened");
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(RestoreFromFullScreen::disposeUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
frame = new JFrame("RestoreFromFullScreen");
|
||||
frame.setBounds(200, 200, INITIAL_WIDTH, INITIAL_HEIGHT);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeUI() {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
}
|
||||
70
test/jdk/jb/java/awt/Window/WindowInitialPosition.java
Normal file
70
test/jdk/jb/java/awt/Window/WindowInitialPosition.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2022 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.*;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-5095 Incorrect initial window's location under GNOME
|
||||
* @key headful
|
||||
*/
|
||||
|
||||
public class WindowInitialPosition {
|
||||
private static JFrame frame;
|
||||
private static Point location;
|
||||
private static Point locationOnScreen;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(WindowInitialPosition::initUI);
|
||||
Thread.sleep(1000);
|
||||
SwingUtilities.invokeAndWait(WindowInitialPosition::fetchLocation);
|
||||
Point expectedLocation = new Point(200, 200);
|
||||
if (!expectedLocation.equals(location)) {
|
||||
throw new RuntimeException("Frame reports unexpected location: " + location);
|
||||
}
|
||||
if (!expectedLocation.equals(locationOnScreen)) {
|
||||
throw new RuntimeException("Frame reports unexpected locationOnScreen: " + locationOnScreen);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
SwingUtilities.invokeAndWait(WindowInitialPosition::disposeUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
frame = new JFrame("WindowInitialPosition");
|
||||
frame.setBounds(200, 200, 200, 200);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeUI() {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
|
||||
private static void fetchLocation() {
|
||||
location = frame.getLocation();
|
||||
locationOnScreen = frame.getLocationOnScreen();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user