8012224: AWT_TopLevels/TopLevelEvents/Automated/WindowIconifyDeiconifyEventsTest02 fails on Ubuntu 12.04 Unity shell

Reviewed-by: anthony, serb
This commit is contained in:
Alexander Zvegintsev 2014-03-17 19:30:54 +04:00
parent 87514d9f0e
commit b88756e8fd
2 changed files with 33 additions and 1 deletions

View File

@ -284,6 +284,11 @@ class XFramePeer extends XDecoratedPeer implements FramePeer {
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);
}
}

View File

@ -213,7 +213,7 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
* 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 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
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 @@ final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProt
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;