=== 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-29 15:50:34 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2016-01-31 16:54:35 +0000 @@ -95,7 +95,53 @@ me.send(msg); }; - + + /** + * Sends the window active event to the server. + * + * @param {Number} wid + * The target window id + */ + me.sendWindowActive = function(wid) + { + // send the window activation to the java side + var msg = new Uint8Array(5); + + // message type + msg[0] = 0x0f; + + // 1. the window ID + me.writeInt32BinaryMessage(msg, 1, wid); + + // send the window active event + me.send(msg); + } + + /** + * Sends the window icon state event to the server. + * + * @param {Number} wid + * The target window id. + * @param {Boolean} minimized + * The target window has been minimized. + */ + me.sendWindowIconState = function(wid, minimized) + { + var msg = new Uint8Array(6); + + // message type + msg[0] = 0x10; + + // 0. the window ID + me.writeInt32BinaryMessage(msg, 1, wid); + + // 1. the iconification state + msg[5] = minimized ? 1 : 0; + + // send the mouse event + me.send(msg); + } + /** * Send a binary message with the given message type and the specified byte array serialized. * === 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-04 08:14:16 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2016-01-31 16:14:34 +0000 @@ -115,20 +115,7 @@ // move the window to top win.moveToTop(); - // send the window activation to the java side - var 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 mouse event - p2j.socket.send(message); + p2j.socket.sendWindowActive(win.id); // consume the event evt.preventDefault(); @@ -1086,25 +1073,8 @@ function windowIconifyCallback(win, evt, mousePos, opCode) { win.iconify(); - - var message = new Uint8Array(6); - - var offset = 0; - - // message type - message[0] = 0x10; - offset = offset + 1; - - // 0. the window ID - p2j.socket.writeInt32BinaryMessage(message, offset, win.id); - offset = offset + 4; - - // 1. the iconification state - message[offset] = 1; - offset = offset + 1; - - // send the mouse event - p2j.socket.send(message); + + p2j.socket.sendWindowIconState(win.id, true); }; this.getEvents = function() === 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-29 15:50:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-01-31 16:53:08 +0000 @@ -1594,6 +1594,7 @@ if (topWindow) { topWindow.moveToTop(); + p2j.socket.sendWindowActive(topWindow.id); } } @@ -2325,23 +2326,21 @@ }; /** - * Sends the active window state to the server. + * Notifies the server that the target window should be active and restores its state + * if the target window has been minimized before. * * @param {Number} windowId * The target windowId */ function sendWindowStateActive(windowId) { - var message = new Uint8Array(6); - - message[0] = 0x10; - p2j.socket.writeInt32BinaryMessage(message, 1, windowId); - // 1. the iconification state - message[5] = 0; - p2j.socket.send(message); - + p2j.socket.sendWindowActive(windowId); + var win = getWindow(windowId); + if (!win.isVisible()) + { + p2j.socket.sendWindowIconState(windowId, false); + } // de-iconify the window - var win = getWindow(windowId); win.deiconify(); }