Project

General

Profile

2776_2.txt

Sergey Ivanovskiy, 10/25/2015 05:19 PM

Download (9.56 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js'
2
--- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js	2015-10-24 19:51:34 +0000
3
+++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js	2015-10-25 20:57:36 +0000
4
@@ -783,7 +783,8 @@
5
                      break;
6
                   case 0x98:
7
                      // enable/disable OS events
8
-                     p2j.screen.enableOsEvents(message[1] == 1);
9
+                     var wid = me.readInt32BinaryMessage(message, 1);
10
+                     p2j.screen.enableOsEvents(wid, message[5] == 1);
11
                      break;
12
                   case 0x99:
13
                      // set window iconification state
14

    
15
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java'
16
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2015-10-24 19:51:34 +0000
17
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2015-10-25 20:21:46 +0000
18
@@ -253,7 +253,7 @@
19
    @Override
20
    public void enableEvents(boolean capture)
21
    {
22
-      websock.enableOsEvents(capture);
23
+      websock.enableOsEvents(windowId, capture);
24
    }
25
 
26
    /**
27

    
28
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
29
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2015-10-24 19:51:34 +0000
30
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2015-10-25 20:21:24 +0000
31
@@ -611,12 +611,19 @@
32
    /**
33
     * Enable or disable processing of OS events.
34
     *  
35
+    * @param    windowId
36
+    *           The window ID.
37
     * @param    state
38
     *           {@code true} to process OS events, {@code false} to ignore them.
39
     */
40
-   public void enableOsEvents(boolean state)
41
+   public void enableOsEvents(int windowId, boolean state)
42
    {
43
-      sendBinaryMessage(ENABLE_OS_EVENTS, (byte) (state ? 1 : 0));
44
+      byte[] message = new byte[6];
45
+      message[0] = ENABLE_OS_EVENTS;
46
+      
47
+      writeMessageInt32(message, 1, windowId);
48
+      message[5] = (byte) (state ? 1 : 0);
49
+      sendBinaryMessage(message);
50
    }
51
 
52
    /**
53

    
54
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js'
55
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2015-10-24 19:51:34 +0000
56
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2015-10-25 21:11:41 +0000
57
@@ -94,7 +94,7 @@
58
    {
59
       return function(evt)
60
       {
61
-         if (!p2j.screen.processMouse || evt.defaultPrevented)
62
+         if (!p2j.screen.processMouse || evt.defaultPrevented || !win.processOsEvents)
63
          {
64
             return;
65
          }
66
@@ -110,23 +110,20 @@
67
          // move the window to top
68
          win.moveToTop();
69
          
70
-         if (p2j.screen.processOsEvents)
71
-         {
72
-            // send the window activation to the java side
73
-            var message = new Uint8Array(5);
74
-            var offset = 0;
75
-            
76
-            // message type
77
-            message[0] = 0x0f;
78
-            offset = offset + 1;
79
-            
80
-            // 1. the window ID
81
-            p2j.socket.writeInt32BinaryMessage(message, offset, win.id);
82
-            offset = offset + 4;
83
-   
84
-            // send the mouse event
85
-            p2j.socket.send(message);
86
-         }
87
+         // send the window activation to the java side
88
+         var message = new Uint8Array(5);
89
+         var offset = 0;
90
+         
91
+         // message type
92
+         message[0] = 0x0f;
93
+         offset = offset + 1;
94
+         
95
+         // 1. the window ID
96
+         p2j.socket.writeInt32BinaryMessage(message, offset, win.id);
97
+         offset = offset + 4;
98
+
99
+         // send the mouse event
100
+         p2j.socket.send(message);
101
          
102
          // consume the event
103
          evt.preventDefault();
104
@@ -148,7 +145,7 @@
105
    {
106
       return function(evt)
107
       {
108
-         if (!p2j.screen.canProcessOsEvent(evt))
109
+         if (!p2j.screen.canProcessOsEvent(evt, win))
110
          {
111
             return;
112
          }
113
@@ -490,7 +487,7 @@
114
          }
115
          var mThis = win.mouseHandler;
116
          
117
-         if (mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt))
118
+         if (mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt, win))
119
          {
120
             return;
121
          }
122
@@ -657,7 +654,7 @@
123
          if (mThis.dragOwner != win.id ||
124
              !win.resizeable           ||
125
              !mThis.mouseDrag          ||
126
-             !p2j.screen.canProcessOsEvent(evt))
127
+             !p2j.screen.canProcessOsEvent(evt, win))
128
          {
129
             return;
130
          }
131
@@ -854,7 +851,7 @@
132
    {
133
       return function(evt)
134
       {
135
-         if (!mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt))
136
+         if (!mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt, win))
137
          {
138
             return;
139
          }
140
@@ -898,7 +895,7 @@
141
       {
142
          // only left button can trigger move
143
          if (evt.which != 1                     || 
144
-             !p2j.screen.canProcessOsEvent(evt) || 
145
+             !p2j.screen.canProcessOsEvent(evt, win) || 
146
              !win.canProcessWidget(wid, evt, mouseOp))
147
          {
148
             return;
149
@@ -935,7 +932,7 @@
150
    {
151
       return function(evt)
152
       {
153
-         if (mThis.dragOwner != wid || !mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt))
154
+         if (mThis.dragOwner != wid || !mThis.mouseDrag || !p2j.screen.canProcessOsEvent(evt, win))
155
          {
156
             return;
157
          }
158
@@ -994,7 +991,7 @@
159
 
160
       return function(evt)
161
       {
162
-         if (evt.which != 1 || !p2j.screen.canProcessOsEvent(evt))
163
+         if (evt.which != 1 || !p2j.screen.canProcessOsEvent(evt, win))
164
          {
165
             return;
166
          }
167
@@ -1194,7 +1191,7 @@
168
 
169
       return function(evt)
170
       {
171
-         if (evt.which != btnId || !p2j.screen.canProcessOsEvent(evt))
172
+         if (evt.which != btnId || !p2j.screen.canProcessOsEvent(evt, win))
173
          {
174
             return;
175
          }
176

    
177
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
178
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-10-24 19:51:34 +0000
179
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-10-25 20:59:20 +0000
180
@@ -48,9 +48,6 @@
181
    /** Flag indicating if the screen should send mouse events to the client-side. */
182
    me.processMouse = false;
183
 
184
-   /** Flag indicating if the screen should send OS events to the client-side. */
185
-   me.processOsEvents = false;
186
-   
187
    /** PaintPrimitives to ordinal mappings. Change this to match Java PaintPrimitives changes! */
188
    var ops = 
189
    {
190
@@ -202,6 +199,12 @@
191
       this.canvasRenderer = new CanvasRenderer(this.canvas, this.ctx, strokesManager,
192
              p2j.fonts, p2j.logger);
193
       
194
+      /** 
195
+        * Flag indicating if the window should send OS events to the client-side. The default value
196
+        * for new created window must be true due to modal windows application logic.
197
+        */
198
+      this.processOsEvents = true;
199
+
200
       /**
201
         * List of widgets which are aware of mouse events. They are in z-order, with the top-most
202
         * widgets having a having a lower index than the bottomost widgets.  This provides a 
203
@@ -372,7 +375,7 @@
204
             wThis.sendMouseEvent(evt, mousePos, wThis, opCode);
205
          }
206
          
207
-         if (!me.canProcessOsEvent(evt))
208
+         if (!me.canProcessOsEvent(evt, wThis))
209
          {
210
             return;
211
          }
212
@@ -629,6 +632,16 @@
213
    };
214
    
215
    /**
216
+    * Enables/disables the OS events for this window.
217
+    * 
218
+    * @param    {Boolean} capture
219
+    *           When <code>true</code>, it will process OS events like window close/iconify/etc.
220
+    */
221
+   Window.prototype.enableOsEvents = function(capture)
222
+   {
223
+      this.processOsEvents = capture;
224
+   };
225
+   /**
226
     * Draw the given list of operations in the canvas.
227
     *
228
     * @param    {byte[]} message
229
@@ -1461,14 +1474,16 @@
230
     * Determine if the specified event can be processed.  If the OS events or the mouse events are
231
     * disabled, return false.  Also, return false if the event is consumed.
232
     *
233
-    * @param   {MouseEvent} evt
234
-    *          The event details.
235
+    * @param    {MouseEvent} evt
236
+    *           The event details.
237
+    * @param    {Window} win
238
+    *           The window object.
239
     *
240
-    * @return  <code>true</code> if the event can be processed.
241
+    * @return   <code>true</code> if the event can be processed.
242
     */
243
-   me.canProcessOsEvent = function(evt)
244
+   me.canProcessOsEvent = function(evt, win)
245
    {
246
-      return me.processOsEvents && me.processMouse && !evt.defaultPrevented;
247
+      return win.processOsEvents && me.processMouse && !evt.defaultPrevented;
248
    }
249
    
250
    /**
251
@@ -1868,12 +1883,15 @@
252
    /**
253
     * Disable or enable OS event processing.
254
     *
255
-    * @param   {boolean} capture
256
-    *          When <code>true</code>, it will process OS events like window close/iconify/etc.
257
+    * @param    {Number} wid
258
+    *           The target window for which OS event processing should be enabled or disabled.
259
+    * @param    {Boolean} capture
260
+    *           When <code>true</code>, it will process OS events like window close/iconify/etc.
261
     */
262
-   me.enableOsEvents = function(capture)
263
+   me.enableOsEvents = function(wid, capture)
264
    {
265
-      me.processOsEvents = capture;
266
+      var win = getWindow(wid);
267
+      win.enableOsEvents(capture);
268
    }
269
    
270
    /**
271
@@ -1919,9 +1937,6 @@
272
       // disable mouse events
273
       me.captureMouseEvents(false);
274
       
275
-      // enable all OS events
276
-      me.enableOsEvents(true);
277
-      
278
       desktop = new VirtualDesktop(
279
             sendWindowStateActive,
280
             [174, 174, 174],
281