Project

General

Profile

2956_window_events_5.txt

Sergey Ivanovskiy, 02/03/2016 04:37 PM

Download (9.01 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/chui/driver/web/ChuiWebSimulator.java'
2
--- src/com/goldencode/p2j/ui/client/chui/driver/web/ChuiWebSimulator.java	2016-02-02 05:54:01 +0000
3
+++ src/com/goldencode/p2j/ui/client/chui/driver/web/ChuiWebSimulator.java	2016-02-03 21:18:40 +0000
4
@@ -229,9 +229,13 @@
5
     *           The window ID.
6
     * @param    state
7
     *           True if the window has been activated, otherwise false.
8
+    * @param    focusOut
9
+    *           The true value indicates that the current focus is moved from a non P2J window to
10
+    *           a P2J window for an activation event or from a P2j window to a non P2j window
11
+    *           for a deactivation event.
12
     */
13
    @Override
14
-   public void windowActivated(int windowId, boolean state)
15
+   public void windowActivated(int windowId, boolean state, boolean focusOut)
16
    {
17
       // no-op
18
    }
19

    
20
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/ClientProtocolHooks.java'
21
--- src/com/goldencode/p2j/ui/client/driver/web/ClientProtocolHooks.java	2016-02-02 05:54:01 +0000
22
+++ src/com/goldencode/p2j/ui/client/driver/web/ClientProtocolHooks.java	2016-02-03 21:18:40 +0000
23
@@ -106,8 +106,12 @@
24
     *           The window ID.
25
     * @param    state
26
     *           The boolean flag indicating that the target window has been activated or inactive.
27
+    * @param    focusOut
28
+    *           The true value indicates that the current focus is moved from a non P2J window to
29
+    *           a P2J window for an activation event or from a P2j window to a non P2j window
30
+    *           for a deactivation event.
31
     */
32
-   public void windowActivated(int windowId, boolean state);
33
+   public void windowActivated(int windowId, boolean state, boolean focusOut);
34
 
35
    /**
36
     * Raise an event as the window was (de)iconified.
37

    
38
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js'
39
--- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js	2016-02-03 11:21:56 +0000
40
+++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js	2016-02-03 21:18:40 +0000
41
@@ -104,11 +104,15 @@
42
     *           The target window id
43
     * @param    {Boolean} active
44
     *           The flag indicating that the target window should be active or not.
45
+    * @param    {Boolean} focusOut
46
+    *           The true value indicates that the current focus is moved from a non P2J window to
47
+    *           a P2J window for an activation event or from a P2j window to a non P2j window
48
+    *           for a deactivation event.
49
     */
50
-   me.sendWindowActive = function(wid, active)
51
+   me.sendWindowActive = function(wid, active, focusOut)
52
    {
53
-      // send the window activation to the java side
54
-      var msg = new Uint8Array(6);
55
+      // send the window activation/deactivation to the java side
56
+      var msg = new Uint8Array(7);
57
       
58
       // message type
59
       msg[0] = 0x0f;
60
@@ -116,7 +120,8 @@
61
       // 1. the window ID
62
       me.writeInt32BinaryMessage(msg, 1, wid);
63
       
64
-      msg[5] = active ? 1 : 0;
65
+      msg[5] = active   ? 1 : 0;
66
+      msg[6] = focusOut ? 1 : 0;
67
       
68
       // send the window active event
69
       me.send(msg);
70

    
71
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java'
72
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java	2016-02-02 19:15:56 +0000
73
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java	2016-02-03 21:18:40 +0000
74
@@ -587,7 +587,7 @@
75
       if (focus)
76
       {
77
          // activate the window and notify the upper layers
78
-         windowActivated(windowId, true);
79
+         windowActivated(windowId, true, false);
80
       }
81
    }
82
    
83
@@ -891,41 +891,37 @@
84
     *           The window ID.
85
     * @param    state
86
     *           True if the window has been activated, otherwise false.
87
+    * @param    focusOut
88
+    *           The true value indicates that the current focus is moved from a non P2J window to
89
+    *           a P2J window for an activation event or from a P2j window to a non P2j window
90
+    *           for a deactivation event.
91
     */
92
    @Override
93
-   public void windowActivated(int windowId, boolean state)
94
+   public void windowActivated(int windowId, boolean state, boolean focusOut)
95
    {
96
       // resolve window object
97
       TopLevelWindow<?> window = (TopLevelWindow<?>) WindowManager.findWindow(windowId);
98
       
99
       // this protects from activation already active window
100
       // it become important when overlay window is on screen
101
-      // in this case double activation will incorrectly dismiss overaly
102
+      // in this case double activation will incorrectly dismiss overlay
103
       TopLevelWindow<?> currActiveWindow = WindowManager.getActiveWindow();
104
-      TopLevelWindow<?> currFocusWindow = WindowManager.getFocusWindow();
105
       // check if overlay window exists
106
       OverlayWindow ow = WindowManager.findOverlayWindow();
107
       
108
       // we do not need to activate already active window is there is no overlay on the screen
109
-      if (state && window == currActiveWindow && ow == null && currFocusWindow == currActiveWindow)
110
+      if (state && WindowManager.isWindowActive(window) && ow == null)
111
       {
112
          return;
113
       }
114
 
115
       // if overlay window exists and not a target of activation - remove it first
116
-      if (ow != null && ow != window && state)
117
+      if (state && ow != null && ow != window)
118
       {
119
          ThinClient.getInstance().postOSEvent(new WindowActivated(ow, false, false));
120
       }
121
-      if (window == currFocusWindow && !state)
122
-      {
123
-         WindowManager.removeFocusWindow();
124
-      }
125
-      if (state)
126
-      {
127
-         WindowManager.setFocusWindow(window);
128
-      }
129
-      ThinClient.getInstance().postOSEvent(new WindowActivated(window, state, false));
130
+      
131
+      ThinClient.getInstance().postOSEvent(new WindowActivated(window, state, focusOut));
132
    }
133
 
134
    /**
135

    
136
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
137
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2016-02-03 11:21:56 +0000
138
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2016-02-03 21:18:40 +0000
139
@@ -1282,16 +1282,16 @@
140
          
141
          handled = true;
142
       }
143
-      else if (length == 6 && message[offset] == MSG_WINDOW_ACTIVATED)
144
+      else if (length == 7 && message[offset] == MSG_WINDOW_ACTIVATED)
145
       {
146
          int idx = offset + 1;
147
          
148
          int windowId = readMessageInt32(message, idx);
149
-         idx = idx + 4;
150
-         
151
-         boolean state = message[idx] == 1;
152
-         
153
-         this.callbacks.windowActivated(windowId, state);
154
+         
155
+         boolean state    = message[idx + 4] == 1;
156
+         boolean focusOut = message[idx + 5] == 1;
157
+         
158
+         this.callbacks.windowActivated(windowId, state, focusOut);
159
       }
160
       else if (length == 6 && message[offset] == MSG_WINDOW_ICONIFY)
161
       {
162

    
163
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js'
164
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-02-02 05:54:01 +0000
165
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-02-03 21:18:40 +0000
166
@@ -117,12 +117,12 @@
167
          
168
          if (topWindowId)
169
          {
170
-            p2j.socket.sendWindowActive(topWindowId, false);
171
+            p2j.socket.sendWindowActive(topWindowId, false, false);
172
          }
173
          // move the window to top
174
          win.moveToTop();
175
          
176
-         p2j.socket.sendWindowActive(win.id, true);
177
+         p2j.socket.sendWindowActive(win.id, true, false);
178
          
179
          // consume the event
180
          evt.preventDefault();
181

    
182
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
183
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-02-03 11:21:56 +0000
184
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-02-03 21:18:40 +0000
185
@@ -1638,12 +1638,13 @@
186
     */
187
    function activateTopVisibleWindow(id)
188
    {
189
-      p2j.socket.sendWindowActive(id, false);
190
       var topWindow = findTopVisibleWindow(id);
191
+      var focusOut = !(topWindow);
192
+      p2j.socket.sendWindowActive(id, false, focusOut);
193
       if (topWindow)
194
       {
195
          topWindow.moveToTop();
196
-         p2j.socket.sendWindowActive(topWindow.id, true);
197
+         p2j.socket.sendWindowActive(topWindow.id, true, false);
198
       }
199
    }
200
 
201
@@ -2409,11 +2410,12 @@
202
     */
203
    function sendWindowStateActive(windowId)
204
    {
205
-      var topWindowId = p2j.screen.topWindowId();
206
-      if (topWindowId && topWindowId !== windowId)
207
+      var topWindow = findTopVisibleWindow(windowId);
208
+      if (topWindow)
209
       {
210
-         p2j.socket.sendWindowActive(topWindowId, false);
211
+         p2j.socket.sendWindowActive(topWindow.id, false, false);
212
       }
213
+      var focusOut = !(topWindow);
214
       var win = getWindow(windowId);
215
       if (!win.isVisible())
216
       {
217
@@ -2423,7 +2425,7 @@
218
       win.deiconify();
219
       
220
       // send the window activation to the java side
221
-      p2j.socket.sendWindowActive(windowId, true);
222
+      p2j.socket.sendWindowActive(windowId, true, focusOut);
223
    }
224
 
225
    /**
226