Project

General

Profile

2956_window_events_1.txt

Sergey Ivanovskiy, 01/31/2016 12:16 PM

Download (4.39 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	2016-01-29 15:50:34 +0000
3
+++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js	2016-01-31 16:54:35 +0000
4
@@ -95,7 +95,53 @@
5
       
6
       me.send(msg);
7
    };
8
-
9
+   
10
+   /**
11
+    * Sends the window active event to the server.
12
+    * 
13
+    * @param    {Number} wid
14
+    *           The target window id
15
+    */
16
+   me.sendWindowActive = function(wid)
17
+   {
18
+      // send the window activation to the java side
19
+      var msg = new Uint8Array(5);
20
+      
21
+      // message type
22
+      msg[0] = 0x0f;
23
+      
24
+      // 1. the window ID
25
+      me.writeInt32BinaryMessage(msg, 1, wid);
26
+      
27
+      // send the window active event
28
+      me.send(msg);
29
+   }
30
+   
31
+   /**
32
+    * Sends the window icon state event to the server.
33
+    * 
34
+    * @param    {Number} wid
35
+    *           The target window id.
36
+    * @param    {Boolean} minimized
37
+    *           The target window has been minimized.
38
+    */
39
+   me.sendWindowIconState = function(wid, minimized)
40
+   {
41
+      var msg = new Uint8Array(6);
42
+      
43
+      // message type
44
+      msg[0] = 0x10;
45
+      
46
+      // 0. the window ID
47
+      me.writeInt32BinaryMessage(msg, 1, wid);
48
+      
49
+      // 1. the iconification state
50
+      msg[5] = minimized ? 1 : 0;
51
+      
52
+      // send the mouse event
53
+      me.send(msg);
54
+   }
55
+   
56
    /**
57
     * Send a binary message with the given message type and the specified byte array serialized.
58
     *
59

    
60
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js'
61
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-01-04 08:14:16 +0000
62
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-01-31 16:14:34 +0000
63
@@ -115,20 +115,7 @@
64
          // move the window to top
65
          win.moveToTop();
66
          
67
-         // send the window activation to the java side
68
-         var message = new Uint8Array(5);
69
-         var offset = 0;
70
-         
71
-         // message type
72
-         message[0] = 0x0f;
73
-         offset = offset + 1;
74
-         
75
-         // 1. the window ID
76
-         p2j.socket.writeInt32BinaryMessage(message, offset, win.id);
77
-         offset = offset + 4;
78
-
79
-         // send the mouse event
80
-         p2j.socket.send(message);
81
+         p2j.socket.sendWindowActive(win.id);
82
          
83
          // consume the event
84
          evt.preventDefault();
85
@@ -1086,25 +1073,8 @@
86
    function windowIconifyCallback(win, evt, mousePos, opCode)
87
    {
88
       win.iconify();
89
-
90
-      var message = new Uint8Array(6);
91
-
92
-      var offset = 0;
93
-
94
-      // message type
95
-      message[0] = 0x10;
96
-      offset = offset + 1;
97
-      
98
-      // 0. the window ID
99
-      p2j.socket.writeInt32BinaryMessage(message, offset, win.id);
100
-      offset = offset + 4;
101
-      
102
-      // 1. the iconification state
103
-      message[offset] = 1;
104
-      offset = offset + 1;
105
-      
106
-      // send the mouse event
107
-      p2j.socket.send(message);
108
+      
109
+      p2j.socket.sendWindowIconState(win.id, true);
110
    };
111
 
112
    this.getEvents = function()
113

    
114
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
115
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-01-29 15:50:34 +0000
116
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-01-31 16:53:08 +0000
117
@@ -1594,6 +1594,7 @@
118
       if (topWindow)
119
       {
120
          topWindow.moveToTop();
121
+         p2j.socket.sendWindowActive(topWindow.id);
122
       }
123
    }
124
 
125
@@ -2325,23 +2326,21 @@
126
    };
127
    
128
    /**
129
-    * Sends the active window state to the server.
130
+    * Notifies the server that the target window should be active and restores its state
131
+    * if the target window has been minimized before.
132
     * 
133
     * @param    {Number} windowId
134
     *           The target windowId
135
     */
136
    function sendWindowStateActive(windowId)
137
    {
138
-      var message = new Uint8Array(6);
139
-
140
-      message[0] = 0x10;
141
-      p2j.socket.writeInt32BinaryMessage(message, 1, windowId);
142
-      // 1. the iconification state
143
-      message[5] = 0;
144
-      p2j.socket.send(message);
145
-      
146
+      p2j.socket.sendWindowActive(windowId);
147
+      var win = getWindow(windowId);
148
+      if (!win.isVisible())
149
+      {
150
+         p2j.socket.sendWindowIconState(windowId, false);
151
+      }
152
       // de-iconify the window
153
-      var win = getWindow(windowId);
154
       win.deiconify();
155
    }
156
 
157