=== modified file 'src/com/goldencode/p2j/ui/client/chui/driver/web/ChuiWebSimulator.java' --- src/com/goldencode/p2j/ui/client/chui/driver/web/ChuiWebSimulator.java 2015-12-09 06:42:45 +0000 +++ src/com/goldencode/p2j/ui/client/chui/driver/web/ChuiWebSimulator.java 2016-02-01 15:21:19 +0000 @@ -222,13 +222,16 @@ } /** - * Raise an event as the window was activated. This is a no-op in ChUI. + * Raise an event indicating that the target window has been activated or deactivated. This is + * a no-op in ChUI. * * @param windowId * The window ID. + * @param state + * True if the window has been activated, otherwise false. */ @Override - public void windowActivated(int windowId) + public void windowActivated(int windowId, boolean state) { // no-op } === modified file 'src/com/goldencode/p2j/ui/client/driver/web/ClientProtocolHooks.java' --- src/com/goldencode/p2j/ui/client/driver/web/ClientProtocolHooks.java 2015-12-09 06:42:45 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/ClientProtocolHooks.java 2016-02-01 15:21:19 +0000 @@ -100,12 +100,14 @@ public void setWindowDimension(int windowId, int width, int height); /** - * Raise an event as the window was activated. + * Raise an event indicating that the target window has been activated or deactivated. * * @param windowId * The window ID. + * @param state + * The boolean flag indicating that the target window has been activated or inactive. */ - public void windowActivated(int windowId); + public void windowActivated(int windowId, boolean state); /** * Raise an event as the window was (de)iconified. === modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js' --- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2016-01-31 17:04:52 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2016-02-02 05:43:00 +0000 @@ -101,11 +101,13 @@ * * @param {Number} wid * The target window id + * @param {Boolean} active + * The flag indicating that the target window should be active or not. */ - me.sendWindowActive = function(wid) + me.sendWindowActive = function(wid, active) { // send the window activation to the java side - var msg = new Uint8Array(5); + var msg = new Uint8Array(6); // message type msg[0] = 0x0f; @@ -113,6 +115,8 @@ // 1. the window ID me.writeInt32BinaryMessage(msg, 1, wid); + msg[5] = active ? 1 : 0; + // send the window active event me.send(msg); } === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2016-01-10 13:19:14 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2016-02-02 05:28:40 +0000 @@ -587,7 +587,7 @@ if (focus) { // activate the window and notify the upper layers - windowActivated(windowId); + windowActivated(windowId, true); } } @@ -889,9 +889,11 @@ * * @param windowId * The window ID. + * @param state + * True if the window has been activated, otherwise false. */ @Override - public void windowActivated(int windowId) + public void windowActivated(int windowId, boolean state) { // resolve window object TopLevelWindow window = (TopLevelWindow) WindowManager.findWindow(windowId); @@ -915,10 +917,8 @@ { ThinClient.getInstance().postOSEvent(new WindowActivated(ow, false, false)); } - else - { - ThinClient.getInstance().postOSEvent(new WindowActivated(window, true, false)); - } + + ThinClient.getInstance().postOSEvent(new WindowActivated(window, state, false)); } /** === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2016-01-08 16:20:03 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2016-02-01 18:17:11 +0000 @@ -423,7 +423,7 @@ } break; case SET_WINDOW_BOUNDS: - if (x != ps.x || y != ps.y || width != ps.width || height != ps.height) + if (x != ps.x || y != ps.y || width != ps.width || height != ps.height || initLocation) { x = ps.x; y = ps.y; === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-01-29 15:50:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-02-01 15:21:19 +0000 @@ -1245,14 +1245,16 @@ handled = true; } - else if (length == 5 && message[offset] == MSG_WINDOW_ACTIVATED) + else if (length == 6 && message[offset] == MSG_WINDOW_ACTIVATED) { int idx = offset + 1; int windowId = readMessageInt32(message, idx); idx = idx + 4; - this.callbacks.windowActivated(windowId); + boolean state = message[idx] == 1; + + this.callbacks.windowActivated(windowId, state); } else if (length == 6 && message[offset] == MSG_WINDOW_ICONIFY) { === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2016-01-31 17:04:52 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2016-02-01 15:21:19 +0000 @@ -108,16 +108,21 @@ // to request the input focus to this window win.canvas.focus(); - - if (p2j.screen.topWindowId() == win.id) + + var topWindowId = p2j.screen.topWindowId(); + if (topWindowId == win.id) { return; } + if (topWindowId) + { + p2j.socket.sendWindowActive(topWindowId, false); + } // move the window to top win.moveToTop(); - p2j.socket.sendWindowActive(win.id); + p2j.socket.sendWindowActive(win.id, true); // consume the event evt.preventDefault(); === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-01-31 17:04:52 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-02-02 05:49:46 +0000 @@ -1588,11 +1588,12 @@ */ function activateTopVisibleWindow(id) { + //p2j.socket.sendWindowActive(id, false); var topWindow = findTopVisibleWindow(id); if (topWindow) { topWindow.moveToTop(); - p2j.socket.sendWindowActive(topWindow.id); + p2j.socket.sendWindowActive(topWindow.id, true); } } @@ -1670,7 +1671,6 @@ // the z-order is based on the array index var zidx = zlist.length * 10; - // assign the z-order win.canvas.style.zIndex = zidx; }; @@ -2178,7 +2178,11 @@ */ me.moveToTop = function(wid) { - moveZOrderEntryToTop(wid); + var win = getWindow(wid); + if (win) + { + win.moveToTop(); + } } /** @@ -2263,7 +2267,6 @@ addZOrderEntry(newZlist[i].id, newZlist[i].win); } - taskBar.setTaskIconActive(zlist[zlist.length - 1].id, true); console.log("restack"); @@ -2356,7 +2359,11 @@ */ function sendWindowStateActive(windowId) { - p2j.socket.sendWindowActive(windowId); + var topWindowId = p2j.screen.topWindowId(); + if (topWindowId) + { + p2j.socket.sendWindowActive(topWindowId, false); + } var win = getWindow(windowId); if (!win.isVisible()) { @@ -2366,19 +2373,7 @@ win.deiconify(); // send the window activation to the java side - message = new Uint8Array(5); - var offset = 0; - - // message type - message[0] = 0x0f; - offset = offset + 1; - - // 1. the window ID - p2j.socket.writeInt32BinaryMessage(message, offset, win.id); - offset = offset + 4; - - // send the message - p2j.socket.send(message); + p2j.socket.sendWindowActive(windowId, true); } /**