Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
Expand Down Expand Up @@ -29,6 +29,9 @@
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;
Expand All @@ -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);
Expand All @@ -74,6 +79,9 @@ void preInit(XCreateWindowParams params) {
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);
Expand Down Expand Up @@ -297,7 +305,25 @@ public void handlePropertyNotify(XEvent xev) {
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;
}
}
}

Expand Down Expand Up @@ -370,7 +396,7 @@ public void handleReparentNotifyEvent(XEvent xev) {
}
}

if (correctWM != null) {
if (correctWM != null && XWM.getWMID() != XWM.UNITY_COMPIZ_WM) {
handleCorrectInsets(correctWM);
}
}
Expand Down Expand Up @@ -664,6 +690,9 @@ void reconfigureContentWindow(WindowDimensions dims) {

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)) {
Expand Down Expand Up @@ -1011,7 +1040,22 @@ private void handleWmTakeFocus(XClientMessageEvent cl) {
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
focusLog.fine("WM_TAKE_FOCUS on {0}", this);
}
requestWindowFocus(cl.get_data(1), true);

if (XWM.getWMID() == XWM.UNITY_COMPIZ_WM) {
// JDK-8159460
Window focusedWindow = XKeyboardFocusManagerPeer.getInstance()
.getCurrentFocusedWindow();
Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
if (activeWindow != target) {
requestWindowFocus(cl.get_data(1), true);
} else {
WindowEvent we = new WindowEvent(focusedWindow,
WindowEvent.WINDOW_GAINED_FOCUS);
sendEvent(we);
}
} else {
requestWindowFocus(cl.get_data(1), true);
}
}

/**
Expand Down
16 changes: 14 additions & 2 deletions jdk/src/solaris/classes/sun/awt/X11/XWM.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
Expand Down Expand Up @@ -104,7 +104,8 @@ final class XWM
COMPIZ_WM = 12,
LG3D_WM = 13,
CWM_WM = 14,
MUTTER_WM = 15;
MUTTER_WM = 15,
UNITY_COMPIZ_WM = 16;
public String toString() {
switch (WMID) {
case NO_WM:
Expand All @@ -129,6 +130,8 @@ public String toString() {
return "Metacity";
case COMPIZ_WM:
return "Compiz";
case UNITY_COMPIZ_WM:
return "Unity Compiz";
case LG3D_WM:
return "LookingGlass";
case CWM_WM:
Expand Down Expand Up @@ -572,6 +575,10 @@ static boolean isCompiz() {
return isNetWMName("compiz");
}

static boolean isUnityCompiz() {
return isNetWMName("Compiz");
}

static boolean isLookingGlass() {
return isNetWMName("LG3D");
}
Expand Down Expand Up @@ -790,6 +797,8 @@ static int getWMID() {
awt_wmgr = CWM_WM;
} else if (doIsIceWM && isIceWM()) {
awt_wmgr = XWM.ICE_WM;
} else if (isUnityCompiz()) {
awt_wmgr = XWM.UNITY_COMPIZ_WM;
}
/*
* We don't check for legacy WM when we already know that WM
Expand Down Expand Up @@ -1340,6 +1349,9 @@ Insets guessInsets(XDecoratedPeer window) {
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:
Expand Down
1 change: 1 addition & 0 deletions jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ protected Point getNewLocation(XConfigureEvent xe, int leftInset, int topInset)
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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}

}