Project

General

Profile

2966a_err.txt

Vadim Gindin, 11/02/2016 01:19 PM

Download (7.56 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/WindowManager.java'
2
--- src/com/goldencode/p2j/ui/client/WindowManager.java	2016-09-26 10:00:26 +0000
3
+++ src/com/goldencode/p2j/ui/client/WindowManager.java	2016-11-02 17:13:28 +0000
4
@@ -77,6 +77,11 @@
5
 ** 040 HC  20160712 Prevented an NPE when last DIALOG-BOX closed.
6
 ** 041 SBI 20160811 The alert box owner should be CURRENT-WINDOW.
7
 ** 042 HC  20160926 Removed disabling of window input events during server processing.
8
+** 043 HC  20160825 Fixed window activation when window A being deactivated and B being
9
+**                  activated while A and B having the same parent window with shared actvation
10
+**                  state.
11
+**                  Window activation events coming from GUI drivers are dispatched on the
12
+**                  event queue to ensure correct event ordering.
13
 */
14
 
15
 package com.goldencode.p2j.ui.client;
16
@@ -1100,6 +1105,58 @@
17
    }
18
    
19
    /**
20
+    * Enable OS events for the specified windows. Note that
21
+    * the method will not enable OS events for windows silenced
22
+    * due to an active modal window.
23
+    * <p>
24
+    * This method can only be called in GUI mode.   
25
+    * 
26
+    * @param    windowIds
27
+    *           The window IDs which need to be processed.
28
+    */
29
+   public static void enableOSEvents(int[] windowIds)
30
+   {
31
+      WorkArea wa = work.get();
32
+      
33
+      List<Integer> toEnable = new LinkedList<>();
34
+      for (int id : windowIds)
35
+      {
36
+         toEnable.add(id);
37
+      }
38
+      
39
+      // do not enable events for silenced windows
40
+      for (TopLevelWindow<?> wnd : wa.silencedWindows)
41
+      {
42
+         toEnable.remove(new Integer(wnd.getId().asInt()));
43
+      }
44
+      
45
+      if (toEnable.isEmpty())
46
+      {
47
+         return;
48
+      }
49
+      
50
+      GuiDriver<?, ?> driver = (GuiDriver<?, ?>) OutputManager.getDriver();
51
+      
52
+      int[] enableArray = Utils.integerCollectionToPrimitive(toEnable);
53
+      
54
+      driver.enableEvents(enableArray, true);
55
+   }
56
+   
57
+   /**
58
+    * Disable OS events for the specified windows.  
59
+    * <p>
60
+    * This method can only be called in GUI mode.   
61
+    * 
62
+    * @param    windowIds
63
+    *           The window IDs which need to be processed.
64
+    */
65
+   public static void disableOSEvents(int[] windowIds)
66
+   {
67
+      GuiDriver<?, ?> driver = (GuiDriver<?, ?>) OutputManager.getDriver();
68
+      driver.enableEvents(windowIds, false);
69
+   }
70
+   
71
+   /**
72
     * Turn the passed-in window into a modal window. The method
73
     * disables event input for all application top-level windows
74
     * except the passed-in window.
75
@@ -1279,8 +1336,10 @@
76
    }
77
    
78
    /**
79
-    * Called by the UI subsystem (GUI driver for example) when a top-leve window 
80
+    * Called by the UI subsystem (GUI driver for example) when a top-level window
81
     * is activated.
82
+    * The method logic is pushed on the OS event queue and carried out later,
83
+    * this ensures a correct event ordering.
84
     * <p>
85
     * For more information of the concept of active windows, see 
86
     * {@link #forEachActiveWindow(TopLevelWindow, Predicate)}.
87
@@ -1292,26 +1351,31 @@
88
     */
89
    public static void windowActivated(int windowId, boolean fromNativeWindow)
