Project

General

Profile

2954a_1.txt

Sergey Ivanovskiy, 03/18/2016 09:44 AM

Download (8.48 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/chui/ThinClient.java'
2
--- src/com/goldencode/p2j/ui/chui/ThinClient.java	2016-03-04 13:31:54 +0000
3
+++ src/com/goldencode/p2j/ui/chui/ThinClient.java	2016-03-18 13:32:53 +0000
4
@@ -3091,7 +3091,7 @@
5
     */
6
    public synchronized void refreshHover()
7
    {
8
-      Window wnd = WindowManager.getActiveWindow();
9
+      TopLevelWindow wnd = WindowManager.getActiveWindow();
10
       if (recentlyHovered != null && recentlyHovered.windowId() == wnd.getId().asInt())
11
       {
12
          recentlyHovered.updateCursor();
13
@@ -19018,7 +19018,7 @@
14
             independentEventDrawingBracket(activeDropDown, activeDropDown.deactivateCode());
15
          }
16
          
17
-         Window wnd = WindowManager.getActiveWindow();
18
+         TopLevelWindow wnd = WindowManager.getActiveWindow();
19
          if (wnd != null)
20
          {
21
             try
22

    
23
=== modified file 'src/com/goldencode/p2j/ui/client/TopLevelWindow.java'
24
--- src/com/goldencode/p2j/ui/client/TopLevelWindow.java	2016-03-04 13:51:02 +0000
25
+++ src/com/goldencode/p2j/ui/client/TopLevelWindow.java	2016-03-18 13:32:53 +0000
26
@@ -726,64 +726,80 @@
27
                WindowManager.setActiveWindow(tlw);
28
             }
29
          }
30
-         else if ((oldActive != this && !(oldActive != null && oldActive.isOverlay())) ||
31
-                  activated.withNativeWindow())
32
+         else 
33
          {
34
-            // the ACTIVE-WINDOW handle is updated before the LEAVE/ENTRY events are sent
35
-            // if LEAVE event returns NO-APPLY, ENTRY is no longer sent
36
-            
37
-            TopLevelWindow<?> owner = getOwner();
38
-            if (owner != null)
39
-            {
40
-               // this is a window connected to an owner, move the owner to top 
41
-               WindowManager.moveToTop(owner);
42
-               
43
-               // and also all the other dialogs owned by the owner, make sure 
44
-               // the z-order is preserved
45
-               int oId = owner.getId().asInt();
46
-               WindowManager.getModalsOwnedBy(oId, true).stream()
47
-                  .forEach(w -> WindowManager.moveToTop(w));
48
-               
49
-               // and finally move us to top
50
-               WindowManager.moveToTop(this);
51
-            }
52
-            else
53
-            {
54
-               // this is a main window, move us to top
55
-               WindowManager.moveToTop(this);
56
-               
57
-               // move to top the modal windows owned by this window, preserve z-order 
58
-               WindowManager.getModalsOwnedBy(getId().asInt(), true).stream()
59
-                  .forEach(w -> WindowManager.moveToTop(w));
60
-            }
61
-            
62
-            // the active-window handle is set BEFORE executing the LEAVE/ENTRY triggers
63
-            WindowManager.setActiveWindow(owner != null ? owner : this);
64
+            boolean oldNotOverlay = !(oldActive != null && oldActive.isOverlay());
65
+            boolean needRebuildZorder = (oldActive != this && oldNotOverlay) ||
66
+                                        activated.withNativeWindow();
67
+            if (needRebuildZorder)
68
+            {
69
+               // the ACTIVE-WINDOW handle is updated before the LEAVE/ENTRY events are sent
70
+               // if LEAVE event returns NO-APPLY, ENTRY is no longer sent
71
+               
72
+               TopLevelWindow<?> owner = getOwner();
73
+               if (owner != null)
74
+               {
75
+                  // this is a window connected to an owner, move the owner to top 
76
+                  WindowManager.moveToTop(owner);
77
+                  
78
+                  // and also all the other dialogs owned by the owner, make sure 
79
+                  // the z-order is preserved
80
+                  int oId = owner.getId().asInt();
81
+                  WindowManager.getModalsOwnedBy(oId, true).stream()
82
+                     .forEach(w -> WindowManager.moveToTop(w));
83
+                  
84
+                  // and finally move us to top
85
+                  WindowManager.moveToTop(this);
86
+               }
87
+               else
88
+               {
89
+                  // this is a main window, move us to top
90
+                  WindowManager.moveToTop(this);
91
+                  
92
+                  // move to top the modal windows owned by this window, preserve z-order 
93
+                  WindowManager.getModalsOwnedBy(getId().asInt(), true).stream()
94
+                     .forEach(w -> WindowManager.moveToTop(w));
95
+               }
96
+               
97
+               // the active-window handle is set BEFORE executing the LEAVE/ENTRY triggers
98
+               WindowManager.setActiveWindow(owner != null ? owner : this);
99
+            }
100
+            else if (!isOverlay())
101
+            {
102
+               WindowManager.setActiveWindow(this);
103
+            }
104
             
105
             // do not use the top-level window here as it may not be the active one
106
             // (consider the TOP-ONLY attribute)
107
             TopLevelWindow<?> actualActive = WindowManager.getActiveWindow();
108
             
109
-            if (oldActive != actualActive)
110
+            if (needRebuildZorder || !isOverlay())
111
             {
112
                final boolean[] entry = new boolean[1];
113
-               // send leave, only if prev focus was within P2J
114
-               ThinClient.getInstance().independentEventDrawingBracket(oldActive, new Runnable()
115
+               if (oldActive != actualActive)
116
                {
117
-                  @Override
118
-                  public void run()
119
+                  // send leave, only if prev focus was within P2J
120
+                  ThinClient.getInstance().independentEventDrawingBracket(oldActive, new Runnable()
121
                   {
122
-                     // old top receives LEAVE event
123
-                     entry[0] = activated.withNativeWindow() || 
124
-                                ThinClient.getInstance().sendLeave(oldActive);
125
-                     EventManager.postEvent(new FocusEvent(oldActive, EventType.FOCUS_LOST));
126
-                     oldActive.repaint();
127
-                     if (oldActive.currentFocus() != null)
128
+                     @Override
129
+                     public void run()
130
                      {
131
-                        oldActive.currentFocus().repaint();
132
+                        // old top receives LEAVE event
133
+                        entry[0] = activated.withNativeWindow() || 
134
+                                   ThinClient.getInstance().sendLeave(oldActive);
135
+                        EventManager.postEvent(new FocusEvent(oldActive, EventType.FOCUS_LOST));
136
+                        oldActive.repaint();
137
+                        if (oldActive.currentFocus() != null)
138
+                        {
139
+                           oldActive.currentFocus().repaint();
140
+                        }
141
                      }
142
-                  }
143
-               });
144
+                  });
145
+               }
146
+               else
147
+               {
148
+                  entry[0] = true;
149
+               }
150
                
151
                if (entry[0])
152
                {
153
@@ -796,10 +812,7 @@
154
                   }
155
                }
