1
|
=== modified file 'src/com/goldencode/p2j/ui/client/WindowManager.java'
|
2
|
--- src/com/goldencode/p2j/ui/client/WindowManager.java 2015-10-16 12:11:54 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/WindowManager.java 2015-10-28 14:04:06 +0000
|
4
|
@@ -310,7 +310,7 @@
|
5
|
w.hide();
|
6
|
if (w instanceof Window)
|
7
|
{
|
8
|
- removeWindow(w.getId().asInt());
|
9
|
+ remove(w);
|
10
|
}
|
11
|
else
|
12
|
{
|
13
|
|
14
|
=== modified file 'src/com/goldencode/p2j/ui/client/driver/swing/SwingKeyboardReader.java'
|
15
|
--- src/com/goldencode/p2j/ui/client/driver/swing/SwingKeyboardReader.java 2015-10-22 23:14:19 +0000
|
16
|
+++ src/com/goldencode/p2j/ui/client/driver/swing/SwingKeyboardReader.java 2015-10-29 10:26:29 +0000
|
17
|
@@ -227,7 +227,7 @@
|
18
|
* @param evt
|
19
|
* The key event.
|
20
|
*/
|
21
|
- public synchronized void keyReleased(KeyEvent evt)
|
22
|
+ public void keyReleased(KeyEvent evt)
|
23
|
{
|
24
|
}
|
25
|
|
26
|
|
27
|
=== modified file 'src/com/goldencode/p2j/ui/client/driver/swing/WinKeyboardReader.java'
|
28
|
--- src/com/goldencode/p2j/ui/client/driver/swing/WinKeyboardReader.java 2015-10-14 13:31:31 +0000
|
29
|
+++ src/com/goldencode/p2j/ui/client/driver/swing/WinKeyboardReader.java 2015-10-30 17:42:28 +0000
|
30
|
@@ -76,7 +76,7 @@
|
31
|
* @param evt
|
32
|
* The high level key event to process.
|
33
|
*/
|
34
|
- public synchronized void keyPressed(KeyEvent evt)
|
35
|
+ public void keyPressed(KeyEvent evt)
|
36
|
{
|
37
|
KeyEvent last;
|
38
|
|
39
|
@@ -167,7 +167,7 @@
|
40
|
* @param evt
|
41
|
* The high level key event to process.
|
42
|
*/
|
43
|
- public synchronized void keyTyped(KeyEvent evt)
|
44
|
+ public void keyTyped(KeyEvent evt)
|
45
|
{
|
46
|
if (evt.isConsumed())
|
47
|
{
|
48
|
@@ -282,7 +282,13 @@
|
49
|
}
|
50
|
if (code != -1)
|
51
|
{
|
52
|
- queue.add(new Integer(code));
|
53
|
+ try
|
54
|
+ {
|
55
|
+ queue.put(new Integer(code));
|
56
|
+ }
|
57
|
+ catch (InterruptedException e)
|
58
|
+ {
|
59
|
+ }
|
60
|
}
|
61
|
}
|
62
|
|
63
|
@@ -297,7 +303,7 @@
|
64
|
* @param evt
|
65
|
* The key release event.
|
66
|
*/
|
67
|
- public synchronized void keyReleased(KeyEvent evt)
|
68
|
+ public void keyReleased(KeyEvent evt)
|
69
|
{
|
70
|
int code = -1;
|
71
|
int key = evt.getKeyCode();
|
72
|
@@ -346,7 +352,13 @@
|
73
|
}
|
74
|
if (code != -1)
|
75
|
{
|
76
|
- queue.add(new Integer(code));
|
77
|
+ try
|
78
|
+ {
|
79
|
+ queue.put(new Integer(code));
|
80
|
+ }
|
81
|
+ catch (InterruptedException e)
|
82
|
+ {
|
83
|
+ }
|
84
|
}
|
85
|
}
|
86
|
|
87
|
@@ -366,7 +378,13 @@
|
88
|
if (Keyboard.keyLabel(code).length() == 0)
|
89
|
{
|
90
|
code = -1;
|
91
|
- queue.add(code);
|
92
|
+ try
|
93
|
+ {
|
94
|
+ queue.put(code);
|
95
|
+ }
|
96
|
+ catch (InterruptedException e)
|
97
|
+ {
|
98
|
+ }
|
99
|
}
|
100
|
|
101
|
return code;
|
102
|
|
103
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java'
|
104
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-10-24 19:51:34 +0000
|
105
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-10-30 17:49:32 +0000
|
106
|
@@ -85,6 +85,7 @@
|
107
|
import java.awt.Rectangle;
|
108
|
import java.awt.Window;
|
109
|
import java.awt.event.*;
|
110
|
+import java.awt.event.FocusEvent;
|
111
|
import java.awt.event.WindowEvent;
|
112
|
import java.awt.font.*;
|
113
|
import java.awt.geom.*;
|
114
|
@@ -267,7 +268,10 @@
|
115
|
if (toOS)
|
116
|
{
|
117
|
// if focus is lost to a non-4GL window, the titlebar needs to be aware of this
|
118
|
- ThinClient.getInstance().postOSEvent(new WindowActivated(window, false, toOS));
|
119
|
+ ThinClient tc = ThinClient.getInstance();
|
120
|
+ if (tc != null) {
|
121
|
+ tc.postOSEvent(new WindowActivated(window, false, toOS));
|
122
|
+ }
|
123
|
}
|
124
|
}
|
125
|
}
|
126
|
@@ -285,7 +289,11 @@
|
127
|
TopLevelWindow<?> window = (TopLevelWindow<?>) WindowManager.findWindow(windowId);
|
128
|
|
129
|
boolean fromOS = (e.getOppositeWindow() == null);
|
130
|
- ThinClient.getInstance().postOSEvent(new WindowActivated(window, true, fromOS));
|
131
|
+ ThinClient tc = ThinClient.getInstance();
|
132
|
+ if (tc != null)
|
133
|
+ {
|
134
|
+ ThinClient.getInstance().postOSEvent(new WindowActivated(window, true, fromOS));
|
135
|
+ }
|
136
|
}
|
137
|
}
|
138
|
});
|
139
|
@@ -375,37 +383,56 @@
|
140
|
@Override
|
141
|
public void quit()
|
142
|
{
|
143
|
- for (MouseListener l : pane.getMouseListeners())
|
144
|
- {
|
145
|
- pane.removeMouseListener(l);
|
146
|
- }
|
147
|
- for (MouseMotionListener l : pane.getMouseMotionListeners())
|
148
|
- {
|
149
|
- pane.removeMouseMotionListener(l);
|
150
|
- }
|
151
|
- for (MouseWheelListener l : pane.getMouseWheelListeners())
|
152
|
- {
|
153
|
- pane.removeMouseWheelListener(l);
|
154
|
- }
|
155
|
- for (WindowListener l : window.getWindowListeners())
|
156
|
- {
|
157
|
- window.removeWindowListener(l);
|
158
|
- }
|
159
|
- for (WindowFocusListener l : window.getWindowFocusListeners())
|
160
|
- {
|
161
|
- window.removeWindowFocusListener(l);
|
162
|
- }
|
163
|
- for (WindowStateListener l : window.getWindowStateListeners())
|
164
|
- {
|
165
|
- window.removeWindowStateListener(l);
|
166
|
- }
|
167
|
- for (KeyListener l : window.getKeyListeners())
|
168
|
- {
|
169
|
- window.removeKeyListener(l);
|
170
|
- }
|
171
|
-
|
172
|
- // cleanup window resources
|
173
|
- pane.quit();
|
174
|
+ try
|
175
|
+ {
|
176
|
+ SwingUtilities.invokeAndWait(new Runnable()
|
177
|
+ {
|
178
|
+
|
179
|
+ @Override
|
180
|
+ public void run()
|
181
|
+ {
|
182
|
+ for (MouseListener l : pane.getMouseListeners())
|
183
|
+ {
|
184
|
+ pane.removeMouseListener(l);
|
185
|
+ }
|
186
|
+ for (MouseMotionListener l : pane.getMouseMotionListeners())
|
187
|
+ {
|
188
|
+ pane.removeMouseMotionListener(l);
|
189
|
+ }
|
190
|
+ for (MouseWheelListener l : pane.getMouseWheelListeners())
|
191
|
+ {
|
192
|
+ pane.removeMouseWheelListener(l);
|
193
|
+ }
|
194
|
+ for (WindowListener l : window.getWindowListeners())
|
195
|
+ {
|
196
|
+ window.removeWindowListener(l);
|
197
|
+ }
|
198
|
+ for (WindowFocusListener l : window.getWindowFocusListeners())
|
199
|
+ {
|
200
|
+ window.removeWindowFocusListener(l);
|
201
|
+ }
|
202
|
+ for (WindowStateListener l : window.getWindowStateListeners())
|
203
|
+ {
|
204
|
+ window.removeWindowStateListener(l);
|
205
|
+ }
|
206
|
+ for (KeyListener l : window.getKeyListeners())
|
207
|
+ {
|
208
|
+ window.removeKeyListener(l);
|
209
|
+ }
|
210
|
+
|
211
|
+ // cleanup window resources
|
212
|
+ pane.quit();
|
213
|
+ }
|
214
|
+ });
|
215
|
+ }
|
216
|
+ catch (InvocationTargetException e)
|
217
|
+ {
|
218
|
+ e.printStackTrace();
|
219
|
+ }
|
220
|
+ catch (InterruptedException e)
|
221
|
+ {
|
222
|
+ e.printStackTrace();
|
223
|
+ }
|
224
|
}
|
225
|
|
226
|
/**
|
227
|
@@ -433,7 +460,28 @@
|
228
|
{
|
229
|
window.pack();
|
230
|
window.setVisible(visible);
|
231
|
- }
|
232
|
+
|
233
|
+ /** To work around if the current active window is null to get the keys input for it */
|
234
|
+ if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow() == null
|
235
|
+ || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() == null
|
236
|
+ || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == null)
|
237
|
+ {
|
238
|
+ SwingUtilities.invokeLater(new Runnable()
|
239
|
+ {
|
240
|
+
|
241
|
+ @Override
|
242
|
+ public void run()
|
243
|
+ {
|
244
|
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
|
245
|
+ new WindowEvent(window, WindowEvent.WINDOW_ACTIVATED));
|
246
|
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
|
247
|
+ new FocusEvent(window, FocusEvent.FOCUS_GAINED));
|
248
|
+ window.requestFocus();
|
249
|
+ }
|
250
|
+
|
251
|
+ });
|
252
|
+ }
|
253
|
+ }
|
254
|
});
|
255
|
}
|
256
|
|
257
|
@@ -593,6 +641,24 @@
|
258
|
@Override
|
259
|
public void enableEvents(boolean capture)
|
260
|
{
|
261
|
+ SwingUtilities.invokeLater(new Runnable(){
|
262
|
+
|
263
|
+ @Override
|
264
|
+ public void run()
|
265
|
+ {
|
266
|
+ enableListeners(capture);
|
267
|
+ }
|
268
|
+ });
|
269
|
+ }
|
270
|
+
|
271
|
+ /**
|
272
|
+ * Attaches or detaches the window listeners depending on the input capture flag.
|
273
|
+ *
|
274
|
+ * @param capture
|
275
|
+ * True indicates the mouses and keys listeners are attached to this window.
|
276
|
+ */
|
277
|
+ private void enableListeners(boolean capture)
|
278
|
+ {
|
279
|
if (capture)
|
280
|
{
|
281
|
if (savedListeners == null)
|
282
|
|