90
    {
91
-      TopLevelWindow<?> window = WindowManager.findWindow(windowId); 
92
-      if (window == null)
93
-      {
94
-         // when window is hidden/destroyed, the de-activation event from
95
-         // the driver may arrive after the window is unregistered from 
96
-         // WindowManager, so just ignore this
97
-         return;
98
-      }
99
-      
100
-      if (window == activeDriverWindow.get())
101
-      {
102
-         // for now ignore activation of already activated window 
103
-         return;
104
-      }
105
-      
106
-      processWindowActivated(window, fromNativeWindow);
107
+      ThinClient.getInstance().invokeLater(() ->
108
+      {
109
+         TopLevelWindow<?> window = WindowManager.findWindow(windowId);
110
+         if (window == null)
111
+         {
112
+            // when window is hidden/destroyed, the de-activation event from
113
+            // the driver may arrive after the window is unregistered from
114
+            // WindowManager, so just ignore this
115
+            return;
116
+         }
117
+
118
+         if (window == activeDriverWindow.get())
119
+         {
120
+            // for now ignore activation of already activated window
121
+            return;
122
+         }
123
+
124
+         processWindowActivated(window, fromNativeWindow);
125
+      });
126
    }
127
    
128
    /**
129
     * Called by the driver when a top-leve window is deactivated.
130
+    * The method logic is pushed on the OS event queue and carried out later,
131
+    * this ensures a correct event ordering.
132
     * <p>
133
     * For more information of the concept of active windows, see 
134
     * {@link #forEachActiveWindow(TopLevelWindow, Predicate)}.
135
@@ -1323,25 +1387,28 @@
136
     */
137
    public static void windowDeactivated(int windowId, boolean toNativeWindow)
138
    {
139
-      TopLevelWindow<?> deactivatedWindow = WindowManager.findWindow(windowId); 
140
-      if (deactivatedWindow == null)
141
-      {
142
-         // the window being deactivated may be already gone, for example
143
-         // when window is hidden and destroyed right after
144
-         return;
145
-      }
146
-      
147
-      if (activeDriverWindow.get() != deactivatedWindow)
148
-      {
149
-         throw new RuntimeException(
150
-                  "GUI driver sent deactivation event for window not previously activated!");
151
-      }
152
-      
153
-      // process activation of non-p2j window   
154
-      if (toNativeWindow)
155
-      {
156
-         processWindowActivated(null, true);
157
-      }
158
+      ThinClient.getInstance().invokeLater(() ->
159
+      {
160
+         TopLevelWindow<?> deactivatedWindow = WindowManager.findWindow(windowId);
161
+         if (deactivatedWindow == null)
162
+         {
163
+            // the window being deactivated may be already gone, for example
164
+            // when window is hidden and destroyed right after
165
+            return;
166
+         }
167
+
168
+         if (activeDriverWindow.get() != deactivatedWindow)
169
+         {
170
+            throw new RuntimeException(
171
+                    "GUI driver sent deactivation event for window not previously activated!");
172
+         }
173
+
174
+         // process activation of non-p2j window
175
+         if (toNativeWindow)
176
+         {
177
+            processWindowActivated(null, true);
178
+         }
179
+      });
180
    }
181
    
182
    /**
183
@@ -1479,7 +1546,15 @@
184
                // is also the new driver-active window.
185
                return false;
186
             }
187
-            
188
+
189
+            // if activating a window that shares activation state with one of the parents
190
+            // of the window being deactivated, deactivate only up to the window that
191
+            // shares activation state with the window being activated
192
+            if (activated != null && isSharedActivationState(w, activated))
193
+            {
194
+               return false;
195
+            }
196
+
197
             ThinClient.getInstance().postOSEvent(new WindowActivated(w, false, activated == null));
198
             
199
             // continue iteration
200

    
201
=== modified file 'src/com/goldencode/p2j/ui/client/widget/AbstractWidget.java'
202
--- src/com/goldencode/p2j/ui/client/widget/AbstractWidget.java	2016-10-17 19:17:48 +0000
203
+++ src/com/goldencode/p2j/ui/client/widget/AbstractWidget.java	2016-11-02 17:13:28 +0000
204
@@ -103,6 +103,7 @@
205
 **                  never have a paint event raised. 
206
 ** 057 SBI 20160914 Fixed a possible NPE.
207
 ** 058 SVL 20161014 Added clearWidget function.
208
+** 059 VIG 20160729 Fixed requestFocus for the case when ansector() returns null.
209
 */
210
 
211
 package com.goldencode.p2j.ui.client.widget;
212
@@ -2567,4 +2568,4 @@
213
          return FontManager.getTextHeight(txt, window, font, screen().getInstanceDriver());
214
       }
215
    }
216
-} 
217
\ No newline at end of file
218
+} 
219