=== 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 2015-10-24 19:51:34 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2015-10-25 20:57:36 +0000 @@ -783,7 +783,8 @@ break; case 0x98: // enable/disable OS events - p2j.screen.enableOsEvents(message[1] == 1); + var wid = me.readInt32BinaryMessage(message, 1); + p2j.screen.enableOsEvents(wid, message[5] == 1); break; case 0x99: // set window iconification state === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-10-24 19:51:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-10-25 20:21:46 +0000 @@ -253,7 +253,7 @@ @Override public void enableEvents(boolean capture) { - websock.enableOsEvents(capture); + websock.enableOsEvents(windowId, capture); } /** === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-10-24 19:51:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-10-25 20:21:24 +0000 @@ -611,12 +611,19 @@ /** * Enable or disable processing of OS events. * + * @param windowId + * The window ID. * @param state * {@code true} to process OS events, {@code false} to ignore them. */ - public void enableOsEvents(boolean state) + public void enableOsEvents(int windowId, boolean state) { - sendBinaryMessage(ENABLE_OS_EVENTS, (byte) (state ? 1 : 0)); + byte[] message = new byte[6]; + message[0] = ENABLE_OS_EVENTS; + + writeMessageInt32(message, 1, windowId); + message[5] = (byte) (state ? 1 : 0); + sendBinaryMessage(message); } /** === 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 2015-10-24 19:51:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2015-10-25 20:17:10 +0000 @@ -148,7 +148,7 @@ { return function(evt) { - if (!p2j.screen.canProcessOsEvent(evt)) + if (!p2j.screen.canProcessOsEvent(evt, win)) { return; } @@ -490,7 +490,7 @@ } var mThis = win.mouseHandler; - if (mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt)) + if (mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt, win)) { return; } @@ -657,7 +657,7 @@ if (mThis.dragOwner != win.id || !win.resizeable || !mThis.mouseDrag || - !p2j.screen.canProcessOsEvent(evt)) + !p2j.screen.canProcessOsEvent(evt, win)) { return; } @@ -854,7 +854,7 @@ { return function(evt) { - if (!mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt)) + if (!mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt, win)) { return; } @@ -898,7 +898,7 @@ { // only left button can trigger move if (evt.which != 1 || - !p2j.screen.canProcessOsEvent(evt) || + !p2j.screen.canProcessOsEvent(evt, win) || !win.canProcessWidget(wid, evt, mouseOp)) { return; @@ -935,7 +935,7 @@ { return function(evt) { - if (mThis.dragOwner != wid || !mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt)) + if (mThis.dragOwner != wid || !mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt, win)) { return; } @@ -994,7 +994,7 @@ return function(evt) { - if (evt.which != 1 || !p2j.screen.canProcessOsEvent(evt)) + if (evt.which != 1 || !p2j.screen.canProcessOsEvent(evt, win)) { return; } @@ -1194,7 +1194,7 @@ return function(evt) { - if (evt.which != btnId || !p2j.screen.canProcessOsEvent(evt)) + if (evt.which != btnId || !p2j.screen.canProcessOsEvent(evt, win)) { return; } === 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 2015-10-24 19:51:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-10-25 20:59:20 +0000 @@ -48,9 +48,6 @@ /** Flag indicating if the screen should send mouse events to the client-side. */ me.processMouse = false; - /** Flag indicating if the screen should send OS events to the client-side. */ - me.processOsEvents = false; - /** PaintPrimitives to ordinal mappings. Change this to match Java PaintPrimitives changes! */ var ops = { @@ -202,6 +199,12 @@ this.canvasRenderer = new CanvasRenderer(this.canvas, this.ctx, strokesManager, p2j.fonts, p2j.logger); + /** + * Flag indicating if the window should send OS events to the client-side. The default value + * for new created window must be true due to modal windows application logic. + */ + this.processOsEvents = true; + /** * List of widgets which are aware of mouse events. They are in z-order, with the top-most * widgets having a having a lower index than the bottomost widgets. This provides a @@ -372,7 +375,7 @@ wThis.sendMouseEvent(evt, mousePos, wThis, opCode); } - if (!me.canProcessOsEvent(evt)) + if (!me.canProcessOsEvent(evt, wThis)) { return; } @@ -629,6 +632,16 @@ }; /** + * Enables/disables the OS events for this window. + * + * @param {Boolean} capture + * When true, it will process OS events like window close/iconify/etc. + */ + Window.prototype.enableOsEvents = function(capture) + { + this.processOsEvents = capture; + }; + /** * Draw the given list of operations in the canvas. * * @param {byte[]} message @@ -1461,14 +1474,16 @@ * Determine if the specified event can be processed. If the OS events or the mouse events are * disabled, return false. Also, return false if the event is consumed. * - * @param {MouseEvent} evt - * The event details. + * @param {MouseEvent} evt + * The event details. + * @param {Window} win + * The window object. * - * @return true if the event can be processed. + * @return true if the event can be processed. */ - me.canProcessOsEvent = function(evt) + me.canProcessOsEvent = function(evt, win) { - return me.processOsEvents && me.processMouse && !evt.defaultPrevented; + return win.processOsEvents && me.processMouse && !evt.defaultPrevented; } /** @@ -1868,12 +1883,15 @@ /** * Disable or enable OS event processing. * - * @param {boolean} capture - * When true, it will process OS events like window close/iconify/etc. + * @param {Number} wid + * The target window for which OS event processing should be enabled or disabled. + * @param {Boolean} capture + * When true, it will process OS events like window close/iconify/etc. */ - me.enableOsEvents = function(capture) + me.enableOsEvents = function(wid, capture) { - me.processOsEvents = capture; + var win = getWindow(wid); + win.enableOsEvents(capture); } /** @@ -1919,9 +1937,6 @@ // disable mouse events me.captureMouseEvents(false); - // enable all OS events - me.enableOsEvents(true); - desktop = new VirtualDesktop( sendWindowStateActive, [174, 174, 174],