java-1.8.0-openjdk/set-active-window.patch
Omair Majid fc1e586a19 Fix window activation in gnome-shell
Backport fix for JDK-8012224
2014-05-28 19:48:35 -04:00

78 lines
3.3 KiB
Diff

# HG changeset patch
# User azvegint
# Date 1395070254 -14400
# Mon Mar 17 19:30:54 2014 +0400
# Node ID 6406059d2620c8241f6e04398ee0c4591e8820ac
# Parent 37099d54a1483fffb9e51552cfda8ac956bd97ee
8012224: AWT_TopLevels/TopLevelEvents/Automated/WindowIconifyDeiconifyEventsTest02 fails on Ubuntu 12.04 Unity shell
Reviewed-by: anthony, serb
diff --git jdk8/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java jdk8/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
--- jdk8/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
+++ jdk8/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java
@@ -284,6 +284,11 @@
if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
stateLog.finer("DeIconifying " + this);
}
+
+ XNETProtocol net_protocol = XWM.getWM().getNETProtocol();
+ if (net_protocol != null) {
+ net_protocol.setActiveWindow(this);
+ }
xSetVisible(true);
}
}
diff --git jdk8/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java jdk8/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java
--- jdk8/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java
+++ jdk8/jdk/src/solaris/classes/sun/awt/X11/XNETProtocol.java
@@ -213,7 +213,7 @@
* If window is showing then it uses ClientMessage, otherwise adjusts NET_WM_STATE list
* @param window Window which NET_WM_STATE property is being modified
* @param state State atom to be set/reset
- * @param reset Indicates operation, 'set' if false, 'reset' if true
+ * @param set Indicates operation, 'set' if false, 'reset' if true
*/
private void setStateHelper(XWindowPeer window, XAtom state, boolean set) {
if (log.isLoggable(PlatformLogger.Level.FINER)) {
@@ -249,6 +249,7 @@
XAtom XA_UTF8_STRING = XAtom.get("UTF8_STRING"); /* like STRING but encoding is UTF-8 */
XAtom XA_NET_SUPPORTING_WM_CHECK = XAtom.get("_NET_SUPPORTING_WM_CHECK");
XAtom XA_NET_SUPPORTED = XAtom.get("_NET_SUPPORTED"); /* list of protocols (property of root) */
+ XAtom XA_NET_ACTIVE_WINDOW = XAtom.get("_NET_ACTIVE_WINDOW");
XAtom XA_NET_WM_NAME = XAtom.get("_NET_WM_NAME"); /* window property */
XAtom XA_NET_WM_STATE = XAtom.get("_NET_WM_STATE");/* both window property and request */
@@ -325,6 +326,32 @@
return res;
}
+ public void setActiveWindow(XWindow window) {
+ if (!active() || !checkProtocol(XA_NET_SUPPORTED, XA_NET_ACTIVE_WINDOW)) {
+ return;
+ }
+
+ XClientMessageEvent msg = new XClientMessageEvent();
+ msg.zero();
+ msg.set_type(XConstants.ClientMessage);
+ msg.set_message_type(XA_NET_ACTIVE_WINDOW.getAtom());
+ msg.set_display(XToolkit.getDisplay());
+ msg.set_window(window.getWindow());
+ msg.set_format(32);
+ msg.set_data(0, 1);
+ msg.set_data(1, XToolkit.getCurrentServerTime());
+ msg.set_data(2, 0);
+
+ XToolkit.awtLock();
+ try {
+ XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), false,
+ XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, msg.getPData());
+ } finally {
+ XToolkit.awtUnlock();
+ msg.dispose();
+ }
+ }
+
boolean isWMName(String name) {
if (!active()) {
return false;