mirror of
https://github.com/openjdk/jdk.git
synced 2026-06-12 21:45:05 +00:00
8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
Reviewed-by: alexsch, azvegint
This commit is contained in:
parent
99bcaacabf
commit
947d19a3a6
@ -29,6 +29,9 @@ import java.awt.*;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.awt.IconInfo;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
@ -52,6 +55,8 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
XContentWindow content;
|
||||
Insets currentInsets;
|
||||
XFocusProxyWindow focusProxy;
|
||||
static final Map<Class<?>,Insets> lastKnownInsets =
|
||||
Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
XDecoratedPeer(Window target) {
|
||||
super(target);
|
||||
@ -74,6 +79,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
winAttr.initialFocus = true;
|
||||
|
||||
currentInsets = new Insets(0,0,0,0);
|
||||
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
|
||||
currentInsets = lastKnownInsets.get(getClass());
|
||||
}
|
||||
applyGuessedInsets();
|
||||
|
||||
Rectangle bounds = (Rectangle)params.get(BOUNDS);
|
||||
@ -297,7 +305,25 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
if (ev.get_atom() == XWM.XA_KDE_NET_WM_FRAME_STRUT.getAtom()
|
||||
|| ev.get_atom() == XWM.XA_NET_FRAME_EXTENTS.getAtom())
|
||||
{
|
||||
getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||
if (XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
|
||||
getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||
} else {
|
||||
if(!isReparented()) {
|
||||
return;
|
||||
}
|
||||
wm_set_insets = null;
|
||||
Insets in = getWMSetInsets(XAtom.get(ev.get_atom()));
|
||||
if (isNull(in)) {
|
||||
return;
|
||||
}
|
||||
if (!isEmbedded() && !isTargetUndecorated()) {
|
||||
lastKnownInsets.put(getClass(), in);
|
||||
}
|
||||
if (!in.equals(dimensions.getInsets())) {
|
||||
handleCorrectInsets(in);
|
||||
}
|
||||
insets_corrected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,7 +396,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
}
|
||||
|
||||
if (correctWM != null) {
|
||||
if (correctWM != null && XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
|
||||
handleCorrectInsets(correctWM);
|
||||
}
|
||||
}
|
||||
@ -664,6 +690,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
|
||||
boolean no_reparent_artifacts = false;
|
||||
public void handleConfigureNotifyEvent(XEvent xev) {
|
||||
if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM && !insets_corrected) {
|
||||
return;
|
||||
}
|
||||
assert (SunToolkit.isAWTLockHeldByCurrentThread());
|
||||
XConfigureEvent xe = xev.get_xconfigure();
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
|
||||
@ -1360,6 +1360,9 @@ final class XWM
|
||||
case LG3D_WM:
|
||||
res = zeroInsets;
|
||||
break;
|
||||
case UNITY_COMPIZ_WM:
|
||||
res = new Insets(28, 1, 1, 1);
|
||||
break;
|
||||
case MOTIF_WM:
|
||||
case OPENLOOK_WM:
|
||||
default:
|
||||
|
||||
@ -777,6 +777,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
case XWM.METACITY_WM:
|
||||
case XWM.MUTTER_WM:
|
||||
case XWM.SAWFISH_WM:
|
||||
case XWM.UNITY_COMPIZ_WM:
|
||||
{
|
||||
Point xlocation = queryXLocation();
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test @summary setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
|
||||
* @bug 8036915
|
||||
* @run main GetScreenLocationTest
|
||||
*/
|
||||
import java.awt.*;
|
||||
|
||||
public class GetScreenLocationTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
Window frame = null;
|
||||
for(int i = 0; i < 50; i++) {
|
||||
if(frame != null) frame.dispose();
|
||||
frame = new Dialog((Frame)null);
|
||||
frame.setBounds(0, 0, 200, 200);
|
||||
frame.setVisible(true);
|
||||
robot.waitForIdle();
|
||||
robot.delay(200);
|
||||
frame.setLocation(321, 321);
|
||||
robot.waitForIdle();
|
||||
robot.delay(200);
|
||||
Dimension size = frame.getSize();
|
||||
if(size.width != 200 || size.height != 200) {
|
||||
frame.dispose();
|
||||
throw new RuntimeException("getSize() is wrong " + size);
|
||||
}
|
||||
Rectangle r = frame.getBounds();
|
||||
frame.dispose();
|
||||
if(r.x != 321 || r.y != 321) {
|
||||
throw new RuntimeException("getLocation() returns " +
|
||||
"wrong coordinates " + r.getLocation());
|
||||
}
|
||||
if(r.width != 200 || r.height != 200) {
|
||||
throw new RuntimeException("getSize() is wrong " + r.getSize());
|
||||
}
|
||||
}
|
||||
System.out.println("ok");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user