156
             }
157
-         }
158
-         else if (!isOverlay())
159
-         {
160
-            WindowManager.setActiveWindow(this);
161
+            
162
          }
163
 
164
          // title repaint should be done after activation change
165

    
166
=== modified file 'src/com/goldencode/p2j/ui/client/WindowManager.java'
167
--- src/com/goldencode/p2j/ui/client/WindowManager.java	2016-03-04 13:51:02 +0000
168
+++ src/com/goldencode/p2j/ui/client/WindowManager.java	2016-03-18 13:36:48 +0000
169
@@ -325,6 +325,12 @@
170
          throw new NullPointerException("The window can not be null!");
171
       }
172
       
173
+      if (!window.isRealized())
174
+      {
175
+         // window is derigistered
176
+         return;
177
+      }
178
+      
179
       // move window to top
180
       WorkArea wa = work.get();
181
       synchronized (wa.windows)
182
@@ -514,13 +520,13 @@
183
     * @return   See above.
184
     */
185
    @SuppressWarnings("unchecked")
186
-   public static <O extends OutputManager<?>> Window<O> getActiveWindow()
187
+   public static <O extends OutputManager<?>> TopLevelWindow<O> getActiveWindow()
188
    {
189
       TopLevelWindow<O> active = (TopLevelWindow<O>) activeWnd.get();
190
       
191
       // if the top-level active window is not the main window, return its
192
       // main window owner
193
-      return active == null ? null : active.window();
194
+      return active == null ? null : active;
195
    }
196
 
197
    /**
198
@@ -531,7 +537,7 @@
199
     */
200
    public static void setActiveWindow(TopLevelWindow<?> window)
201
    {
202
-      // overlay window can not be cinsidered as active one
203
+      // overlay window can not be considered as active one
204
       if (window != null && window.isOverlay())
205
       {
206
          return;
207