author | ohair |
Wed, 06 Apr 2011 22:06:11 -0700 | |
changeset 9035 | 1255eb81cc2f |
parent 8515 | f1c29dfb4f6a |
child 10902 | a76a2350fe7b |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9035
1255eb81cc2f
7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents:
8515
diff
changeset
|
2 |
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
1954 | 26 |
#include "awt.h" |
2 | 27 |
|
2451 | 28 |
#include <jlong.h> |
29 |
||
2 | 30 |
#include "awt_Component.h" |
31 |
#include "awt_Container.h" |
|
32 |
#include "awt_Frame.h" |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
33 |
#include "awt_Dialog.h" |
2 | 34 |
#include "awt_Insets.h" |
35 |
#include "awt_Panel.h" |
|
36 |
#include "awt_Toolkit.h" |
|
37 |
#include "awt_Window.h" |
|
38 |
#include "awt_Win32GraphicsDevice.h" |
|
39 |
#include "awt_BitmapUtil.h" |
|
40 |
#include "awt_IconCursor.h" |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
41 |
#include "ComCtl32Util.h" |
2 | 42 |
|
43 |
#include "java_awt_Insets.h" |
|
44 |
#include <java_awt_Container.h> |
|
45 |
#include <java_awt_event_ComponentEvent.h> |
|
46 |
#include "sun_awt_windows_WCanvasPeer.h" |
|
47 |
||
1954 | 48 |
#include <windowsx.h> |
49 |
||
2 | 50 |
#if !defined(__int3264) |
51 |
typedef __int32 LONG_PTR; |
|
52 |
#endif // __int3264 |
|
53 |
||
54 |
// Used for Swing's Menu/Tooltip animation Support |
|
55 |
const int UNSPECIFIED = 0; |
|
56 |
const int TOOLTIP = 1; |
|
57 |
const int MENU = 2; |
|
58 |
const int SUBMENU = 3; |
|
59 |
const int POPUPMENU = 4; |
|
60 |
const int COMBOBOX_POPUP = 5; |
|
61 |
const int TYPES_COUNT = 6; |
|
62 |
jint windowTYPES[TYPES_COUNT]; |
|
63 |
||
64 |
||
65 |
/* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code. |
|
66 |
*/ |
|
67 |
||
68 |
/***********************************************************************/ |
|
69 |
// struct for _SetAlwaysOnTop() method |
|
70 |
struct SetAlwaysOnTopStruct { |
|
71 |
jobject window; |
|
72 |
jboolean value; |
|
73 |
}; |
|
74 |
// struct for _SetTitle() method |
|
75 |
struct SetTitleStruct { |
|
76 |
jobject window; |
|
77 |
jstring title; |
|
78 |
}; |
|
79 |
// struct for _SetResizable() method |
|
80 |
struct SetResizableStruct { |
|
81 |
jobject window; |
|
82 |
jboolean resizable; |
|
83 |
}; |
|
84 |
// struct for _UpdateInsets() method |
|
85 |
struct UpdateInsetsStruct { |
|
86 |
jobject window; |
|
87 |
jobject insets; |
|
88 |
}; |
|
89 |
// struct for _ReshapeFrame() method |
|
90 |
struct ReshapeFrameStruct { |
|
91 |
jobject frame; |
|
92 |
jint x, y; |
|
93 |
jint w, h; |
|
94 |
}; |
|
95 |
// struct for _SetIconImagesData |
|
96 |
struct SetIconImagesDataStruct { |
|
97 |
jobject window; |
|
98 |
jintArray iconRaster; |
|
99 |
jint w, h; |
|
100 |
jintArray smallIconRaster; |
|
101 |
jint smw, smh; |
|
102 |
}; |
|
103 |
// struct for _SetMinSize() method |
|
104 |
// and other methods setting sizes |
|
105 |
struct SizeStruct { |
|
106 |
jobject window; |
|
107 |
jint w, h; |
|
108 |
}; |
|
109 |
// struct for _SetFocusableWindow() method |
|
110 |
struct SetFocusableWindowStruct { |
|
111 |
jobject window; |
|
112 |
jboolean isFocusableWindow; |
|
113 |
}; |
|
114 |
// struct for _ModalDisable() method |
|
115 |
struct ModalDisableStruct { |
|
116 |
jobject window; |
|
117 |
jlong blockerHWnd; |
|
118 |
}; |
|
2451 | 119 |
// struct for _SetOpacity() method |
120 |
struct OpacityStruct { |
|
121 |
jobject window; |
|
122 |
jint iOpacity; |
|
123 |
}; |
|
124 |
// struct for _SetOpaque() method |
|
125 |
struct OpaqueStruct { |
|
126 |
jobject window; |
|
127 |
jboolean isOpaque; |
|
128 |
}; |
|
129 |
// struct for _UpdateWindow() method |
|
130 |
struct UpdateWindowStruct { |
|
131 |
jobject window; |
|
132 |
jintArray data; |
|
133 |
HBITMAP hBitmap; |
|
134 |
jint width, height; |
|
135 |
}; |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
136 |
// Struct for _RequestWindowFocus() method |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
137 |
struct RequestWindowFocusStruct { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
138 |
jobject component; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
139 |
jboolean isMouseEventCause; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
140 |
}; |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
141 |
// struct for _RepositionSecurityWarning() method |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
142 |
struct RepositionSecurityWarningStruct { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
143 |
jobject window; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
144 |
}; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
145 |
|
4256
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
146 |
struct SetFullScreenExclusiveModeStateStruct { |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
147 |
jobject window; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
148 |
jboolean isFSEMState; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
149 |
}; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
150 |
|
2451 | 151 |
|
2 | 152 |
/************************************************************************ |
153 |
* AwtWindow fields |
|
154 |
*/ |
|
155 |
||
156 |
jfieldID AwtWindow::warningStringID; |
|
157 |
jfieldID AwtWindow::locationByPlatformID; |
|
158 |
jfieldID AwtWindow::autoRequestFocusID; |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
159 |
jfieldID AwtWindow::securityWarningWidthID; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
160 |
jfieldID AwtWindow::securityWarningHeightID; |
2 | 161 |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
162 |
jfieldID AwtWindow::sysXID; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
163 |
jfieldID AwtWindow::sysYID; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
164 |
jfieldID AwtWindow::sysWID; |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
165 |
jfieldID AwtWindow::sysHID; |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
166 |
jfieldID AwtWindow::windowTypeID; |
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
167 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
168 |
jmethodID AwtWindow::getWarningStringMID; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
169 |
jmethodID AwtWindow::calculateSecurityWarningPositionMID; |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
170 |
jmethodID AwtWindow::windowTypeNameMID; |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
171 |
|
2 | 172 |
int AwtWindow::ms_instanceCounter = 0; |
173 |
HHOOK AwtWindow::ms_hCBTFilter; |
|
174 |
AwtWindow * AwtWindow::m_grabbedWindow = NULL; |
|
175 |
BOOL AwtWindow::sm_resizing = FALSE; |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
176 |
UINT AwtWindow::untrustedWindowsCounter = 0; |
2 | 177 |
|
178 |
/************************************************************************ |
|
179 |
* AwtWindow class methods |
|
180 |
*/ |
|
181 |
||
182 |
AwtWindow::AwtWindow() { |
|
183 |
m_sizePt.x = m_sizePt.y = 0; |
|
184 |
m_owningFrameDialog = NULL; |
|
185 |
m_isResizable = FALSE;//Default value is replaced after construction |
|
186 |
m_minSize.x = m_minSize.y = 0; |
|
187 |
m_hIcon = NULL; |
|
188 |
m_hIconSm = NULL; |
|
189 |
m_iconInherited = FALSE; |
|
190 |
VERIFY(::SetRectEmpty(&m_insets)); |
|
191 |
VERIFY(::SetRectEmpty(&m_old_insets)); |
|
192 |
VERIFY(::SetRectEmpty(&m_warningRect)); |
|
193 |
||
194 |
// what's the best initial value? |
|
195 |
m_screenNum = -1; |
|
196 |
ms_instanceCounter++; |
|
197 |
m_grabbed = FALSE; |
|
198 |
m_isFocusableWindow = TRUE; |
|
199 |
m_isRetainingHierarchyZOrder = FALSE; |
|
200 |
m_filterFocusAndActivation = FALSE; |
|
201 |
||
202 |
if (AwtWindow::ms_instanceCounter == 1) { |
|
203 |
AwtWindow::ms_hCBTFilter = |
|
204 |
::SetWindowsHookEx(WH_CBT, (HOOKPROC)AwtWindow::CBTFilter, |
|
205 |
0, AwtToolkit::MainThread()); |
|
206 |
} |
|
2451 | 207 |
|
208 |
m_opaque = TRUE; |
|
209 |
m_opacity = 0xff; |
|
210 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
211 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
212 |
warningString = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
213 |
warningWindow = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
214 |
securityTooltipWindow = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
215 |
securityWarningAnimationStage = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
216 |
currentWmSizeState = SIZE_RESTORED; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
217 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
218 |
hContentBitmap = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
219 |
|
2451 | 220 |
::InitializeCriticalSection(&contentBitmapCS); |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
221 |
|
6825 | 222 |
m_windowType = NORMAL; |
4375
dc92e241ccea
6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents:
4367
diff
changeset
|
223 |
m_alwaysOnTop = false; |
8515
f1c29dfb4f6a
7022488: The security warning may disappear unexpectedly
anthony
parents:
7668
diff
changeset
|
224 |
|
f1c29dfb4f6a
7022488: The security warning may disappear unexpectedly
anthony
parents:
7668
diff
changeset
|
225 |
fullScreenExclusiveModeState = FALSE; |
2 | 226 |
} |
227 |
||
228 |
AwtWindow::~AwtWindow() |
|
229 |
{ |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
230 |
if (warningString != NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
231 |
delete [] warningString; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
232 |
} |
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
233 |
DeleteContentBitmap(); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
234 |
::DeleteCriticalSection(&contentBitmapCS); |
2 | 235 |
} |
236 |
||
237 |
void AwtWindow::Dispose() |
|
238 |
{ |
|
239 |
// Fix 4745575 GDI Resource Leak |
|
240 |
// MSDN |
|
241 |
// Before a window is destroyed (that is, before it returns from processing |
|
242 |
// the WM_NCDESTROY message), an application must remove all entries it has |
|
243 |
// added to the property list. The application must use the RemoveProp function |
|
244 |
// to remove the entries. |
|
245 |
||
246 |
if (--AwtWindow::ms_instanceCounter == 0) { |
|
247 |
::UnhookWindowsHookEx(AwtWindow::ms_hCBTFilter); |
|
248 |
} |
|
249 |
||
250 |
::RemoveProp(GetHWnd(), ModalBlockerProp); |
|
251 |
||
252 |
if (m_grabbedWindow == this) { |
|
253 |
Ungrab(); |
|
254 |
} |
|
255 |
if ((m_hIcon != NULL) && !m_iconInherited) { |
|
256 |
::DestroyIcon(m_hIcon); |
|
257 |
} |
|
258 |
if ((m_hIconSm != NULL) && !m_iconInherited) { |
|
259 |
::DestroyIcon(m_hIconSm); |
|
260 |
} |
|
261 |
||
262 |
AwtCanvas::Dispose(); |
|
263 |
} |
|
264 |
||
265 |
void |
|
266 |
AwtWindow::Grab() { |
|
267 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
268 |
if (m_grabbedWindow != NULL) { |
|
269 |
m_grabbedWindow->Ungrab(); |
|
270 |
} |
|
271 |
m_grabbed = TRUE; |
|
272 |
m_grabbedWindow = this; |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
273 |
if (AwtComponent::GetFocusedWindow() == NULL && IsFocusableWindow()) { |
2 | 274 |
// we shouldn't perform grab in this case (see 4841881 & 6539458) |
275 |
Ungrab(); |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
276 |
} else if (GetHWnd() != AwtComponent::GetFocusedWindow()) { |
2 | 277 |
_ToFront(env->NewGlobalRef(GetPeer(env))); |
278 |
// Global ref was deleted in _ToFront |
|
279 |
} |
|
280 |
} |
|
281 |
||
282 |
void |
|
283 |
AwtWindow::Ungrab(BOOL doPost) { |
|
284 |
if (m_grabbed && m_grabbedWindow == this) { |
|
285 |
if (doPost) { |
|
286 |
PostUngrabEvent(); |
|
287 |
} |
|
288 |
m_grabbedWindow = NULL; |
|
289 |
m_grabbed = FALSE; |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
void |
|
294 |
AwtWindow::Ungrab() { |
|
295 |
Ungrab(TRUE); |
|
296 |
} |
|
297 |
||
298 |
void AwtWindow::_Grab(void * param) { |
|
299 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
300 |
||
301 |
jobject self = (jobject)param; |
|
302 |
||
303 |
if (env->EnsureLocalCapacity(1) < 0) |
|
304 |
{ |
|
305 |
env->DeleteGlobalRef(self); |
|
306 |
return; |
|
307 |
} |
|
308 |
||
309 |
AwtWindow *p = NULL; |
|
310 |
||
311 |
PDATA pData; |
|
312 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
313 |
p = (AwtWindow *)pData; |
|
314 |
p->Grab(); |
|
315 |
||
316 |
ret: |
|
317 |
env->DeleteGlobalRef(self); |
|
318 |
} |
|
319 |
||
320 |
void AwtWindow::_Ungrab(void * param) { |
|
321 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
322 |
||
323 |
jobject self = (jobject)param; |
|
324 |
||
325 |
if (env->EnsureLocalCapacity(1) < 0) |
|
326 |
{ |
|
327 |
env->DeleteGlobalRef(self); |
|
328 |
return; |
|
329 |
} |
|
330 |
||
331 |
AwtWindow *p = NULL; |
|
332 |
||
333 |
PDATA pData; |
|
334 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
335 |
p = (AwtWindow *)pData; |
|
336 |
p->Ungrab(FALSE); |
|
337 |
||
338 |
ret: |
|
339 |
env->DeleteGlobalRef(self); |
|
340 |
} |
|
341 |
||
342 |
MsgRouting AwtWindow::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) { |
|
343 |
if (m_grabbedWindow != NULL && !m_grabbedWindow->IsOneOfOwnersOf(this)) { |
|
344 |
m_grabbedWindow->Ungrab(); |
|
345 |
} |
|
346 |
return AwtCanvas::WmNcMouseDown(hitTest, x, y, button); |
|
347 |
} |
|
348 |
||
349 |
MsgRouting AwtWindow::WmWindowPosChanging(LPARAM windowPos) { |
|
350 |
return mrDoDefault; |
|
351 |
} |
|
352 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
353 |
void AwtWindow::RepositionSecurityWarning(JNIEnv *env) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
354 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
355 |
RECT rect; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
356 |
CalculateWarningWindowBounds(env, &rect); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
357 |
|
4375
dc92e241ccea
6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents:
4367
diff
changeset
|
358 |
::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(), |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
359 |
rect.left, rect.top, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
360 |
rect.right - rect.left, rect.bottom - rect.top, |
4375
dc92e241ccea
6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents:
4367
diff
changeset
|
361 |
SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | |
2640
643213b1a0a0
6825342: Security warning may change Z-order of top-level
anthony
parents:
2472
diff
changeset
|
362 |
SWP_NOOWNERZORDER |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
363 |
); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
364 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
365 |
|
2 | 366 |
MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) { |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
367 |
WINDOWPOS * wp = (WINDOWPOS *)windowPos; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
368 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
369 |
// Reposition the warning window |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
370 |
if (IsUntrusted() && warningWindow != NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
371 |
if (wp->flags & SWP_HIDEWINDOW) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
372 |
UpdateSecurityWarningVisibility(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
373 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
374 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
375 |
RepositionSecurityWarning((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2)); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
376 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
377 |
if (wp->flags & SWP_SHOWWINDOW) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
378 |
UpdateSecurityWarningVisibility(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
379 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
380 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
381 |
|
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
382 |
if (wp->flags & SWP_HIDEWINDOW) { |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
383 |
EnableTranslucency(FALSE); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
384 |
} |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
385 |
|
2 | 386 |
return mrDoDefault; |
387 |
} |
|
388 |
||
389 |
LPCTSTR AwtWindow::GetClassName() { |
|
390 |
return TEXT("SunAwtWindow"); |
|
391 |
} |
|
392 |
||
393 |
void AwtWindow::FillClassInfo(WNDCLASSEX *lpwc) |
|
394 |
{ |
|
395 |
AwtComponent::FillClassInfo(lpwc); |
|
396 |
/* |
|
397 |
* This line causes bug #4189244 (Swing Popup menu is not being refreshed (cleared) under a Dialog) |
|
398 |
* so it's comment out (son@sparc.spb.su) |
|
399 |
* |
|
400 |
* lpwc->style |= CS_SAVEBITS; // improve pull-down menu performance |
|
401 |
*/ |
|
402 |
lpwc->cbWndExtra = DLGWINDOWEXTRA; |
|
403 |
} |
|
404 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
405 |
bool AwtWindow::IsWarningWindow(HWND hWnd) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
406 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
407 |
const UINT len = 128; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
408 |
TCHAR windowClassName[len]; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
409 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
410 |
::RealGetWindowClass(hWnd, windowClassName, len); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
411 |
return 0 == _tcsncmp(windowClassName, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
412 |
AwtWindow::GetWarningWindowClassName(), len); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
413 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
414 |
|
2 | 415 |
LRESULT CALLBACK AwtWindow::CBTFilter(int nCode, WPARAM wParam, LPARAM lParam) |
416 |
{ |
|
417 |
if (nCode == HCBT_ACTIVATE || nCode == HCBT_SETFOCUS) { |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
418 |
HWND hWnd = (HWND)wParam; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
419 |
AwtComponent *comp = AwtComponent::GetComponent(hWnd); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
420 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
421 |
if (comp == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
422 |
// Check if it's a security warning icon |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
423 |
// See: 5091224, 6181725, 6732583 |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
424 |
if (AwtWindow::IsWarningWindow(hWnd)) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
425 |
return 1; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
426 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
427 |
} else { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
428 |
if (comp->IsTopLevel()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
429 |
AwtWindow* win = (AwtWindow*)comp; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
430 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
431 |
if (!win->IsFocusableWindow() || |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
432 |
win->m_filterFocusAndActivation) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
433 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
434 |
return 1; // Don't change focus/activation. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
435 |
} |
131
fe5ccd4774b4
6567410: PIT : java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java fails
ant
parents:
129
diff
changeset
|
436 |
} |
2 | 437 |
} |
438 |
} |
|
439 |
return ::CallNextHookEx(AwtWindow::ms_hCBTFilter, nCode, wParam, lParam); |
|
440 |
} |
|
441 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
442 |
void AwtWindow::InitSecurityWarningSize(JNIEnv *env) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
443 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
444 |
warningWindowWidth = ::GetSystemMetrics(SM_CXSMICON); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
445 |
warningWindowHeight = ::GetSystemMetrics(SM_CYSMICON); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
446 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
447 |
jobject target = GetTarget(env); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
448 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
449 |
env->SetIntField(target, AwtWindow::securityWarningWidthID, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
450 |
warningWindowWidth); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
451 |
env->SetIntField(target, AwtWindow::securityWarningHeightID, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
452 |
warningWindowHeight); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
453 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
454 |
env->DeleteLocalRef(target); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
455 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
456 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
457 |
void AwtWindow::CreateHWnd(JNIEnv *env, LPCWSTR title, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
458 |
DWORD windowStyle, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
459 |
DWORD windowExStyle, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
460 |
int x, int y, int w, int h, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
461 |
HWND hWndParent, HMENU hMenu, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
462 |
COLORREF colorForeground, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
463 |
COLORREF colorBackground, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
464 |
jobject peer) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
465 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
466 |
// Retrieve the warning string |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
467 |
// Note: we need to get it before CreateHWnd() happens because |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
468 |
// the isUntrusted() method may be invoked while the HWND |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
469 |
// is being created in response to some window messages. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
470 |
jobject target = env->GetObjectField(peer, AwtObject::targetID); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
471 |
jstring javaWarningString = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
472 |
(jstring)env->CallObjectMethod(target, AwtWindow::getWarningStringMID); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
473 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
474 |
if (javaWarningString != NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
475 |
size_t length = env->GetStringLength(javaWarningString) + 1; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
476 |
warningString = new WCHAR[length]; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
477 |
env->GetStringRegion(javaWarningString, 0, |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2646
diff
changeset
|
478 |
static_cast<jsize>(length - 1), reinterpret_cast<jchar*>(warningString)); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
479 |
warningString[length-1] = L'\0'; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
480 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
481 |
env->DeleteLocalRef(javaWarningString); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
482 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
483 |
env->DeleteLocalRef(target); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
484 |
|
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
485 |
InitType(env, peer); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
486 |
TweakStyle(windowStyle, windowExStyle); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
487 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
488 |
AwtCanvas::CreateHWnd(env, title, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
489 |
windowStyle, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
490 |
windowExStyle, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
491 |
x, y, w, h, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
492 |
hWndParent, hMenu, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
493 |
colorForeground, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
494 |
colorBackground, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
495 |
peer); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
496 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
497 |
// Now we need to create the warning window. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
498 |
CreateWarningWindow(env); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
499 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
500 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
501 |
void AwtWindow::CreateWarningWindow(JNIEnv *env) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
502 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
503 |
if (!IsUntrusted()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
504 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
505 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
506 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
507 |
if (++AwtWindow::untrustedWindowsCounter == 1) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
508 |
AwtToolkit::GetInstance().InstallMouseLowLevelHook(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
509 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
510 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
511 |
InitSecurityWarningSize(env); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
512 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
513 |
RECT rect; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
514 |
CalculateWarningWindowBounds(env, &rect); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
515 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
516 |
RegisterWarningWindowClass(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
517 |
warningWindow = ::CreateWindowEx( |
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
518 |
WS_EX_NOACTIVATE, |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
519 |
GetWarningWindowClassName(), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
520 |
warningString, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
521 |
WS_POPUP, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
522 |
rect.left, rect.top, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
523 |
rect.right - rect.left, rect.bottom - rect.top, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
524 |
GetHWnd(), // owner |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
525 |
NULL, // menu |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
526 |
AwtToolkit::GetInstance().GetModuleHandle(), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
527 |
NULL // lParam |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
528 |
); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
529 |
if (warningWindow == NULL) { |
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
530 |
//XXX: actually this is bad... We didn't manage to create the window. |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
531 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
532 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
533 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
534 |
HICON hIcon = GetSecurityWarningIcon(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
535 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
536 |
ICONINFO ii; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
537 |
::GetIconInfo(hIcon, &ii); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
538 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
539 |
//Note: we assume that every security icon has exactly the same shape. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
540 |
HRGN rgn = BitmapUtil::BitmapToRgn(ii.hbmColor); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
541 |
if (rgn) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
542 |
::SetWindowRgn(warningWindow, rgn, TRUE); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
543 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
544 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
545 |
// Now we need to create the tooltip control for this window. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
546 |
if (!ComCtl32Util::GetInstance().IsToolTipControlInitialized()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
547 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
548 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
549 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
550 |
securityTooltipWindow = ::CreateWindowEx( |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
551 |
WS_EX_TOPMOST, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
552 |
TOOLTIPS_CLASS, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
553 |
NULL, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
554 |
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
555 |
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
556 |
warningWindow, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
557 |
NULL, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
558 |
AwtToolkit::GetInstance().GetModuleHandle(), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
559 |
NULL |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
560 |
); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
561 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
562 |
::SetWindowPos(securityTooltipWindow, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
563 |
HWND_TOPMOST, 0, 0, 0, 0, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
564 |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
565 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
566 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
567 |
// We currently don't expect changing the size of the window, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
568 |
// hence we may not care of updating the TOOL position/size. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
569 |
::GetClientRect(warningWindow, &rect); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
570 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
571 |
TOOLINFO ti; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
572 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
573 |
ti.cbSize = sizeof(ti); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
574 |
ti.uFlags = TTF_SUBCLASS; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
575 |
ti.hwnd = warningWindow; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
576 |
ti.hinst = AwtToolkit::GetInstance().GetModuleHandle(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
577 |
ti.uId = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
578 |
ti.lpszText = warningString; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
579 |
ti.rect.left = rect.left; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
580 |
ti.rect.top = rect.top; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
581 |
ti.rect.right = rect.right; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
582 |
ti.rect.bottom = rect.bottom; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
583 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
584 |
::SendMessage(securityTooltipWindow, TTM_ADDTOOL, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
585 |
0, (LPARAM) (LPTOOLINFO) &ti); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
586 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
587 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
588 |
void AwtWindow::DestroyWarningWindow() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
589 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
590 |
if (!IsUntrusted()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
591 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
592 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
593 |
if (--AwtWindow::untrustedWindowsCounter == 0) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
594 |
AwtToolkit::GetInstance().UninstallMouseLowLevelHook(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
595 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
596 |
if (warningWindow != NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
597 |
// Note that the warningWindow is an owned window, and hence |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
598 |
// it would be destroyed automatically. However, the window |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
599 |
// class may only be unregistered if there's no any single |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
600 |
// window left using this class. Thus, we're destroying the |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
601 |
// warning window manually. Note that the tooltip window |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
602 |
// will be destroyed automatically because it's an owned |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
603 |
// window as well. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
604 |
::DestroyWindow(warningWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
605 |
warningWindow = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
606 |
securityTooltipWindow = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
607 |
UnregisterWarningWindowClass(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
608 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
609 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
610 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
611 |
void AwtWindow::DestroyHWnd() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
612 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
613 |
DestroyWarningWindow(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
614 |
AwtCanvas::DestroyHWnd(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
615 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
616 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
617 |
LPCTSTR AwtWindow::GetWarningWindowClassName() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
618 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
619 |
return TEXT("SunAwtWarningWindow"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
620 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
621 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
622 |
void AwtWindow::FillWarningWindowClassInfo(WNDCLASS *lpwc) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
623 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
624 |
lpwc->style = 0L; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
625 |
lpwc->lpfnWndProc = (WNDPROC)WarningWindowProc; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
626 |
lpwc->cbClsExtra = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
627 |
lpwc->cbWndExtra = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
628 |
lpwc->hInstance = AwtToolkit::GetInstance().GetModuleHandle(), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
629 |
lpwc->hIcon = AwtToolkit::GetInstance().GetAwtIcon(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
630 |
lpwc->hCursor = ::LoadCursor(NULL, IDC_ARROW); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
631 |
lpwc->hbrBackground = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
632 |
lpwc->lpszMenuName = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
633 |
lpwc->lpszClassName = AwtWindow::GetWarningWindowClassName(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
634 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
635 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
636 |
void AwtWindow::RegisterWarningWindowClass() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
637 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
638 |
WNDCLASS wc; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
639 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
640 |
::ZeroMemory(&wc, sizeof(wc)); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
641 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
642 |
if (!::GetClassInfo(AwtToolkit::GetInstance().GetModuleHandle(), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
643 |
AwtWindow::GetWarningWindowClassName(), &wc)) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
644 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
645 |
AwtWindow::FillWarningWindowClassInfo(&wc); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
646 |
ATOM atom = ::RegisterClass(&wc); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
647 |
DASSERT(atom != 0); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
648 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
649 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
650 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
651 |
void AwtWindow::UnregisterWarningWindowClass() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
652 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
653 |
::UnregisterClass(AwtWindow::GetWarningWindowClassName(), AwtToolkit::GetInstance().GetModuleHandle()); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
654 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
655 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
656 |
HICON AwtWindow::GetSecurityWarningIcon() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
657 |
{ |
4367
e60cfd711532
6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents:
4366
diff
changeset
|
658 |
// It is assumed that the icon at index 0 is gray |
e60cfd711532
6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents:
4366
diff
changeset
|
659 |
const UINT index = securityAnimationKind == akShow ? |
e60cfd711532
6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents:
4366
diff
changeset
|
660 |
securityWarningAnimationStage : 0; |
e60cfd711532
6901021: Security Warning Icon not getting displayed properly when frame loses focus
anthony
parents:
4366
diff
changeset
|
661 |
HICON ico = AwtToolkit::GetInstance().GetSecurityWarningIcon(index, |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
662 |
warningWindowWidth, warningWindowHeight); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
663 |
return ico; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
664 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
665 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
666 |
// This function calculates the bounds of the warning window and stores them |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
667 |
// into the RECT structure pointed by the argument rect. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
668 |
void AwtWindow::CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
669 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
670 |
RECT windowBounds; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
671 |
AwtToolkit::GetWindowRect(GetHWnd(), &windowBounds); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
672 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
673 |
jobject target = GetTarget(env); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
674 |
jobject point2D = env->CallObjectMethod(target, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
675 |
calculateSecurityWarningPositionMID, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
676 |
(jdouble)windowBounds.left, (jdouble)windowBounds.top, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
677 |
(jdouble)(windowBounds.right - windowBounds.left), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
678 |
(jdouble)(windowBounds.bottom - windowBounds.top)); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
679 |
env->DeleteLocalRef(target); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
680 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
681 |
static jclass point2DClassID = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
682 |
static jmethodID point2DGetXMID = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
683 |
static jmethodID point2DGetYMID = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
684 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
685 |
if (point2DClassID == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
686 |
jclass point2DClassIDLocal = env->FindClass("java/awt/geom/Point2D"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
687 |
point2DClassID = (jclass)env->NewGlobalRef(point2DClassIDLocal); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
688 |
env->DeleteLocalRef(point2DClassIDLocal); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
689 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
690 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
691 |
if (point2DGetXMID == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
692 |
point2DGetXMID = env->GetMethodID(point2DClassID, "getX", "()D"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
693 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
694 |
if (point2DGetYMID == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
695 |
point2DGetYMID = env->GetMethodID(point2DClassID, "getY", "()D"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
696 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
697 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
698 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
699 |
int x = (int)env->CallDoubleMethod(point2D, point2DGetXMID); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
700 |
int y = (int)env->CallDoubleMethod(point2D, point2DGetYMID); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
701 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
702 |
env->DeleteLocalRef(point2D); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
703 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
704 |
rect->left = x; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
705 |
rect->top = y; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
706 |
rect->right = rect->left + warningWindowWidth; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
707 |
rect->bottom = rect->top + warningWindowHeight; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
708 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
709 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
710 |
LRESULT CALLBACK AwtWindow::WarningWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
711 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
712 |
switch (uMsg) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
713 |
case WM_PAINT: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
714 |
PaintWarningWindow(hwnd); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
715 |
return 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
716 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
717 |
case WM_MOUSEACTIVATE: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
718 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
719 |
// Retrive the owner of the warning window. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
720 |
HWND javaWindow = ::GetParent(hwnd); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
721 |
if (javaWindow) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
722 |
// If the window is blocked by a modal dialog, substitute |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
723 |
// its handle with the topmost blocker. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
724 |
HWND topmostBlocker = GetTopmostModalBlocker(javaWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
725 |
if (::IsWindow(topmostBlocker)) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
726 |
javaWindow = topmostBlocker; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
727 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
728 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
729 |
::BringWindowToTop(javaWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
730 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
731 |
AwtWindow * window = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
732 |
(AwtWindow*)AwtComponent::GetComponent(javaWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
733 |
if (window == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
734 |
// Quite unlikely to go into here, but it's way better |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
735 |
// than getting a crash. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
736 |
::SetForegroundWindow(javaWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
737 |
} else { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
738 |
// Activate the window if it is focusable and inactive |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
739 |
if (window->IsFocusableWindow() && |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
740 |
javaWindow != ::GetActiveWindow()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
741 |
::SetForegroundWindow(javaWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
742 |
} else { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
743 |
// ...otherwise just start the animation. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
744 |
window->StartSecurityAnimation(akShow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
745 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
746 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
747 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
748 |
// In every case if there's a top-most blocker, we need to |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
749 |
// enable modal animation. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
750 |
if (::IsWindow(topmostBlocker)) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
751 |
AwtDialog::AnimateModalBlocker(topmostBlocker); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
752 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
753 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
754 |
return MA_NOACTIVATEANDEAT; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
755 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
756 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
757 |
return ::DefWindowProc(hwnd, uMsg, wParam, lParam); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
758 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
759 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
760 |
void AwtWindow::PaintWarningWindow(HWND warningWindow) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
761 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
762 |
RECT updateRect; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
763 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
764 |
if (!::GetUpdateRect(warningWindow, &updateRect, FALSE)) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
765 |
// got nothing to update |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
766 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
767 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
768 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
769 |
PAINTSTRUCT ps; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
770 |
HDC hdc = ::BeginPaint(warningWindow, &ps); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
771 |
if (hdc == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
772 |
// indicates an error |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
773 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
774 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
775 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
776 |
PaintWarningWindow(warningWindow, hdc); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
777 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
778 |
::EndPaint(warningWindow, &ps); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
779 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
780 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
781 |
void AwtWindow::PaintWarningWindow(HWND warningWindow, HDC hdc) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
782 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
783 |
HWND javaWindow = ::GetParent(warningWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
784 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
785 |
AwtWindow * window = (AwtWindow*)AwtComponent::GetComponent(javaWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
786 |
if (window == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
787 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
788 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
789 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
790 |
::DrawIconEx(hdc, 0, 0, window->GetSecurityWarningIcon(), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
791 |
window->warningWindowWidth, window->warningWindowHeight, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
792 |
0, NULL, DI_NORMAL); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
793 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
794 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
795 |
static const UINT_PTR IDT_AWT_SECURITYANIMATION = 0x102; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
796 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
797 |
// Approximately 6 times a second. 0.75 seconds total. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
798 |
static const UINT securityAnimationTimerElapse = 150; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
799 |
static const UINT securityAnimationMaxIterations = 5; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
800 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
801 |
void AwtWindow::RepaintWarningWindow() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
802 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
803 |
HDC hdc = ::GetDC(warningWindow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
804 |
PaintWarningWindow(warningWindow, hdc); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
805 |
::ReleaseDC(warningWindow, hdc); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
806 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
807 |
|
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
808 |
void AwtWindow::SetLayered(HWND window, bool layered) |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
809 |
{ |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
810 |
const LONG ex_style = ::GetWindowLong(window, GWL_EXSTYLE); |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
811 |
::SetWindowLong(window, GWL_EXSTYLE, layered ? |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
812 |
ex_style | WS_EX_LAYERED : ex_style & ~WS_EX_LAYERED); |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
813 |
} |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
814 |
|
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
815 |
bool AwtWindow::IsLayered(HWND window) |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
816 |
{ |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
817 |
const LONG ex_style = ::GetWindowLong(window, GWL_EXSTYLE); |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
818 |
return ex_style & WS_EX_LAYERED; |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
819 |
} |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
820 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
821 |
void AwtWindow::StartSecurityAnimation(AnimationKind kind) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
822 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
823 |
if (!IsUntrusted()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
824 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
825 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
826 |
if (warningWindow == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
827 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
828 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
829 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
830 |
securityAnimationKind = kind; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
831 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
832 |
securityWarningAnimationStage = 1; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
833 |
::SetTimer(GetHWnd(), IDT_AWT_SECURITYANIMATION, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
834 |
securityAnimationTimerElapse, NULL); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
835 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
836 |
if (securityAnimationKind == akShow) { |
4375
dc92e241ccea
6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents:
4367
diff
changeset
|
837 |
::SetWindowPos(warningWindow, |
dc92e241ccea
6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents:
4367
diff
changeset
|
838 |
IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(), |
dc92e241ccea
6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents:
4367
diff
changeset
|
839 |
0, 0, 0, 0, |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
840 |
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | |
2640
643213b1a0a0
6825342: Security warning may change Z-order of top-level
anthony
parents:
2472
diff
changeset
|
841 |
SWP_SHOWWINDOW | SWP_NOOWNERZORDER); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
842 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
843 |
::SetLayeredWindowAttributes(warningWindow, RGB(0, 0, 0), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
844 |
0xFF, LWA_ALPHA); |
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
845 |
AwtWindow::SetLayered(warningWindow, false); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
846 |
::RedrawWindow(warningWindow, NULL, NULL, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
847 |
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); |
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
848 |
} else if (securityAnimationKind == akPreHide) { |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
849 |
// Pre-hiding means fading-out. We have to make the window layered. |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
850 |
// Note: Some VNC clients do not support layered windows, hence |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
851 |
// we dynamically turn it on and off. See 6805231. |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
852 |
AwtWindow::SetLayered(warningWindow, true); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
853 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
854 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
855 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
856 |
void AwtWindow::StopSecurityAnimation() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
857 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
858 |
if (!IsUntrusted()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
859 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
860 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
861 |
if (warningWindow == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
862 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
863 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
864 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
865 |
securityWarningAnimationStage = 0; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
866 |
::KillTimer(GetHWnd(), IDT_AWT_SECURITYANIMATION); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
867 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
868 |
switch (securityAnimationKind) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
869 |
case akHide: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
870 |
case akPreHide: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
871 |
::SetWindowPos(warningWindow, HWND_NOTOPMOST, 0, 0, 0, 0, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
872 |
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | |
2640
643213b1a0a0
6825342: Security warning may change Z-order of top-level
anthony
parents:
2472
diff
changeset
|
873 |
SWP_HIDEWINDOW | SWP_NOOWNERZORDER); |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
874 |
break; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
875 |
case akShow: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
876 |
RepaintWarningWindow(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
877 |
break; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
878 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
879 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
880 |
securityAnimationKind = akNone; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
881 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
882 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
883 |
MsgRouting AwtWindow::WmTimer(UINT_PTR timerID) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
884 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
885 |
if (timerID != IDT_AWT_SECURITYANIMATION) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
886 |
return mrPassAlong; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
887 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
888 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
889 |
if (securityWarningAnimationStage == 0) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
890 |
return mrConsume; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
891 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
892 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
893 |
securityWarningAnimationStage++; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
894 |
if (securityWarningAnimationStage >= securityAnimationMaxIterations) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
895 |
if (securityAnimationKind == akPreHide) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
896 |
// chain real hiding |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
897 |
StartSecurityAnimation(akHide); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
898 |
} else { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
899 |
StopSecurityAnimation(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
900 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
901 |
} else { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
902 |
switch (securityAnimationKind) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
903 |
case akHide: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
904 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
905 |
BYTE opacity = ((int)0xFF * |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
906 |
(securityAnimationMaxIterations - |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
907 |
securityWarningAnimationStage)) / |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
908 |
securityAnimationMaxIterations; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
909 |
::SetLayeredWindowAttributes(warningWindow, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
910 |
RGB(0, 0, 0), opacity, LWA_ALPHA); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
911 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
912 |
break; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
913 |
case akShow: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
914 |
case akNone: // quite unlikely, but quite safe |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
915 |
RepaintWarningWindow(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
916 |
break; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
917 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
918 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
919 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
920 |
return mrConsume; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
921 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
922 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
923 |
// The security warning is visible if: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
924 |
// 1. The window has the keyboard window focus, OR |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
925 |
// 2. The mouse pointer is located within the window bounds, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
926 |
// or within the security warning icon. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
927 |
void AwtWindow::UpdateSecurityWarningVisibility() |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
928 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
929 |
if (!IsUntrusted()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
930 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
931 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
932 |
if (warningWindow == NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
933 |
return; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
934 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
935 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
936 |
bool show = false; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
937 |
|
4256
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
938 |
if (IsVisible() && currentWmSizeState != SIZE_MINIMIZED && |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
939 |
!isFullScreenExclusiveMode()) |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
940 |
{ |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
941 |
if (AwtComponent::GetFocusedWindow() == GetHWnd()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
942 |
show = true; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
943 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
944 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
945 |
HWND hwnd = AwtToolkit::GetInstance().GetWindowUnderMouse(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
946 |
if (hwnd == GetHWnd()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
947 |
show = true; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
948 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
949 |
if (hwnd == warningWindow) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
950 |
show = true; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
951 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
952 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
953 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
954 |
if (show && (!::IsWindowVisible(warningWindow) || |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
955 |
securityAnimationKind == akHide || |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
956 |
securityAnimationKind == akPreHide)) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
957 |
StartSecurityAnimation(akShow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
958 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
959 |
if (!show && ::IsWindowVisible(warningWindow)) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
960 |
StartSecurityAnimation(akPreHide); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
961 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
962 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
963 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
964 |
void AwtWindow::FocusedWindowChanged(HWND from, HWND to) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
965 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
966 |
AwtWindow * fw = (AwtWindow *)AwtComponent::GetComponent(from); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
967 |
AwtWindow * tw = (AwtWindow *)AwtComponent::GetComponent(to); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
968 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
969 |
if (fw != NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
970 |
fw->UpdateSecurityWarningVisibility(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
971 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
972 |
if (tw != NULL) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
973 |
tw->UpdateSecurityWarningVisibility(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
974 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
975 |
// Flash on receiving the keyboard focus even if the warning |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
976 |
// has already been shown (e.g. by hovering with the mouse) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
977 |
tw->StartSecurityAnimation(akShow); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
978 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
979 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
980 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
981 |
void AwtWindow::_RepositionSecurityWarning(void* param) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
982 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
983 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
984 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
985 |
RepositionSecurityWarningStruct *rsws = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
986 |
(RepositionSecurityWarningStruct *)param; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
987 |
jobject self = rsws->window; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
988 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
989 |
PDATA pData; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
990 |
JNI_CHECK_PEER_GOTO(self, ret); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
991 |
AwtWindow *window = (AwtWindow *)pData; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
992 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
993 |
window->RepositionSecurityWarning(env); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
994 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
995 |
ret: |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
996 |
env->DeleteGlobalRef(self); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
997 |
delete rsws; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
998 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
999 |
|
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1000 |
void AwtWindow::InitType(JNIEnv *env, jobject peer) |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1001 |
{ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1002 |
jobject type = env->GetObjectField(peer, windowTypeID); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1003 |
if (type == NULL) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1004 |
return; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1005 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1006 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1007 |
jstring value = (jstring)env->CallObjectMethod(type, windowTypeNameMID); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1008 |
if (value == NULL) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1009 |
env->DeleteLocalRef(type); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1010 |
return; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1011 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1012 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1013 |
const char* valueNative = env->GetStringUTFChars(value, 0); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1014 |
if (valueNative == NULL) { |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1015 |
env->DeleteLocalRef(value); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1016 |
env->DeleteLocalRef(type); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1017 |
return; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1018 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1019 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1020 |
if (strcmp(valueNative, "UTILITY") == 0) { |
6825 | 1021 |
m_windowType = UTILITY; |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1022 |
} else if (strcmp(valueNative, "POPUP") == 0) { |
6825 | 1023 |
m_windowType = POPUP; |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1024 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1025 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1026 |
env->ReleaseStringUTFChars(value, valueNative); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1027 |
env->DeleteLocalRef(value); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1028 |
env->DeleteLocalRef(type); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1029 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1030 |
|
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1031 |
void AwtWindow::TweakStyle(DWORD & style, DWORD & exStyle) |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1032 |
{ |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1033 |
switch (GetType()) { |
6825 | 1034 |
case UTILITY: |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1035 |
exStyle |= WS_EX_TOOLWINDOW; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1036 |
break; |
6825 | 1037 |
case POPUP: |
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1038 |
style &= ~WS_OVERLAPPED; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1039 |
style |= WS_POPUP; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1040 |
break; |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1041 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1042 |
} |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
1043 |
|
2 | 1044 |
/* Create a new AwtWindow object and window. */ |
1045 |
AwtWindow* AwtWindow::Create(jobject self, jobject parent) |
|
1046 |
{ |
|
1047 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1048 |
||
1049 |
jobject target = NULL; |
|
1050 |
AwtWindow* window = NULL; |
|
1051 |
||
1052 |
try { |
|
1053 |
if (env->EnsureLocalCapacity(1) < 0) { |
|
1054 |
return NULL; |
|
1055 |
} |
|
1056 |
||
1057 |
AwtWindow* awtParent = NULL; |
|
1058 |
||
1059 |
PDATA pData; |
|
1060 |
if (parent != NULL) { |
|
1061 |
JNI_CHECK_PEER_GOTO(parent, done); |
|
1062 |
awtParent = (AwtWindow *)pData; |
|
1063 |
} |
|
1064 |
||
1065 |
target = env->GetObjectField(self, AwtObject::targetID); |
|
1066 |
JNI_CHECK_NULL_GOTO(target, "null target", done); |
|
1067 |
||
1068 |
window = new AwtWindow(); |
|
1069 |
||
1070 |
{ |
|
1071 |
if (JNU_IsInstanceOfByName(env, target, "javax/swing/Popup$HeavyWeightWindow") > 0) { |
|
1072 |
window->m_isRetainingHierarchyZOrder = TRUE; |
|
1073 |
} |
|
1074 |
DWORD style = WS_CLIPCHILDREN | WS_POPUP; |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1075 |
DWORD exStyle = WS_EX_NOACTIVATE; |
2 | 1076 |
if (GetRTL()) { |
1077 |
exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR; |
|
1078 |
if (GetRTLReadingOrder()) |
|
1079 |
exStyle |= WS_EX_RTLREADING; |
|
1080 |
} |
|
1081 |
if (awtParent != NULL) { |
|
1082 |
window->InitOwner(awtParent); |
|
1083 |
} else { |
|
1084 |
// specify WS_EX_TOOLWINDOW to remove parentless windows from taskbar |
|
1085 |
exStyle |= WS_EX_TOOLWINDOW; |
|
1086 |
} |
|
1087 |
window->CreateHWnd(env, L"", |
|
1088 |
style, exStyle, |
|
1089 |
0, 0, 0, 0, |
|
1090 |
(awtParent != NULL) ? awtParent->GetHWnd() : NULL, |
|
1091 |
NULL, |
|
1092 |
::GetSysColor(COLOR_WINDOWTEXT), |
|
1093 |
::GetSysColor(COLOR_WINDOW), |
|
1094 |
self); |
|
1095 |
||
1096 |
jint x = env->GetIntField(target, AwtComponent::xID); |
|
1097 |
jint y = env->GetIntField(target, AwtComponent::yID); |
|
1098 |
jint width = env->GetIntField(target, AwtComponent::widthID); |
|
1099 |
jint height = env->GetIntField(target, AwtComponent::heightID); |
|
1100 |
||
1101 |
/* |
|
1102 |
* Initialize icon as inherited from parent if it exists |
|
1103 |
*/ |
|
1104 |
if (parent != NULL) { |
|
1105 |
window->m_hIcon = awtParent->GetHIcon(); |
|
1106 |
window->m_hIconSm = awtParent->GetHIconSm(); |
|
1107 |
window->m_iconInherited = TRUE; |
|
1108 |
} |
|
1109 |
window->DoUpdateIcon(); |
|
1110 |
||
1111 |
||
1112 |
/* |
|
1113 |
* Reshape here instead of during create, so that a WM_NCCALCSIZE |
|
1114 |
* is sent. |
|
1115 |
*/ |
|
1116 |
window->Reshape(x, y, width, height); |
|
1117 |
} |
|
1118 |
} catch (...) { |
|
1119 |
env->DeleteLocalRef(target); |
|
1120 |
throw; |
|
1121 |
} |
|
1122 |
||
1123 |
done: |
|
1124 |
env->DeleteLocalRef(target); |
|
1125 |
return window; |
|
1126 |
} |
|
1127 |
||
1128 |
BOOL AwtWindow::IsOneOfOwnersOf(AwtWindow * wnd) { |
|
1129 |
while (wnd != NULL) { |
|
1130 |
if (wnd == this || wnd->GetOwningFrameOrDialog() == this) return TRUE; |
|
1131 |
wnd = (AwtWindow*)GetComponent(::GetWindow(wnd->GetHWnd(), GW_OWNER)); |
|
1132 |
} |
|
1133 |
return FALSE; |
|
1134 |
} |
|
1135 |
||
1136 |
void AwtWindow::InitOwner(AwtWindow *owner) |
|
1137 |
{ |
|
1138 |
DASSERT(owner != NULL); |
|
1139 |
while (owner != NULL && owner->IsSimpleWindow()) { |
|
1140 |
||
1141 |
HWND ownerOwnerHWND = ::GetWindow(owner->GetHWnd(), GW_OWNER); |
|
1142 |
if (ownerOwnerHWND == NULL) { |
|
1143 |
owner = NULL; |
|
1144 |
break; |
|
1145 |
} |
|
1146 |
owner = (AwtWindow *)AwtComponent::GetComponent(ownerOwnerHWND); |
|
1147 |
} |
|
1148 |
m_owningFrameDialog = (AwtFrame *)owner; |
|
1149 |
} |
|
1150 |
||
1151 |
void AwtWindow::moveToDefaultLocation() { |
|
1152 |
HWND boggy = ::CreateWindow(GetClassName(), L"BOGGY", WS_OVERLAPPED, CW_USEDEFAULT, 0 ,0, 0, |
|
1153 |
NULL, NULL, NULL, NULL); |
|
1154 |
RECT defLoc; |
|
1155 |
||
1156 |
// Fixed 6477497: Windows drawn off-screen on Win98, even when java.awt.Window.locationByPlatform is set |
|
1157 |
// Win9x does not position a window until the window is shown. |
|
1158 |
// The behavior is slightly opposite to the WinNT (and up), where |
|
1159 |
// Windows will position the window upon creation of the window. |
|
1160 |
// That's why we have to manually set the left & top values of |
|
1161 |
// the defLoc to 0 if the GetWindowRect function returns FALSE. |
|
1162 |
BOOL result = ::GetWindowRect(boggy, &defLoc); |
|
1163 |
if (!result) { |
|
1164 |
defLoc.left = defLoc.top = 0; |
|
1165 |
} |
|
1166 |
VERIFY(::DestroyWindow(boggy)); |
|
1167 |
VERIFY(::SetWindowPos(GetHWnd(), NULL, defLoc.left, defLoc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER)); |
|
1168 |
} |
|
1169 |
||
1170 |
void AwtWindow::Show() |
|
1171 |
{ |
|
1172 |
m_visible = true; |
|
1173 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1174 |
BOOL done = false; |
|
1175 |
HWND hWnd = GetHWnd(); |
|
1176 |
||
1177 |
if (env->EnsureLocalCapacity(2) < 0) { |
|
1178 |
return; |
|
1179 |
} |
|
1180 |
jobject target = GetTarget(env); |
|
1181 |
INT nCmdShow; |
|
1182 |
||
1183 |
AwtFrame* owningFrame = GetOwningFrameOrDialog(); |
|
1184 |
if (IsFocusableWindow() && IsAutoRequestFocus() && owningFrame != NULL && |
|
1185 |
::GetForegroundWindow() == owningFrame->GetHWnd()) |
|
1186 |
{ |
|
1187 |
nCmdShow = SW_SHOW; |
|
1188 |
} else { |
|
1189 |
nCmdShow = SW_SHOWNA; |
|
1190 |
} |
|
1191 |
||
1192 |
BOOL locationByPlatform = env->GetBooleanField(GetTarget(env), AwtWindow::locationByPlatformID); |
|
1193 |
||
1194 |
if (locationByPlatform) { |
|
1195 |
moveToDefaultLocation(); |
|
1196 |
} |
|
1197 |
||
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
1198 |
EnableTranslucency(TRUE); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
1199 |
|
2 | 1200 |
// The following block exists to support Menu/Tooltip animation for |
1201 |
// Swing programs in a way which avoids introducing any new public api into |
|
1202 |
// AWT or Swing. |
|
1203 |
// This code should eventually be replaced by a better longterm solution |
|
1204 |
// which might involve tagging java.awt.Window instances with a semantic |
|
1205 |
// property so platforms can animate/decorate/etc accordingly. |
|
1206 |
// |
|
1954 | 1207 |
if (JNU_IsInstanceOfByName(env, target, "com/sun/java/swing/plaf/windows/WindowsPopupWindow") > 0) |
2 | 1208 |
{ |
1209 |
// need this global ref to make the class unloadable (see 6500204) |
|
1210 |
static jclass windowsPopupWindowCls; |
|
1211 |
static jfieldID windowTypeFID = NULL; |
|
1212 |
jint windowType = 0; |
|
1213 |
BOOL animateflag = FALSE; |
|
1214 |
BOOL fadeflag = FALSE; |
|
1215 |
DWORD animateStyle = 0; |
|
1216 |
||
1217 |
if (windowTypeFID == NULL) { |
|
1218 |
// Initialize Window type constants ONCE... |
|
1219 |
||
1220 |
jfieldID windowTYPESFID[TYPES_COUNT]; |
|
1221 |
jclass cls = env->GetObjectClass(target); |
|
1222 |
windowTypeFID = env->GetFieldID(cls, "windowType", "I"); |
|
1223 |
||
1224 |
windowTYPESFID[UNSPECIFIED] = env->GetStaticFieldID(cls, "UNDEFINED_WINDOW_TYPE", "I"); |
|
1225 |
windowTYPESFID[TOOLTIP] = env->GetStaticFieldID(cls, "TOOLTIP_WINDOW_TYPE", "I"); |
|
1226 |
windowTYPESFID[MENU] = env->GetStaticFieldID(cls, "MENU_WINDOW_TYPE", "I"); |
|
1227 |
windowTYPESFID[SUBMENU] = env->GetStaticFieldID(cls, "SUBMENU_WINDOW_TYPE", "I"); |
|
1228 |
windowTYPESFID[POPUPMENU] = env->GetStaticFieldID(cls, "POPUPMENU_WINDOW_TYPE", "I"); |
|
1229 |
windowTYPESFID[COMBOBOX_POPUP] = env->GetStaticFieldID(cls, "COMBOBOX_POPUP_WINDOW_TYPE", "I"); |
|
1230 |
||
1231 |
for (int i=0; i < 6; i++) { |
|
1232 |
windowTYPES[i] = env->GetStaticIntField(cls, windowTYPESFID[i]); |
|
1233 |
} |
|
1234 |
windowsPopupWindowCls = (jclass) env->NewGlobalRef(cls); |
|
1235 |
env->DeleteLocalRef(cls); |
|
1236 |
} |
|
1237 |
windowType = env->GetIntField(target, windowTypeFID); |
|
1238 |
||
1239 |
if (windowType == windowTYPES[TOOLTIP]) { |
|
1954 | 1240 |
SystemParametersInfo(SPI_GETTOOLTIPANIMATION, 0, &animateflag, 0); |
1241 |
SystemParametersInfo(SPI_GETTOOLTIPFADE, 0, &fadeflag, 0); |
|
2 | 1242 |
if (animateflag) { |
1243 |
// AW_BLEND currently produces runtime parameter error |
|
1244 |
// animateStyle = fadeflag? AW_BLEND : AW_SLIDE | AW_VER_POSITIVE; |
|
1245 |
animateStyle = fadeflag? 0 : AW_SLIDE | AW_VER_POSITIVE; |
|
1246 |
} |
|
1247 |
} else if (windowType == windowTYPES[MENU] || windowType == windowTYPES[SUBMENU] || |
|
1248 |
windowType == windowTYPES[POPUPMENU]) { |
|
1249 |
SystemParametersInfo(SPI_GETMENUANIMATION, 0, &animateflag, 0); |
|
1250 |
if (animateflag) { |
|
1954 | 1251 |
SystemParametersInfo(SPI_GETMENUFADE, 0, &fadeflag, 0); |
1252 |
if (fadeflag) { |
|
1253 |
// AW_BLEND currently produces runtime parameter error |
|
1254 |
//animateStyle = AW_BLEND; |
|
2 | 1255 |
} |
1256 |
if (animateStyle == 0 && !fadeflag) { |
|
1257 |
animateStyle = AW_SLIDE; |
|
1258 |
if (windowType == windowTYPES[MENU]) { |
|
1259 |
animateStyle |= AW_VER_POSITIVE; |
|
1260 |
} else if (windowType == windowTYPES[SUBMENU]) { |
|
1261 |
animateStyle |= AW_HOR_POSITIVE; |
|
1262 |
} else { /* POPUPMENU */ |
|
1263 |
animateStyle |= (AW_VER_POSITIVE | AW_HOR_POSITIVE); |
|
1264 |
} |
|
1265 |
} |
|
1266 |
} |
|
1267 |
} else if (windowType == windowTYPES[COMBOBOX_POPUP]) { |
|
1268 |
SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &animateflag, 0); |
|
1269 |
if (animateflag) { |
|
1270 |
animateStyle = AW_SLIDE | AW_VER_POSITIVE; |
|
1271 |
} |
|
1272 |
} |
|
1273 |
||
1274 |
if (animateStyle != 0) { |
|
1954 | 1275 |
BOOL result = ::AnimateWindow(hWnd, (DWORD)200, animateStyle); |
1276 |
if (!result) { |
|
1277 |
// TODO: log message |
|
1278 |
} else { |
|
1279 |
// WM_PAINT is not automatically sent when invoking AnimateWindow, |
|
1280 |
// so force an expose event |
|
1281 |
RECT rect; |
|
1282 |
::GetWindowRect(hWnd,&rect); |
|
1283 |
::ScreenToClient(hWnd, (LPPOINT)&rect); |
|
1284 |
::InvalidateRect(hWnd, &rect, TRUE); |
|
1285 |
::UpdateWindow(hWnd); |
|
1286 |
done = TRUE; |
|
2 | 1287 |
} |
1288 |
} |
|
1289 |
} |
|
1290 |
if (!done) { |
|
2646
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1291 |
// transient windows shouldn't change the owner window's position in the z-order |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1292 |
if (IsRetainingHierarchyZOrder()){ |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1293 |
UINT flags = SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER; |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1294 |
if (nCmdShow == SW_SHOWNA) { |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1295 |
flags |= SWP_NOACTIVATE; |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1296 |
} |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1297 |
::SetWindowPos(GetHWnd(), HWND_TOPMOST, 0, 0, 0, 0, flags); |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1298 |
} else { |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1299 |
::ShowWindow(GetHWnd(), nCmdShow); |
ab13ed73d1f5
6770457: Using ToolTips causes inactive app window to exhibit active window behavior
dcherepanov
parents:
2640
diff
changeset
|
1300 |
} |
2 | 1301 |
} |
1302 |
env->DeleteLocalRef(target); |
|
1303 |
} |
|
1304 |
||
1305 |
/* |
|
1306 |
* Get and return the insets for this window (container, really). |
|
1307 |
* Calculate & cache them while we're at it, for use by AwtGraphics |
|
1308 |
*/ |
|
1309 |
BOOL AwtWindow::UpdateInsets(jobject insets) |
|
1310 |
{ |
|
1311 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1312 |
DASSERT(GetPeer(env) != NULL); |
|
1313 |
if (env->EnsureLocalCapacity(2) < 0) { |
|
1314 |
return FALSE; |
|
1315 |
} |
|
1316 |
||
1317 |
// fix 4167248 : don't update insets when frame is iconified |
|
1318 |
// to avoid bizarre window/client rectangles |
|
1319 |
if (::IsIconic(GetHWnd())) { |
|
1320 |
return FALSE; |
|
1321 |
} |
|
1322 |
||
1323 |
/* |
|
1324 |
* Code to calculate insets. Stores results in frame's data |
|
1325 |
* members, and in the peer's Inset object. |
|
1326 |
*/ |
|
1327 |
RECT outside; |
|
1328 |
RECT inside; |
|
1329 |
int extraBottomInsets = 0; |
|
1330 |
||
1331 |
::GetClientRect(GetHWnd(), &inside); |
|
1332 |
::GetWindowRect(GetHWnd(), &outside); |
|
1333 |
||
1334 |
/* Update our inset member */ |
|
1335 |
if (outside.right - outside.left > 0 && outside.bottom - outside.top > 0) { |
|
1336 |
::MapWindowPoints(GetHWnd(), 0, (LPPOINT)&inside, 2); |
|
1337 |
m_insets.top = inside.top - outside.top; |
|
1338 |
m_insets.bottom = outside.bottom - inside.bottom + extraBottomInsets; |
|
1339 |
m_insets.left = inside.left - outside.left; |
|
1340 |
m_insets.right = outside.right - inside.right; |
|
1341 |
} else { |
|
1342 |
m_insets.top = -1; |
|
1343 |
} |
|
1344 |
if (m_insets.left < 0 || m_insets.top < 0 || |
|
1345 |
m_insets.right < 0 || m_insets.bottom < 0) |
|
1346 |
{ |
|
1347 |
/* This window hasn't been sized yet -- use system metrics. */ |
|
1348 |
jobject target = GetTarget(env); |
|
1349 |
if (IsUndecorated() == FALSE) { |
|
1350 |
/* Get outer frame sizes. */ |
|
1351 |
LONG style = GetStyle(); |
|
1352 |
if (style & WS_THICKFRAME) { |
|
1353 |
m_insets.left = m_insets.right = |
|
1354 |
::GetSystemMetrics(SM_CXSIZEFRAME); |
|
1355 |
m_insets.top = m_insets.bottom = |
|
1356 |
::GetSystemMetrics(SM_CYSIZEFRAME); |
|
1357 |
} else { |
|
1358 |
m_insets.left = m_insets.right = |
|
1359 |
::GetSystemMetrics(SM_CXDLGFRAME); |
|
1360 |
m_insets.top = m_insets.bottom = |
|
1361 |
::GetSystemMetrics(SM_CYDLGFRAME); |
|
1362 |
} |
|
1363 |
||
1364 |
||
1365 |
/* Add in title. */ |
|
1366 |
m_insets.top += ::GetSystemMetrics(SM_CYCAPTION); |
|
1367 |
} |
|
1368 |
else { |
|
1369 |
/* fix for 4418125: Undecorated frames are off by one */ |
|
1370 |
/* undo the -1 set above */ |
|
1371 |
/* Additional fix for 5059656 */ |
|
1372 |
/* Also, 5089312: Window insets should be 0. */ |
|
1373 |
::memset(&m_insets, 0, sizeof(m_insets)); |
|
1374 |
} |
|
1375 |
||
1376 |
/* Add in menuBar, if any. */ |
|
1377 |
if (JNU_IsInstanceOfByName(env, target, "java/awt/Frame") > 0 && |
|
1378 |
((AwtFrame*)this)->GetMenuBar()) { |
|
1379 |
m_insets.top += ::GetSystemMetrics(SM_CYMENU); |
|
1380 |
} |
|
1381 |
m_insets.bottom += extraBottomInsets; |
|
1382 |
env->DeleteLocalRef(target); |
|
1383 |
} |
|
1384 |
||
1385 |
BOOL insetsChanged = FALSE; |
|
1386 |
||
1387 |
jobject peer = GetPeer(env); |
|
1388 |
/* Get insets into our peer directly */ |
|
1389 |
jobject peerInsets = (env)->GetObjectField(peer, AwtPanel::insets_ID); |
|
1390 |
DASSERT(!safe_ExceptionOccurred(env)); |
|
1391 |
if (peerInsets != NULL) { // may have been called during creation |
|
1392 |
(env)->SetIntField(peerInsets, AwtInsets::topID, m_insets.top); |
|
1393 |
(env)->SetIntField(peerInsets, AwtInsets::bottomID, |
|
1394 |
m_insets.bottom); |
|
1395 |
(env)->SetIntField(peerInsets, AwtInsets::leftID, m_insets.left); |
|
1396 |
(env)->SetIntField(peerInsets, AwtInsets::rightID, m_insets.right); |
|
1397 |
} |
|
1398 |
/* Get insets into the Inset object (if any) that was passed */ |
|
1399 |
if (insets != NULL) { |
|
1400 |
(env)->SetIntField(insets, AwtInsets::topID, m_insets.top); |
|
1401 |
(env)->SetIntField(insets, AwtInsets::bottomID, m_insets.bottom); |
|
1402 |
(env)->SetIntField(insets, AwtInsets::leftID, m_insets.left); |
|
1403 |
(env)->SetIntField(insets, AwtInsets::rightID, m_insets.right); |
|
1404 |
} |
|
1405 |
env->DeleteLocalRef(peerInsets); |
|
1406 |
||
1407 |
insetsChanged = !::EqualRect( &m_old_insets, &m_insets ); |
|
1408 |
::CopyRect( &m_old_insets, &m_insets ); |
|
1409 |
||
887 | 1410 |
if (insetsChanged) { |
2 | 1411 |
// Since insets are changed we need to update the surfaceData object |
1412 |
// to reflect that change |
|
1413 |
env->CallVoidMethod(peer, AwtComponent::replaceSurfaceDataLaterMID); |
|
1414 |
} |
|
1415 |
||
1416 |
return insetsChanged; |
|
1417 |
} |
|
1418 |
||
1419 |
/** |
|
1420 |
* Sometimes we need the hWnd that actually owns this Window's hWnd (if |
|
1421 |
* there is an owner). |
|
1422 |
*/ |
|
1423 |
HWND AwtWindow::GetTopLevelHWnd() |
|
1424 |
{ |
|
1425 |
return m_owningFrameDialog ? m_owningFrameDialog->GetHWnd() : |
|
1426 |
GetHWnd(); |
|
1427 |
} |
|
1428 |
||
1429 |
/* |
|
1430 |
* Although this function sends ComponentEvents, it needs to be defined |
|
1431 |
* here because only top-level windows need to have move and resize |
|
1432 |
* events fired from native code. All contained windows have these events |
|
1433 |
* fired from common Java code. |
|
1434 |
*/ |
|
1435 |
void AwtWindow::SendComponentEvent(jint eventId) |
|
1436 |
{ |
|
1437 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1438 |
||
1439 |
static jclass classEvent = NULL; |
|
1440 |
if (classEvent == NULL) { |
|
1441 |
if (env->PushLocalFrame(1) < 0) |
|
1442 |
return; |
|
1443 |
classEvent = env->FindClass("java/awt/event/ComponentEvent"); |
|
1444 |
if (classEvent != NULL) { |
|
1445 |
classEvent = (jclass)env->NewGlobalRef(classEvent); |
|
1446 |
} |
|
1447 |
env->PopLocalFrame(0); |
|
1448 |
} |
|
1449 |
static jmethodID eventInitMID = NULL; |
|
1450 |
if (eventInitMID == NULL) { |
|
1451 |
eventInitMID = env->GetMethodID(classEvent, "<init>", |
|
1452 |
"(Ljava/awt/Component;I)V"); |
|
1453 |
if (eventInitMID == NULL) { |
|
1454 |
return; |
|
1455 |
} |
|
1456 |
} |
|
1457 |
if (env->EnsureLocalCapacity(2) < 0) { |
|
1458 |
return; |
|
1459 |
} |
|
1460 |
jobject target = GetTarget(env); |
|
1461 |
jobject event = env->NewObject(classEvent, eventInitMID, |
|
1462 |
target, eventId); |
|
1463 |
DASSERT(!safe_ExceptionOccurred(env)); |
|
1464 |
DASSERT(event != NULL); |
|
1465 |
SendEvent(event); |
|
1466 |
||
1467 |
env->DeleteLocalRef(target); |
|
1468 |
env->DeleteLocalRef(event); |
|
1469 |
} |
|
1470 |
||
1471 |
void AwtWindow::SendWindowEvent(jint id, HWND opposite, |
|
1472 |
jint oldState, jint newState) |
|
1473 |
{ |
|
1474 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1475 |
||
1476 |
static jclass wClassEvent; |
|
1477 |
if (wClassEvent == NULL) { |
|
1478 |
if (env->PushLocalFrame(1) < 0) |
|
1479 |
return; |
|
1480 |
wClassEvent = env->FindClass("java/awt/event/WindowEvent"); |
|
1481 |
if (wClassEvent != NULL) { |
|
1482 |
wClassEvent = (jclass)env->NewGlobalRef(wClassEvent); |
|
1483 |
} |
|
1484 |
env->PopLocalFrame(0); |
|
1485 |
if (wClassEvent == NULL) { |
|
1486 |
return; |
|
1487 |
} |
|
1488 |
} |
|
1489 |
||
1490 |
static jmethodID wEventInitMID; |
|
1491 |
if (wEventInitMID == NULL) { |
|
1492 |
wEventInitMID = |
|
1493 |
env->GetMethodID(wClassEvent, "<init>", |
|
1494 |
"(Ljava/awt/Window;ILjava/awt/Window;II)V"); |
|
1495 |
DASSERT(wEventInitMID); |
|
1496 |
if (wEventInitMID == NULL) { |
|
1497 |
return; |
|
1498 |
} |
|
1499 |
} |
|
1500 |
||
1501 |
static jclass sequencedEventCls; |
|
1502 |
if (sequencedEventCls == NULL) { |
|
1503 |
jclass sequencedEventClsLocal |
|
1504 |
= env->FindClass("java/awt/SequencedEvent"); |
|
1505 |
DASSERT(sequencedEventClsLocal); |
|
1506 |
if (sequencedEventClsLocal == NULL) { |
|
1507 |
/* exception already thrown */ |
|
1508 |
return; |
|
1509 |
} |
|
1510 |
sequencedEventCls = |
|
1511 |
(jclass)env->NewGlobalRef(sequencedEventClsLocal); |
|
1512 |
env->DeleteLocalRef(sequencedEventClsLocal); |
|
1513 |
} |
|
1514 |
||
1515 |
static jmethodID sequencedEventConst; |
|
1516 |
if (sequencedEventConst == NULL) { |
|
1517 |
sequencedEventConst = |
|
1518 |
env->GetMethodID(sequencedEventCls, "<init>", |
|
1519 |
"(Ljava/awt/AWTEvent;)V"); |
|
1520 |
} |
|
1521 |
||
1522 |
if (env->EnsureLocalCapacity(3) < 0) { |
|
1523 |
return; |
|
1524 |
} |
|
1525 |
||
1526 |
jobject target = GetTarget(env); |
|
1527 |
jobject jOpposite = NULL; |
|
1528 |
if (opposite != NULL) { |
|
1529 |
AwtComponent *awtOpposite = AwtComponent::GetComponent(opposite); |
|
1530 |
if (awtOpposite != NULL) { |
|
1531 |
jOpposite = awtOpposite->GetTarget(env); |
|
1532 |
} |
|
1533 |
} |
|
1534 |
jobject event = env->NewObject(wClassEvent, wEventInitMID, target, id, |
|
1535 |
jOpposite, oldState, newState); |
|
1536 |
DASSERT(!safe_ExceptionOccurred(env)); |
|
1537 |
DASSERT(event != NULL); |
|
1538 |
if (jOpposite != NULL) { |
|
1539 |
env->DeleteLocalRef(jOpposite); jOpposite = NULL; |
|
1540 |
} |
|
1541 |
env->DeleteLocalRef(target); target = NULL; |
|
1542 |
||
1543 |
if (id == java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS || |
|
1544 |
id == java_awt_event_WindowEvent_WINDOW_LOST_FOCUS) |
|
1545 |
{ |
|
1546 |
jobject sequencedEvent = env->NewObject(sequencedEventCls, |
|
1547 |
sequencedEventConst, |
|
1548 |
event); |
|
1549 |
DASSERT(!safe_ExceptionOccurred(env)); |
|
1550 |
DASSERT(sequencedEvent != NULL); |
|
1551 |
env->DeleteLocalRef(event); |
|
1552 |
event = sequencedEvent; |
|
1553 |
} |
|
1554 |
||
1555 |
SendEvent(event); |
|
1556 |
||
1557 |
env->DeleteLocalRef(event); |
|
1558 |
} |
|
1559 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1560 |
BOOL AwtWindow::AwtSetActiveWindow(BOOL isMouseEventCause, UINT hittest) |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1561 |
{ |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1562 |
// Fix for 6458497. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1563 |
// Retreat if current foreground window is out of both our and embedder process. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1564 |
// The exception is when activation is requested due to a mouse event. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1565 |
if (!isMouseEventCause) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1566 |
HWND fgWindow = ::GetForegroundWindow(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1567 |
if (NULL != fgWindow) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1568 |
DWORD fgProcessID; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1569 |
::GetWindowThreadProcessId(fgWindow, &fgProcessID); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1570 |
if (fgProcessID != ::GetCurrentProcessId() |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1571 |
&& !AwtToolkit::GetInstance().IsEmbedderProcessId(fgProcessID)) |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1572 |
{ |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1573 |
return FALSE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1574 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1575 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1576 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1577 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1578 |
HWND proxyContainerHWnd = GetProxyToplevelContainer(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1579 |
HWND proxyHWnd = GetProxyFocusOwner(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1580 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1581 |
if (proxyContainerHWnd == NULL || proxyHWnd == NULL) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1582 |
return FALSE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1583 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1584 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1585 |
// Activate the proxy toplevel container |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1586 |
if (::GetActiveWindow() != proxyContainerHWnd) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1587 |
sm_suppressFocusAndActivation = TRUE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1588 |
::BringWindowToTop(proxyContainerHWnd); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1589 |
::SetForegroundWindow(proxyContainerHWnd); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1590 |
sm_suppressFocusAndActivation = FALSE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1591 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1592 |
if (::GetActiveWindow() != proxyContainerHWnd) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1593 |
return FALSE; // activation has been rejected |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1594 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1595 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1596 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1597 |
// Focus the proxy itself |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1598 |
if (::GetFocus() != proxyHWnd) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1599 |
sm_suppressFocusAndActivation = TRUE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1600 |
::SetFocus(proxyHWnd); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1601 |
sm_suppressFocusAndActivation = FALSE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1602 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1603 |
if (::GetFocus() != proxyHWnd) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1604 |
return FALSE; // focus has been rejected (that is unlikely) |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1605 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1606 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1607 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1608 |
const HWND focusedWindow = AwtComponent::GetFocusedWindow(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1609 |
if (focusedWindow != GetHWnd()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1610 |
if (focusedWindow != NULL) { |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1611 |
// Deactivate the old focused window |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1612 |
AwtWindow::SynthesizeWmActivate(FALSE, focusedWindow, GetHWnd()); |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1613 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1614 |
// Activate the new focused window. |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1615 |
AwtWindow::SynthesizeWmActivate(TRUE, GetHWnd(), focusedWindow); |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1616 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1617 |
return TRUE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1618 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1619 |
|
2 | 1620 |
MsgRouting AwtWindow::WmActivate(UINT nState, BOOL fMinimized, HWND opposite) |
1621 |
{ |
|
1622 |
jint type; |
|
1623 |
||
1624 |
if (nState != WA_INACTIVE) { |
|
1625 |
type = java_awt_event_WindowEvent_WINDOW_GAINED_FOCUS; |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1626 |
AwtComponent::SetFocusedWindow(GetHWnd()); |
2 | 1627 |
} else { |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1628 |
// The owner is not necassarily getting WM_ACTIVATE(WA_INACTIVE). |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1629 |
// So, initiate retaining the actualFocusedWindow. |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1630 |
AwtFrame *owner = GetOwningFrameOrDialog(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1631 |
if (owner) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1632 |
owner->CheckRetainActualFocusedWindow(opposite); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1633 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1634 |
|
2 | 1635 |
if (m_grabbedWindow != NULL && !m_grabbedWindow->IsOneOfOwnersOf(this)) { |
1636 |
m_grabbedWindow->Ungrab(); |
|
1637 |
} |
|
1638 |
type = java_awt_event_WindowEvent_WINDOW_LOST_FOCUS; |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1639 |
AwtComponent::SetFocusedWindow(NULL); |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1640 |
sm_focusOwner = NULL; |
2 | 1641 |
} |
1642 |
||
1643 |
SendWindowEvent(type, opposite); |
|
1644 |
return mrConsume; |
|
1645 |
} |
|
1646 |
||
1647 |
MsgRouting AwtWindow::WmCreate() |
|
1648 |
{ |
|
1649 |
return mrDoDefault; |
|
1650 |
} |
|
1651 |
||
1652 |
MsgRouting AwtWindow::WmClose() |
|
1653 |
{ |
|
1654 |
SendWindowEvent(java_awt_event_WindowEvent_WINDOW_CLOSING); |
|
1655 |
||
1656 |
/* Rely on above notification to handle quitting as needed */ |
|
1657 |
return mrConsume; |
|
1658 |
} |
|
1659 |
||
1660 |
MsgRouting AwtWindow::WmDestroy() |
|
1661 |
{ |
|
1662 |
SendWindowEvent(java_awt_event_WindowEvent_WINDOW_CLOSED); |
|
1663 |
return AwtComponent::WmDestroy(); |
|
1664 |
} |
|
1665 |
||
1666 |
MsgRouting AwtWindow::WmShowWindow(BOOL show, UINT status) |
|
1667 |
{ |
|
1668 |
/* |
|
1669 |
* Original fix for 4810575. Modified for 6386592. |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1670 |
* If a simple window gets disposed we should synthesize |
2 | 1671 |
* WM_ACTIVATE for its nearest owner. This is not performed by default because |
1672 |
* the owner frame/dialog is natively active. |
|
1673 |
*/ |
|
1674 |
HWND hwndSelf = GetHWnd(); |
|
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1675 |
HWND hwndOwner = ::GetParent(hwndSelf); |
2 | 1676 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1677 |
if (!show && IsSimpleWindow() && hwndSelf == AwtComponent::GetFocusedWindow() && |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1678 |
hwndOwner != NULL && ::IsWindowVisible(hwndOwner)) |
2 | 1679 |
{ |
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1680 |
AwtFrame *owner = (AwtFrame*)AwtComponent::GetComponent(hwndOwner); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1681 |
if (owner != NULL) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1682 |
owner->AwtSetActiveWindow(); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
1683 |
} |
2 | 1684 |
} |
1685 |
||
1686 |
//Fixed 4842599: REGRESSION: JPopupMenu not Hidden Properly After Iconified and Deiconified |
|
1687 |
if (show && (status == SW_PARENTOPENING)) { |
|
1688 |
if (!IsVisible()) { |
|
1689 |
return mrConsume; |
|
1690 |
} |
|
1691 |
} |
|
1692 |
return AwtCanvas::WmShowWindow(show, status); |
|
1693 |
} |
|
1694 |
||
1695 |
/* |
|
1696 |
* Override AwtComponent's move handling to first update the |
|
1697 |
* java AWT target's position fields directly, since Windows |
|
1698 |
* and below can be resized from outside of java (by user) |
|
1699 |
*/ |
|
1700 |
MsgRouting AwtWindow::WmMove(int x, int y) |
|
1701 |
{ |
|
1702 |
if ( ::IsIconic(GetHWnd()) ) { |
|
1703 |
// fixes 4065534 (robi.khan@eng) |
|
1704 |
// if a window is iconified we don't want to update |
|
1705 |
// it's target's position since minimized Win32 windows |
|
1706 |
// move to -32000, -32000 for whatever reason |
|
1707 |
// NOTE: See also AwtWindow::Reshape |
|
1708 |
return mrDoDefault; |
|
1709 |
} |
|
1710 |
||
1711 |
if (m_screenNum == -1) { |
|
1712 |
// Set initial value |
|
1713 |
m_screenNum = GetScreenImOn(); |
|
1714 |
} |
|
1715 |
else { |
|
1716 |
CheckIfOnNewScreen(); |
|
1717 |
} |
|
1718 |
||
1719 |
/* Update the java AWT target component's fields directly */ |
|
1720 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1721 |
if (env->EnsureLocalCapacity(1) < 0) { |
|
1722 |
return mrConsume; |
|
1723 |
} |
|
1724 |
jobject peer = GetPeer(env); |
|
1725 |
jobject target = env->GetObjectField(peer, AwtObject::targetID); |
|
1726 |
||
1727 |
RECT rect; |
|
1728 |
::GetWindowRect(GetHWnd(), &rect); |
|
1729 |
||
1730 |
(env)->SetIntField(target, AwtComponent::xID, rect.left); |
|
1731 |
(env)->SetIntField(target, AwtComponent::yID, rect.top); |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
1732 |
(env)->SetIntField(peer, AwtWindow::sysXID, rect.left); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
1733 |
(env)->SetIntField(peer, AwtWindow::sysYID, rect.top); |
2 | 1734 |
SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_MOVED); |
1735 |
||
1736 |
env->DeleteLocalRef(target); |
|
1737 |
return AwtComponent::WmMove(x, y); |
|
1738 |
} |
|
1739 |
||
1740 |
MsgRouting AwtWindow::WmGetMinMaxInfo(LPMINMAXINFO lpmmi) |
|
1741 |
{ |
|
1742 |
MsgRouting r = AwtCanvas::WmGetMinMaxInfo(lpmmi); |
|
1743 |
if ((m_minSize.x == 0) && (m_minSize.y == 0)) { |
|
1744 |
return r; |
|
1745 |
} |
|
1746 |
lpmmi->ptMinTrackSize.x = m_minSize.x; |
|
1747 |
lpmmi->ptMinTrackSize.y = m_minSize.y; |
|
1748 |
return mrConsume; |
|
1749 |
} |
|
1750 |
||
1751 |
MsgRouting AwtWindow::WmSizing() |
|
1752 |
{ |
|
1753 |
if (!AwtToolkit::GetInstance().IsDynamicLayoutActive()) { |
|
1754 |
return mrDoDefault; |
|
1755 |
} |
|
1756 |
||
1757 |
DTRACE_PRINTLN("AwtWindow::WmSizing fullWindowDragEnabled"); |
|
1758 |
||
1759 |
SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_RESIZED); |
|
1760 |
||
1761 |
HWND thisHwnd = GetHWnd(); |
|
1762 |
if (thisHwnd == NULL) { |
|
1763 |
return mrDoDefault; |
|
1764 |
} |
|
1765 |
||
1766 |
// Call WComponentPeer::dynamicallyLayoutContainer() |
|
1767 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1768 |
jobject peer = GetPeer(env); |
|
1769 |
JNU_CallMethodByName(env, NULL, peer, "dynamicallyLayoutContainer", "()V"); |
|
1770 |
DASSERT(!safe_ExceptionOccurred(env)); |
|
1771 |
||
1772 |
return mrDoDefault; |
|
1773 |
} |
|
1774 |
||
1775 |
/* |
|
1776 |
* Override AwtComponent's size handling to first update the |
|
1777 |
* java AWT target's dimension fields directly, since Windows |
|
1778 |
* and below can be resized from outside of java (by user) |
|
1779 |
*/ |
|
1780 |
MsgRouting AwtWindow::WmSize(UINT type, int w, int h) |
|
1781 |
{ |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1782 |
currentWmSizeState = type; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1783 |
|
2 | 1784 |
if (type == SIZE_MINIMIZED) { |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1785 |
UpdateSecurityWarningVisibility(); |
2 | 1786 |
return mrDoDefault; |
1787 |
} |
|
1788 |
||
1789 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1790 |
if (env->EnsureLocalCapacity(1) < 0) |
|
1791 |
return mrDoDefault; |
|
1792 |
jobject target = GetTarget(env); |
|
1793 |
// fix 4167248 : ensure the insets are up-to-date before using |
|
1794 |
BOOL insetsChanged = UpdateInsets(NULL); |
|
1795 |
int newWidth = w + m_insets.left + m_insets.right; |
|
1796 |
int newHeight = h + m_insets.top + m_insets.bottom; |
|
1797 |
||
1798 |
(env)->SetIntField(target, AwtComponent::widthID, newWidth); |
|
1799 |
(env)->SetIntField(target, AwtComponent::heightID, newHeight); |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
1800 |
|
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
1801 |
jobject peer = GetPeer(env); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
1802 |
(env)->SetIntField(peer, AwtWindow::sysWID, newWidth); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
1803 |
(env)->SetIntField(peer, AwtWindow::sysHID, newHeight); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
1804 |
|
2 | 1805 |
if (!AwtWindow::IsResizing()) { |
1806 |
WindowResized(); |
|
1807 |
} |
|
1808 |
||
1809 |
env->DeleteLocalRef(target); |
|
1810 |
return AwtComponent::WmSize(type, w, h); |
|
1811 |
} |
|
1812 |
||
1813 |
MsgRouting AwtWindow::WmPaint(HDC) |
|
1814 |
{ |
|
1815 |
PaintUpdateRgn(&m_insets); |
|
1816 |
return mrConsume; |
|
1817 |
} |
|
1818 |
||
1819 |
MsgRouting AwtWindow::WmSettingChange(UINT wFlag, LPCTSTR pszSection) |
|
1820 |
{ |
|
1821 |
if (wFlag == SPI_SETNONCLIENTMETRICS) { |
|
1822 |
// user changed window metrics in |
|
1823 |
// Control Panel->Display->Appearance |
|
1824 |
// which may cause window insets to change |
|
1825 |
UpdateInsets(NULL); |
|
1826 |
||
1827 |
// [rray] fix for 4407329 - Changing Active Window Border width in display |
|
1828 |
// settings causes problems |
|
1829 |
WindowResized(); |
|
1830 |
Invalidate(NULL); |
|
1831 |
||
1832 |
return mrConsume; |
|
1833 |
} |
|
1834 |
return mrDoDefault; |
|
1835 |
} |
|
1836 |
||
1837 |
MsgRouting AwtWindow::WmNcCalcSize(BOOL fCalcValidRects, |
|
1838 |
LPNCCALCSIZE_PARAMS lpncsp, LRESULT& retVal) |
|
1839 |
{ |
|
1840 |
MsgRouting mrRetVal = mrDoDefault; |
|
1841 |
||
1842 |
if (fCalcValidRects == FALSE) { |
|
1843 |
return mrDoDefault; |
|
1844 |
} |
|
1845 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
1846 |
if (env->EnsureLocalCapacity(2) < 0) { |
|
1847 |
return mrConsume; |
|
1848 |
} |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1849 |
// WM_NCCALCSIZE is usually in response to a resize, but |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1850 |
// also can be triggered by SetWindowPos(SWP_FRAMECHANGED), |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1851 |
// which means the insets will have changed - rnk 4/7/1998 |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1852 |
retVal = static_cast<UINT>(DefWindowProc( |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1853 |
WM_NCCALCSIZE, fCalcValidRects, reinterpret_cast<LPARAM>(lpncsp))); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1854 |
if (HasValidRect()) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1855 |
UpdateInsets(NULL); |
2 | 1856 |
} |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
1857 |
mrRetVal = mrConsume; |
2 | 1858 |
return mrRetVal; |
1859 |
} |
|
1860 |
||
1861 |
MsgRouting AwtWindow::WmNcHitTest(UINT x, UINT y, LRESULT& retVal) |
|
1862 |
{ |
|
1863 |
// If this window is blocked by modal dialog, return HTCLIENT for any point of it. |
|
1864 |
// That prevents it to be moved or resized using the mouse. Disabling these |
|
1865 |
// actions to be launched from sysmenu is implemented by ignoring WM_SYSCOMMAND |
|
1866 |
if (::IsWindow(GetModalBlocker(GetHWnd()))) { |
|
1867 |
retVal = HTCLIENT; |
|
1868 |
} else { |
|
1869 |
retVal = DefWindowProc(WM_NCHITTEST, 0, MAKELPARAM(x, y)); |
|
1870 |
} |
|
1871 |
return mrConsume; |
|
1872 |
} |
|
1873 |
||
1874 |
MsgRouting AwtWindow::WmGetIcon(WPARAM iconType, LRESULT& retValue) |
|
1875 |
{ |
|
1876 |
return mrDoDefault; |
|
1877 |
} |
|
1878 |
||
1879 |
LRESULT AwtWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) |
|
1880 |
{ |
|
1881 |
MsgRouting mr = mrDoDefault; |
|
1882 |
LRESULT retValue = 0L; |
|
1883 |
||
1884 |
switch(message) { |
|
1885 |
case WM_GETICON: |
|
1886 |
mr = WmGetIcon(wParam, retValue); |
|
1887 |
break; |
|
1888 |
case WM_SYSCOMMAND: |
|
1889 |
//Fixed 6355340: Contents of frame are not layed out properly on maximize |
|
1890 |
if ((wParam & 0xFFF0) == SC_SIZE) { |
|
1891 |
AwtWindow::sm_resizing = TRUE; |
|
1892 |
mr = WmSysCommand(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); |
|
1893 |
if (mr != mrConsume) { |
|
1894 |
AwtWindow::DefWindowProc(message, wParam, lParam); |
|
1895 |
} |
|
1896 |
AwtWindow::sm_resizing = FALSE; |
|
1897 |
if (!AwtToolkit::GetInstance().IsDynamicLayoutActive()) { |
|
1898 |
WindowResized(); |
|
1899 |
} |
|
1900 |
mr = mrConsume; |
|
1901 |
} |
|
1902 |
break; |
|
1903 |
} |
|
1904 |
||
1905 |
if (mr != mrConsume) { |
|
1906 |
retValue = AwtCanvas::WindowProc(message, wParam, lParam); |
|
1907 |
} |
|
1908 |
return retValue; |
|
1909 |
} |
|
1910 |
||
1911 |
/* |
|
1912 |
* Fix for BugTraq ID 4041703: keyDown not being invoked. |
|
1913 |
* This method overrides AwtCanvas::HandleEvent() since |
|
1914 |
* an empty Window always receives the focus on the activation |
|
1915 |
* so we don't have to modify the behavior. |
|
1916 |
*/ |
|
1917 |
MsgRouting AwtWindow::HandleEvent(MSG *msg, BOOL synthetic) |
|
1918 |
{ |
|
1919 |
return AwtComponent::HandleEvent(msg, synthetic); |
|
1920 |
} |
|
1921 |
||
1922 |
void AwtWindow::WindowResized() |
|
1923 |
{ |
|
1924 |
SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_RESIZED); |
|
1925 |
// Need to replace surfaceData on resize to catch changes to |
|
1926 |
// various component-related values, such as insets |
|
887 | 1927 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
1928 |
env->CallVoidMethod(m_peerObject, AwtComponent::replaceSurfaceDataLaterMID); |
|
2 | 1929 |
} |
1930 |
||
1931 |
BOOL CALLBACK InvalidateChildRect(HWND hWnd, LPARAM) |
|
1932 |
{ |
|
1933 |
TRY; |
|
1934 |
||
1935 |
::InvalidateRect(hWnd, NULL, TRUE); |
|
1936 |
return TRUE; |
|
1937 |
||
1938 |
CATCH_BAD_ALLOC_RET(FALSE); |
|
1939 |
} |
|
1940 |
||
1941 |
void AwtWindow::Invalidate(RECT* r) |
|
1942 |
{ |
|
1943 |
::InvalidateRect(GetHWnd(), NULL, TRUE); |
|
1944 |
::EnumChildWindows(GetHWnd(), (WNDENUMPROC)InvalidateChildRect, 0); |
|
1945 |
} |
|
1946 |
||
1947 |
BOOL AwtWindow::IsResizable() { |
|
1948 |
return m_isResizable; |
|
1949 |
} |
|
1950 |
||
1951 |
void AwtWindow::SetResizable(BOOL isResizable) |
|
1952 |
{ |
|
1953 |
m_isResizable = isResizable; |
|
1954 |
if (IsEmbeddedFrame()) { |
|
1955 |
return; |
|
1956 |
} |
|
1957 |
LONG style = GetStyle(); |
|
1958 |
LONG resizeStyle = WS_MAXIMIZEBOX; |
|
1959 |
||
1960 |
if (IsUndecorated() == FALSE) { |
|
1961 |
resizeStyle |= WS_THICKFRAME; |
|
1962 |
} |
|
1963 |
||
1964 |
if (isResizable) { |
|
1965 |
style |= resizeStyle; |
|
1966 |
} else { |
|
1967 |
style &= ~resizeStyle; |
|
1968 |
} |
|
1969 |
SetStyle(style); |
|
1970 |
RedrawNonClient(); |
|
1971 |
} |
|
1972 |
||
1973 |
// SetWindowPos flags to cause frame edge to be recalculated |
|
1974 |
static const UINT SwpFrameChangeFlags = |
|
1975 |
SWP_FRAMECHANGED | /* causes WM_NCCALCSIZE to be called */ |
|
1976 |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | |
|
1977 |
SWP_NOACTIVATE | SWP_NOCOPYBITS | |
|
1978 |
SWP_NOREPOSITION | SWP_NOSENDCHANGING; |
|
1979 |
||
1980 |
// |
|
1981 |
// Forces WM_NCCALCSIZE to be called to recalculate |
|
1982 |
// window border (updates insets) without redrawing it |
|
1983 |
// |
|
1984 |
void AwtWindow::RecalcNonClient() |
|
1985 |
{ |
|
1986 |
::SetWindowPos(GetHWnd(), (HWND) NULL, 0, 0, 0, 0, SwpFrameChangeFlags|SWP_NOREDRAW); |
|
1987 |
} |
|
1988 |
||
1989 |
// |
|
1990 |
// Forces WM_NCCALCSIZE to be called to recalculate |
|
1991 |
// window border (updates insets) and redraws border to match |
|
1992 |
// |
|
1993 |
void AwtWindow::RedrawNonClient() |
|
1994 |
{ |
|
1995 |
::SetWindowPos(GetHWnd(), (HWND) NULL, 0, 0, 0, 0, SwpFrameChangeFlags|SWP_ASYNCWINDOWPOS); |
|
1996 |
} |
|
1997 |
||
1998 |
int AwtWindow::GetScreenImOn() { |
|
1954 | 1999 |
HMONITOR hmon; |
2 | 2000 |
int scrnNum; |
2001 |
||
1954 | 2002 |
hmon = ::MonitorFromWindow(GetHWnd(), MONITOR_DEFAULTTOPRIMARY); |
2 | 2003 |
DASSERT(hmon != NULL); |
2004 |
||
1954 | 2005 |
scrnNum = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hmon); |
2 | 2006 |
DASSERT(scrnNum > -1); |
2007 |
||
2008 |
return scrnNum; |
|
2009 |
} |
|
2010 |
||
2011 |
/* Check to see if we've been moved onto another screen. |
|
2012 |
* If so, update internal data, surfaces, etc. |
|
2013 |
*/ |
|
2014 |
||
2015 |
void AwtWindow::CheckIfOnNewScreen() { |
|
2016 |
int curScrn = GetScreenImOn(); |
|
2017 |
||
2018 |
if (curScrn != m_screenNum) { // we've been moved |
|
2019 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2020 |
||
2021 |
jclass peerCls = env->GetObjectClass(m_peerObject); |
|
2022 |
DASSERT(peerCls); |
|
2023 |
||
2024 |
jmethodID draggedID = env->GetMethodID(peerCls, "draggedToNewScreen", |
|
2025 |
"()V"); |
|
2026 |
DASSERT(draggedID); |
|
2027 |
||
2028 |
env->CallVoidMethod(m_peerObject, draggedID); |
|
2029 |
m_screenNum = curScrn; |
|
2030 |
||
2031 |
env->DeleteLocalRef(peerCls); |
|
2032 |
} |
|
2033 |
} |
|
2034 |
||
2035 |
BOOL AwtWindow::IsFocusableWindow() { |
|
2036 |
/* |
|
2037 |
* For Window/Frame/Dialog to accept focus it should: |
|
2038 |
* - be focusable; |
|
2039 |
* - be not blocked by any modal blocker. |
|
2040 |
*/ |
|
2041 |
BOOL focusable = m_isFocusableWindow && !::IsWindow(AwtWindow::GetModalBlocker(GetHWnd())); |
|
2042 |
AwtFrame *owner = GetOwningFrameOrDialog(); // NULL for Frame and Dialog |
|
2043 |
||
2044 |
if (owner != NULL) { |
|
2045 |
/* |
|
2046 |
* Also for Window (not Frame/Dialog) to accept focus: |
|
2047 |
* - its decorated parent should accept focus; |
|
2048 |
*/ |
|
2049 |
focusable = focusable && owner->IsFocusableWindow(); |
|
2050 |
} |
|
2051 |
return focusable; |
|
2052 |
} |
|
2053 |
||
2054 |
void AwtWindow::SetModalBlocker(HWND window, HWND blocker) { |
|
2055 |
if (!::IsWindow(window)) { |
|
2056 |
return; |
|
2057 |
} |
|
122
0a8658c7d538
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents:
2
diff
changeset
|
2058 |
|
2 | 2059 |
if (::IsWindow(blocker)) { |
2060 |
::SetProp(window, ModalBlockerProp, reinterpret_cast<HANDLE>(blocker)); |
|
122
0a8658c7d538
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents:
2
diff
changeset
|
2061 |
::EnableWindow(window, FALSE); |
2 | 2062 |
} else { |
2063 |
::RemoveProp(window, ModalBlockerProp); |
|
122
0a8658c7d538
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents:
2
diff
changeset
|
2064 |
AwtComponent *comp = AwtComponent::GetComponent(window); |
0a8658c7d538
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents:
2
diff
changeset
|
2065 |
// we don't expect to be called with non-java HWNDs |
0a8658c7d538
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents:
2
diff
changeset
|
2066 |
DASSERT(comp && comp->IsTopLevel()); |
0a8658c7d538
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents:
2
diff
changeset
|
2067 |
// we should not unblock disabled toplevels |
0a8658c7d538
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
dcherepanov
parents:
2
diff
changeset
|
2068 |
::EnableWindow(window, comp->isEnabled()); |
2 | 2069 |
} |
2070 |
} |
|
2071 |
||
2072 |
void AwtWindow::SetAndActivateModalBlocker(HWND window, HWND blocker) { |
|
2073 |
if (!::IsWindow(window)) { |
|
2074 |
return; |
|
2075 |
} |
|
2076 |
AwtWindow::SetModalBlocker(window, blocker); |
|
2077 |
if (::IsWindow(blocker)) { |
|
2078 |
// We must check for visibility. Otherwise invisible dialog will receive WM_ACTIVATE. |
|
2079 |
if (::IsWindowVisible(blocker)) { |
|
2080 |
::BringWindowToTop(blocker); |
|
2081 |
::SetForegroundWindow(blocker); |
|
2082 |
} |
|
2083 |
} |
|
2084 |
} |
|
2085 |
||
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2086 |
HWND AwtWindow::GetTopmostModalBlocker(HWND window) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2087 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2088 |
HWND ret, blocker = NULL; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2089 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2090 |
do { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2091 |
ret = blocker; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2092 |
blocker = AwtWindow::GetModalBlocker(window); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2093 |
window = blocker; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2094 |
} while (::IsWindow(blocker)); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2095 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2096 |
return ret; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2097 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
2098 |
|
2 | 2099 |
void AwtWindow::FlashWindowEx(HWND hWnd, UINT count, DWORD timeout, DWORD flags) { |
2100 |
FLASHWINFO fi; |
|
2101 |
fi.cbSize = sizeof(fi); |
|
2102 |
fi.hwnd = hWnd; |
|
2103 |
fi.dwFlags = flags; |
|
2104 |
fi.uCount = count; |
|
2105 |
fi.dwTimeout = timeout; |
|
2106 |
::FlashWindowEx(&fi); |
|
2107 |
} |
|
2108 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2109 |
jboolean |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2110 |
AwtWindow::_RequestWindowFocus(void *param) |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2111 |
{ |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2112 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2113 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2114 |
RequestWindowFocusStruct *rfs = (RequestWindowFocusStruct *)param; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2115 |
jobject self = rfs->component; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2116 |
jboolean isMouseEventCause = rfs->isMouseEventCause; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2117 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2118 |
jboolean result = JNI_FALSE; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2119 |
AwtWindow *window = NULL; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2120 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2121 |
PDATA pData; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2122 |
JNI_CHECK_NULL_GOTO(self, "peer", ret); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2123 |
pData = JNI_GET_PDATA(self); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2124 |
if (pData == NULL) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2125 |
// do nothing just return false |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2126 |
goto ret; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2127 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2128 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2129 |
window = (AwtWindow *)pData; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2130 |
if (::IsWindow(window->GetHWnd())) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2131 |
result = (jboolean)window->SendMessage(WM_AWT_WINDOW_SETACTIVE, (WPARAM)isMouseEventCause, 0); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2132 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2133 |
ret: |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2134 |
env->DeleteGlobalRef(self); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2135 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2136 |
delete rfs; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2137 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2138 |
return result; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2139 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2140 |
|
2 | 2141 |
void AwtWindow::_ToFront(void *param) |
2142 |
{ |
|
2143 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2144 |
||
2145 |
jobject self = (jobject)param; |
|
2146 |
||
2147 |
AwtWindow *w = NULL; |
|
2148 |
||
2149 |
PDATA pData; |
|
2150 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2151 |
w = (AwtWindow *)pData; |
|
2152 |
if (::IsWindow(w->GetHWnd())) |
|
2153 |
{ |
|
2154 |
UINT flags = SWP_NOMOVE|SWP_NOSIZE; |
|
2155 |
BOOL focusable = w->IsFocusableWindow(); |
|
2156 |
BOOL autoRequestFocus = w->IsAutoRequestFocus(); |
|
2157 |
||
2158 |
if (!focusable || !autoRequestFocus) |
|
2159 |
{ |
|
2160 |
flags = flags|SWP_NOACTIVATE; |
|
2161 |
} |
|
2162 |
::SetWindowPos(w->GetHWnd(), HWND_TOP, 0, 0, 0, 0, flags); |
|
2163 |
if (focusable && autoRequestFocus) |
|
2164 |
{ |
|
2165 |
::SetForegroundWindow(w->GetHWnd()); |
|
2166 |
} |
|
2167 |
} |
|
2168 |
ret: |
|
2169 |
env->DeleteGlobalRef(self); |
|
2170 |
} |
|
2171 |
||
2172 |
void AwtWindow::_ToBack(void *param) |
|
2173 |
{ |
|
2174 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2175 |
||
2176 |
jobject self = (jobject)param; |
|
2177 |
||
2178 |
AwtWindow *w = NULL; |
|
2179 |
||
2180 |
PDATA pData; |
|
2181 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2182 |
w = (AwtWindow *)pData; |
|
2183 |
if (::IsWindow(w->GetHWnd())) |
|
2184 |
{ |
|
2185 |
HWND hwnd = w->GetHWnd(); |
|
2186 |
// if (AwtComponent::GetComponent(hwnd) == NULL) { |
|
2187 |
// // Window was disposed. Don't bother. |
|
2188 |
// return; |
|
2189 |
// } |
|
2190 |
||
2191 |
::SetWindowPos(hwnd, HWND_BOTTOM, 0, 0 ,0, 0, |
|
2192 |
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); |
|
2193 |
||
2194 |
// If hwnd is the foreground window or if *any* of its owners are, then |
|
2195 |
// we have to reset the foreground window. The reason is that when we send |
|
2196 |
// hwnd to back, all of its owners are sent to back as well. If any one of |
|
2197 |
// them is the foreground window, then it's possible that we could end up |
|
2198 |
// with a foreground window behind a window of another application. |
|
2199 |
HWND foregroundWindow = ::GetForegroundWindow(); |
|
2200 |
BOOL adjustForegroundWindow; |
|
2201 |
HWND toTest = hwnd; |
|
2202 |
do |
|
2203 |
{ |
|
2204 |
adjustForegroundWindow = (toTest == foregroundWindow); |
|
2205 |
if (adjustForegroundWindow) |
|
2206 |
{ |
|
2207 |
break; |
|
2208 |
} |
|
2209 |
toTest = ::GetWindow(toTest, GW_OWNER); |
|
2210 |
} |
|
2211 |
while (toTest != NULL); |
|
2212 |
||
2213 |
if (adjustForegroundWindow) |
|
2214 |
{ |
|
2215 |
HWND foregroundSearch = hwnd, newForegroundWindow = NULL; |
|
2216 |
while (1) |
|
2217 |
{ |
|
2218 |
foregroundSearch = ::GetNextWindow(foregroundSearch, GW_HWNDPREV); |
|
2219 |
if (foregroundSearch == NULL) |
|
2220 |
{ |
|
2221 |
break; |
|
2222 |
} |
|
2223 |
LONG style = static_cast<LONG>(::GetWindowLongPtr(foregroundSearch, GWL_STYLE)); |
|
2224 |
if ((style & WS_CHILD) || !(style & WS_VISIBLE)) |
|
2225 |
{ |
|
2226 |
continue; |
|
2227 |
} |
|
2228 |
||
2229 |
AwtComponent *c = AwtComponent::GetComponent(foregroundSearch); |
|
2230 |
if ((c != NULL) && !::IsWindow(AwtWindow::GetModalBlocker(c->GetHWnd()))) |
|
2231 |
{ |
|
2232 |
newForegroundWindow = foregroundSearch; |
|
2233 |
} |
|
2234 |
} |
|
2235 |
if (newForegroundWindow != NULL) |
|
2236 |
{ |
|
2237 |
::SetWindowPos(newForegroundWindow, HWND_TOP, 0, 0, 0, 0, |
|
2238 |
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); |
|
2239 |
if (((AwtWindow*)AwtComponent::GetComponent(newForegroundWindow))->IsFocusableWindow()) |
|
2240 |
{ |
|
2241 |
::SetForegroundWindow(newForegroundWindow); |
|
2242 |
} |
|
2243 |
} |
|
2244 |
else |
|
2245 |
{ |
|
2246 |
// We *have* to set the active HWND to something new. We simply |
|
2247 |
// cannot risk having an active Java HWND which is behind an HWND |
|
2248 |
// of a native application. This really violates the Windows user |
|
2249 |
// experience. |
|
2250 |
// |
|
2251 |
// Windows won't allow us to set the foreground window to NULL, |
|
2252 |
// so we use the desktop window instead. To the user, it appears |
|
2253 |
// that there is no foreground window system-wide. |
|
2254 |
::SetForegroundWindow(::GetDesktopWindow()); |
|
2255 |
} |
|
2256 |
} |
|
2257 |
} |
|
2258 |
ret: |
|
2259 |
env->DeleteGlobalRef(self); |
|
2260 |
} |
|
2261 |
||
2262 |
void AwtWindow::_SetAlwaysOnTop(void *param) |
|
2263 |
{ |
|
2264 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2265 |
||
2266 |
SetAlwaysOnTopStruct *sas = (SetAlwaysOnTopStruct *)param; |
|
2267 |
jobject self = sas->window; |
|
2268 |
jboolean value = sas->value; |
|
2269 |
||
2270 |
AwtWindow *w = NULL; |
|
2271 |
||
2272 |
PDATA pData; |
|
2273 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2274 |
w = (AwtWindow *)pData; |
|
2275 |
if (::IsWindow(w->GetHWnd())) |
|
2276 |
{ |
|
2277 |
w->SendMessage(WM_AWT_SETALWAYSONTOP, (WPARAM)value, (LPARAM)w); |
|
4375
dc92e241ccea
6900622: Security warning icon is not getting displayed properly for tooltip
anthony
parents:
4367
diff
changeset
|
2278 |
w->m_alwaysOnTop = (bool)value; |
2 | 2279 |
} |
2280 |
ret: |
|
2281 |
env->DeleteGlobalRef(self); |
|
2282 |
||
2283 |
delete sas; |
|
2284 |
} |
|
2285 |
||
2286 |
void AwtWindow::_SetTitle(void *param) |
|
2287 |
{ |
|
2288 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2289 |
||
2290 |
SetTitleStruct *sts = (SetTitleStruct *)param; |
|
2291 |
jobject self = sts->window; |
|
2292 |
jstring title = sts->title; |
|
2293 |
||
2294 |
AwtWindow *w = NULL; |
|
2295 |
||
2296 |
PDATA pData; |
|
2297 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2298 |
JNI_CHECK_NULL_GOTO(title, "null title", ret); |
|
2299 |
||
2300 |
w = (AwtWindow *)pData; |
|
2301 |
if (::IsWindow(w->GetHWnd())) |
|
2302 |
{ |
|
2303 |
int length = env->GetStringLength(title); |
|
1954 | 2304 |
TCHAR *buffer = new TCHAR[length + 1]; |
2305 |
env->GetStringRegion(title, 0, length, reinterpret_cast<jchar*>(buffer)); |
|
2 | 2306 |
buffer[length] = L'\0'; |
1954 | 2307 |
VERIFY(::SetWindowText(w->GetHWnd(), buffer)); |
2 | 2308 |
delete[] buffer; |
2309 |
} |
|
2310 |
ret: |
|
2311 |
env->DeleteGlobalRef(self); |
|
2312 |
if (title != NULL) { |
|
2313 |
env->DeleteGlobalRef(title); |
|
2314 |
} |
|
2315 |
||
2316 |
delete sts; |
|
2317 |
} |
|
2318 |
||
2319 |
void AwtWindow::_SetResizable(void *param) |
|
2320 |
{ |
|
2321 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2322 |
||
2323 |
SetResizableStruct *srs = (SetResizableStruct *)param; |
|
2324 |
jobject self = srs->window; |
|
2325 |
jboolean resizable = srs->resizable; |
|
2326 |
||
2327 |
AwtWindow *w = NULL; |
|
2328 |
||
2329 |
PDATA pData; |
|
2330 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2331 |
w = (AwtWindow *)pData; |
|
2332 |
if (::IsWindow(w->GetHWnd())) |
|
2333 |
{ |
|
2334 |
DASSERT(!IsBadReadPtr(w, sizeof(AwtWindow))); |
|
2335 |
w->SetResizable(resizable != 0); |
|
2336 |
} |
|
2337 |
ret: |
|
2338 |
env->DeleteGlobalRef(self); |
|
2339 |
||
2340 |
delete srs; |
|
2341 |
} |
|
2342 |
||
2343 |
void AwtWindow::_UpdateInsets(void *param) |
|
2344 |
{ |
|
2345 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2346 |
||
2347 |
UpdateInsetsStruct *uis = (UpdateInsetsStruct *)param; |
|
2348 |
jobject self = uis->window; |
|
2349 |
jobject insets = uis->insets; |
|
2350 |
||
2351 |
AwtWindow *w = NULL; |
|
2352 |
||
2353 |
PDATA pData; |
|
2354 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2355 |
JNI_CHECK_NULL_GOTO(insets, "null insets", ret); |
|
2356 |
w = (AwtWindow *)pData; |
|
2357 |
if (::IsWindow(w->GetHWnd())) |
|
2358 |
{ |
|
2359 |
w->UpdateInsets(insets); |
|
2360 |
} |
|
2361 |
ret: |
|
2362 |
env->DeleteGlobalRef(self); |
|
2363 |
env->DeleteGlobalRef(insets); |
|
2364 |
||
2365 |
delete uis; |
|
2366 |
} |
|
2367 |
||
2368 |
void AwtWindow::_ReshapeFrame(void *param) |
|
2369 |
{ |
|
2370 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2371 |
||
2372 |
ReshapeFrameStruct *rfs = (ReshapeFrameStruct *)param; |
|
2373 |
jobject self = rfs->frame; |
|
2374 |
jint x = rfs->x; |
|
2375 |
jint y = rfs->y; |
|
2376 |
jint w = rfs->w; |
|
2377 |
jint h = rfs->h; |
|
2378 |
||
2379 |
if (env->EnsureLocalCapacity(1) < 0) |
|
2380 |
{ |
|
2381 |
env->DeleteGlobalRef(self); |
|
2382 |
delete rfs; |
|
2383 |
return; |
|
2384 |
} |
|
2385 |
||
2386 |
AwtFrame *p = NULL; |
|
2387 |
||
2388 |
PDATA pData; |
|
2389 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2390 |
p = (AwtFrame *)pData; |
|
2391 |
if (::IsWindow(p->GetHWnd())) |
|
2392 |
{ |
|
2393 |
jobject target = env->GetObjectField(self, AwtObject::targetID); |
|
2394 |
if (target != NULL) |
|
2395 |
{ |
|
2396 |
// enforce tresholds before sending the event |
|
2397 |
// Fix for 4459064 : do not enforce thresholds for embedded frames |
|
2398 |
if (!p->IsEmbeddedFrame()) |
|
2399 |
{ |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
2400 |
jobject peer = p->GetPeer(env); |
2 | 2401 |
int minWidth = ::GetSystemMetrics(SM_CXMIN); |
2402 |
int minHeight = ::GetSystemMetrics(SM_CYMIN); |
|
2403 |
if (w < minWidth) |
|
2404 |
{ |
|
2405 |
env->SetIntField(target, AwtComponent::widthID, |
|
2406 |
w = minWidth); |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
2407 |
env->SetIntField(peer, AwtWindow::sysWID, |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
2408 |
w); |
2 | 2409 |
} |
2410 |
if (h < minHeight) |
|
2411 |
{ |
|
2412 |
env->SetIntField(target, AwtComponent::heightID, |
|
2413 |
h = minHeight); |
|
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
2414 |
env->SetIntField(peer, AwtWindow::sysHID, |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
2415 |
h); |
2 | 2416 |
} |
2417 |
} |
|
2418 |
env->DeleteLocalRef(target); |
|
2419 |
||
2420 |
RECT *r = new RECT; |
|
2421 |
::SetRect(r, x, y, x + w, y + h); |
|
2422 |
p->SendMessage(WM_AWT_RESHAPE_COMPONENT, 0, (LPARAM)r); |
|
2423 |
// r is deleted in message handler |
|
2424 |
||
2425 |
// After the input method window shown, the dimension & position may not |
|
2426 |
// be valid until this method is called. So we need to adjust the |
|
2427 |
// IME candidate window position for the same reason as commented on |
|
2428 |
// awt_Frame.cpp Show() method. |
|
2429 |
if (p->isInputMethodWindow() && ::IsWindowVisible(p->GetHWnd())) { |
|
2430 |
p->AdjustCandidateWindowPos(); |
|
2431 |
} |
|
2432 |
} |
|
2433 |
else |
|
2434 |
{ |
|
2435 |
JNU_ThrowNullPointerException(env, "null target"); |
|
2436 |
} |
|
2437 |
} |
|
2438 |
ret: |
|
2439 |
env->DeleteGlobalRef(self); |
|
2440 |
||
2441 |
delete rfs; |
|
2442 |
} |
|
2443 |
||
2444 |
/* |
|
2445 |
* This is AwtWindow-specific function that is not intended for reusing |
|
2446 |
*/ |
|
2447 |
HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h) |
|
2448 |
{ |
|
2449 |
HBITMAP mask = NULL; |
|
2450 |
HBITMAP image = NULL; |
|
2451 |
HICON icon = NULL; |
|
2452 |
if (iconRaster != NULL) { |
|
2453 |
int* iconRasterBuffer = NULL; |
|
2454 |
try { |
|
2455 |
iconRasterBuffer = (int *)env->GetPrimitiveArrayCritical(iconRaster, 0); |
|
2456 |
||
2457 |
JNI_CHECK_NULL_GOTO(iconRasterBuffer, "iconRaster data", done); |
|
2458 |
||
2459 |
mask = BitmapUtil::CreateTransparencyMaskFromARGB(w, h, iconRasterBuffer); |
|
2460 |
image = BitmapUtil::CreateV4BitmapFromARGB(w, h, iconRasterBuffer); |
|
2461 |
} catch (...) { |
|
2462 |
if (iconRasterBuffer != NULL) { |
|
2463 |
env->ReleasePrimitiveArrayCritical(iconRaster, iconRasterBuffer, 0); |
|
2464 |
} |
|
2465 |
throw; |
|
2466 |
} |
|
2467 |
if (iconRasterBuffer != NULL) { |
|
2468 |
env->ReleasePrimitiveArrayCritical(iconRaster, iconRasterBuffer, 0); |
|
2469 |
} |
|
2470 |
} |
|
2471 |
if (mask && image) { |
|
2472 |
ICONINFO icnInfo; |
|
2473 |
memset(&icnInfo, 0, sizeof(ICONINFO)); |
|
2474 |
icnInfo.hbmMask = mask; |
|
2475 |
icnInfo.hbmColor = image; |
|
2476 |
icnInfo.fIcon = TRUE; |
|
2477 |
icon = ::CreateIconIndirect(&icnInfo); |
|
2478 |
} |
|
2479 |
if (image) { |
|
2480 |
destroy_BMP(image); |
|
2481 |
} |
|
2482 |
if (mask) { |
|
2483 |
destroy_BMP(mask); |
|
2484 |
} |
|
2485 |
done: |
|
2486 |
return icon; |
|
2487 |
} |
|
2488 |
||
2489 |
void AwtWindow::SetIconData(JNIEnv* env, jintArray iconRaster, jint w, jint h, |
|
2490 |
jintArray smallIconRaster, jint smw, jint smh) |
|
2491 |
{ |
|
2492 |
HICON hOldIcon = NULL; |
|
2493 |
HICON hOldIconSm = NULL; |
|
2494 |
//Destroy previous icon if it isn't inherited |
|
2495 |
if ((m_hIcon != NULL) && !m_iconInherited) { |
|
2496 |
hOldIcon = m_hIcon; |
|
2497 |
} |
|
2498 |
m_hIcon = NULL; |
|
2499 |
if ((m_hIconSm != NULL) && !m_iconInherited) { |
|
2500 |
hOldIconSm = m_hIconSm; |
|
2501 |
} |
|
2502 |
m_hIconSm = NULL; |
|
2503 |
m_hIcon = CreateIconFromRaster(env, iconRaster, w, h); |
|
2504 |
m_hIconSm = CreateIconFromRaster(env, smallIconRaster, smw, smh); |
|
2505 |
||
2506 |
m_iconInherited = (m_hIcon == NULL); |
|
2507 |
if (m_iconInherited) { |
|
2508 |
HWND hOwner = ::GetWindow(GetHWnd(), GW_OWNER); |
|
2509 |
AwtWindow* owner = (AwtWindow *)AwtComponent::GetComponent(hOwner); |
|
2510 |
if (owner != NULL) { |
|
2511 |
m_hIcon = owner->GetHIcon(); |
|
2512 |
m_hIconSm = owner->GetHIconSm(); |
|
2513 |
} else { |
|
2514 |
m_iconInherited = FALSE; |
|
2515 |
} |
|
2516 |
} |
|
2517 |
DoUpdateIcon(); |
|
2518 |
EnumThreadWindows(AwtToolkit::MainThread(), UpdateOwnedIconCallback, (LPARAM)this); |
|
2519 |
if (hOldIcon != NULL) { |
|
2520 |
DestroyIcon(hOldIcon); |
|
2521 |
} |
|
2522 |
if (hOldIconSm != NULL) { |
|
2523 |
DestroyIcon(hOldIconSm); |
|
2524 |
} |
|
2525 |
} |
|
2526 |
||
2527 |
BOOL AwtWindow::UpdateOwnedIconCallback(HWND hWndOwned, LPARAM lParam) |
|
2528 |
{ |
|
2529 |
HWND hWndOwner = ::GetWindow(hWndOwned, GW_OWNER); |
|
2530 |
AwtWindow* owner = (AwtWindow*)lParam; |
|
2531 |
if (hWndOwner == owner->GetHWnd()) { |
|
2532 |
AwtComponent* comp = AwtComponent::GetComponent(hWndOwned); |
|
2533 |
if (comp != NULL && comp->IsTopLevel()) { |
|
2534 |
AwtWindow* owned = (AwtWindow *)comp; |
|
2535 |
if (owned->m_iconInherited) { |
|
2536 |
owned->m_hIcon = owner->m_hIcon; |
|
2537 |
owned->m_hIconSm = owner->m_hIconSm; |
|
2538 |
owned->DoUpdateIcon(); |
|
2539 |
EnumThreadWindows(AwtToolkit::MainThread(), UpdateOwnedIconCallback, (LPARAM)owned); |
|
2540 |
} |
|
2541 |
} |
|
2542 |
} |
|
2543 |
return TRUE; |
|
2544 |
} |
|
2545 |
||
2546 |
void AwtWindow::DoUpdateIcon() |
|
2547 |
{ |
|
2548 |
//Does nothing for windows, is overriden for frames and dialogs |
|
2549 |
} |
|
2550 |
||
2451 | 2551 |
void AwtWindow::RedrawWindow() |
2552 |
{ |
|
2553 |
if (isOpaque()) { |
|
2554 |
::RedrawWindow(GetHWnd(), NULL, NULL, |
|
2555 |
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); |
|
2556 |
} else { |
|
2557 |
::EnterCriticalSection(&contentBitmapCS); |
|
2558 |
if (hContentBitmap != NULL) { |
|
2559 |
UpdateWindowImpl(contentWidth, contentHeight, hContentBitmap); |
|
2560 |
} |
|
2561 |
::LeaveCriticalSection(&contentBitmapCS); |
|
2562 |
} |
|
2563 |
} |
|
2564 |
||
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2565 |
// Deletes the hContentBitmap if it is non-null |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2566 |
void AwtWindow::DeleteContentBitmap() |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2567 |
{ |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2568 |
::EnterCriticalSection(&contentBitmapCS); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2569 |
if (hContentBitmap != NULL) { |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2570 |
::DeleteObject(hContentBitmap); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2571 |
hContentBitmap = NULL; |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2572 |
} |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2573 |
::LeaveCriticalSection(&contentBitmapCS); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2574 |
} |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2575 |
|
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2576 |
// The effects are enabled only upon showing the window. |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2577 |
// See 6780496 for details. |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2578 |
void AwtWindow::EnableTranslucency(BOOL enable) |
2451 | 2579 |
{ |
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2580 |
if (enable) { |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2581 |
SetTranslucency(getOpacity(), isOpaque(), FALSE, TRUE); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2582 |
} else { |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2583 |
SetTranslucency(0xFF, TRUE, FALSE); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2584 |
} |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2585 |
} |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2586 |
|
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2587 |
/** |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2588 |
* Sets the translucency effects. |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2589 |
* |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2590 |
* This method is used to: |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2591 |
* |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2592 |
* 1. Apply the translucency effects upon showing the window |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2593 |
* (setValues == FALSE, useDefaultForOldValues == TRUE); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2594 |
* 2. Turn off the effects upon hiding the window |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2595 |
* (setValues == FALSE, useDefaultForOldValues == FALSE); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2596 |
* 3. Set the effects per user's request |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2597 |
* (setValues == TRUE, useDefaultForOldValues == FALSE); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2598 |
* |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2599 |
* In case #3 the effects may or may not be applied immediately depending on |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2600 |
* the current visibility status of the window. |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2601 |
* |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2602 |
* The setValues argument indicates if we need to preserve the passed values |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2603 |
* in local fields for further use. |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2604 |
* The useDefaultForOldValues argument indicates whether we should consider |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2605 |
* the window as if it has not any effects applied at the moment. |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2606 |
*/ |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2607 |
void AwtWindow::SetTranslucency(BYTE opacity, BOOL opaque, BOOL setValues, |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2608 |
BOOL useDefaultForOldValues) |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2609 |
{ |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2610 |
BYTE old_opacity = useDefaultForOldValues ? 0xFF : getOpacity(); |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2611 |
BOOL old_opaque = useDefaultForOldValues ? TRUE : isOpaque(); |
2451 | 2612 |
|
2613 |
if (opacity == old_opacity && opaque == old_opaque) { |
|
2614 |
return; |
|
2615 |
} |
|
2616 |
||
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2617 |
if (setValues) { |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2618 |
m_opacity = opacity; |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2619 |
m_opaque = opaque; |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2620 |
} |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2621 |
|
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2622 |
// If we're invisible and are storing the values, return |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2623 |
// Otherwise, apply the effects immediately |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2624 |
if (!IsVisible() && setValues) { |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2625 |
return; |
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2626 |
} |
2451 | 2627 |
|
2628 |
HWND hwnd = GetHWnd(); |
|
2629 |
||
2630 |
if (opaque != old_opaque) { |
|
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2631 |
DeleteContentBitmap(); |
2451 | 2632 |
} |
2633 |
||
2634 |
if (opaque && opacity == 0xff) { |
|
2635 |
// Turn off all the effects |
|
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
2636 |
AwtWindow::SetLayered(hwnd, false); |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
2637 |
|
2451 | 2638 |
// Ask the window to repaint itself and all the children |
2639 |
RedrawWindow(); |
|
2640 |
} else { |
|
2641 |
// We're going to enable some effects |
|
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
2642 |
if (!AwtWindow::IsLayered(hwnd)) { |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
2643 |
AwtWindow::SetLayered(hwnd, true); |
2451 | 2644 |
} else { |
2645 |
if ((opaque && opacity < 0xff) ^ (old_opaque && old_opacity < 0xff)) { |
|
2646 |
// _One_ of the modes uses the SetLayeredWindowAttributes. |
|
2647 |
// Need to reset the style in this case. |
|
2648 |
// If both modes are simple (i.e. just changing the opacity level), |
|
2649 |
// no need to reset the style. |
|
3443
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
2650 |
AwtWindow::SetLayered(hwnd, false); |
72f1e3846339
6805231: Security Warning Icon is missing in Windows 2000 Prof from Jdk build 6u12
anthony
parents:
2472
diff
changeset
|
2651 |
AwtWindow::SetLayered(hwnd, true); |
2451 | 2652 |
} |
2653 |
} |
|
2654 |
||
2655 |
if (opaque) { |
|
2656 |
// Simple opacity mode |
|
2657 |
::SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), opacity, LWA_ALPHA); |
|
2658 |
} |
|
2659 |
} |
|
2660 |
} |
|
2661 |
||
2662 |
static HBITMAP CreateBitmapFromRaster(JNIEnv* env, jintArray raster, jint w, jint h) |
|
2663 |
{ |
|
2664 |
HBITMAP image = NULL; |
|
2665 |
if (raster != NULL) { |
|
2666 |
int* rasterBuffer = NULL; |
|
2667 |
try { |
|
2668 |
rasterBuffer = (int *)env->GetPrimitiveArrayCritical(raster, 0); |
|
2669 |
JNI_CHECK_NULL_GOTO(rasterBuffer, "raster data", done); |
|
2670 |
image = BitmapUtil::CreateBitmapFromARGBPre(w, h, w*4, rasterBuffer); |
|
2671 |
} catch (...) { |
|
2672 |
if (rasterBuffer != NULL) { |
|
2673 |
env->ReleasePrimitiveArrayCritical(raster, rasterBuffer, 0); |
|
2674 |
} |
|
2675 |
throw; |
|
2676 |
} |
|
2677 |
if (rasterBuffer != NULL) { |
|
2678 |
env->ReleasePrimitiveArrayCritical(raster, rasterBuffer, 0); |
|
2679 |
} |
|
2680 |
} |
|
2681 |
done: |
|
2682 |
return image; |
|
2683 |
} |
|
2684 |
||
2685 |
void AwtWindow::UpdateWindowImpl(int width, int height, HBITMAP hBitmap) |
|
2686 |
{ |
|
2687 |
if (isOpaque()) { |
|
2688 |
return; |
|
2689 |
} |
|
2690 |
||
2691 |
HWND hWnd = GetHWnd(); |
|
2692 |
HDC hdcDst = ::GetDC(NULL); |
|
2693 |
HDC hdcSrc = ::CreateCompatibleDC(NULL); |
|
2694 |
HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hdcSrc, hBitmap); |
|
2695 |
||
2696 |
//XXX: this code doesn't paint the children (say, the java.awt.Button)! |
|
2697 |
//So, if we ever want to support HWs here, we need to repaint them |
|
2698 |
//in some other way... |
|
2699 |
//::SendMessage(hWnd, WM_PRINT, (WPARAM)hdcSrc, /*PRF_CHECKVISIBLE |*/ |
|
2700 |
// PRF_CHILDREN /*| PRF_CLIENT | PRF_NONCLIENT*/); |
|
2701 |
||
2702 |
POINT ptSrc; |
|
2703 |
ptSrc.x = ptSrc.y = 0; |
|
2704 |
||
2705 |
RECT rect; |
|
2706 |
POINT ptDst; |
|
2707 |
SIZE size; |
|
2708 |
||
2709 |
::GetWindowRect(hWnd, &rect); |
|
2710 |
ptDst.x = rect.left; |
|
2711 |
ptDst.y = rect.top; |
|
2712 |
size.cx = width; |
|
2713 |
size.cy = height; |
|
2714 |
||
2715 |
BLENDFUNCTION bf; |
|
2716 |
||
2717 |
bf.SourceConstantAlpha = getOpacity(); |
|
2718 |
bf.AlphaFormat = AC_SRC_ALPHA; |
|
2719 |
bf.BlendOp = AC_SRC_OVER; |
|
2720 |
bf.BlendFlags = 0; |
|
2721 |
||
2722 |
::UpdateLayeredWindow(hWnd, hdcDst, &ptDst, &size, hdcSrc, &ptSrc, |
|
2723 |
RGB(0, 0, 0), &bf, ULW_ALPHA); |
|
2724 |
||
2725 |
::ReleaseDC(NULL, hdcDst); |
|
2726 |
::SelectObject(hdcSrc, hOldBitmap); |
|
2727 |
::DeleteDC(hdcSrc); |
|
2728 |
} |
|
2729 |
||
2730 |
void AwtWindow::UpdateWindow(JNIEnv* env, jintArray data, int width, int height, |
|
2731 |
HBITMAP hNewBitmap) |
|
2732 |
{ |
|
2733 |
if (isOpaque()) { |
|
2734 |
return; |
|
2735 |
} |
|
2736 |
||
2737 |
HBITMAP hBitmap; |
|
2738 |
if (hNewBitmap == NULL) { |
|
2739 |
if (data == NULL) { |
|
2740 |
return; |
|
2741 |
} |
|
2742 |
hBitmap = CreateBitmapFromRaster(env, data, width, height); |
|
2743 |
if (hBitmap == NULL) { |
|
2744 |
return; |
|
2745 |
} |
|
2746 |
} else { |
|
2747 |
hBitmap = hNewBitmap; |
|
2748 |
} |
|
2749 |
||
2750 |
::EnterCriticalSection(&contentBitmapCS); |
|
3726
d97f7f568e97
6780496: Javaw process taking up 80-90 percent of CPU time!
anthony
parents:
3456
diff
changeset
|
2751 |
DeleteContentBitmap(); |
2451 | 2752 |
hContentBitmap = hBitmap; |
2753 |
contentWidth = width; |
|
2754 |
contentHeight = height; |
|
2755 |
UpdateWindowImpl(width, height, hBitmap); |
|
2756 |
::LeaveCriticalSection(&contentBitmapCS); |
|
2757 |
} |
|
2758 |
||
2759 |
/* |
|
2760 |
* Fixed 6353381: it's improved fix for 4792958 |
|
2761 |
* which was backed-out to avoid 5059656 |
|
2762 |
*/ |
|
2763 |
BOOL AwtWindow::HasValidRect() |
|
2764 |
{ |
|
2765 |
RECT inside; |
|
2766 |
RECT outside; |
|
2767 |
||
2768 |
if (::IsIconic(GetHWnd())) { |
|
2769 |
return FALSE; |
|
2770 |
} |
|
2771 |
||
2772 |
::GetClientRect(GetHWnd(), &inside); |
|
2773 |
::GetWindowRect(GetHWnd(), &outside); |
|
2774 |
||
2775 |
BOOL isZeroClientArea = (inside.right == 0 && inside.bottom == 0); |
|
2776 |
BOOL isInvalidLocation = ((outside.left == -32000 && outside.top == -32000) || // Win2k && WinXP |
|
2777 |
(outside.left == 32000 && outside.top == 32000) || // Win95 && Win98 |
|
2778 |
(outside.left == 3000 && outside.top == 3000)); // Win95 && Win98 |
|
2779 |
||
2780 |
// the bounds correspond to iconic state |
|
2781 |
if (isZeroClientArea && isInvalidLocation) |
|
2782 |
{ |
|
2783 |
return FALSE; |
|
2784 |
} |
|
2785 |
||
2786 |
return TRUE; |
|
2787 |
} |
|
2788 |
||
2789 |
||
2 | 2790 |
void AwtWindow::_SetIconImagesData(void * param) |
2791 |
{ |
|
2792 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2793 |
||
2794 |
SetIconImagesDataStruct* s = (SetIconImagesDataStruct*)param; |
|
2795 |
jobject self = s->window; |
|
2796 |
||
2797 |
jintArray iconRaster = s->iconRaster; |
|
2798 |
jintArray smallIconRaster = s->smallIconRaster; |
|
2799 |
||
2800 |
AwtWindow *window = NULL; |
|
2801 |
||
2802 |
PDATA pData; |
|
2803 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2804 |
// ok to pass null raster: default AWT icon |
|
2805 |
||
2806 |
window = (AwtWindow*)pData; |
|
2807 |
if (::IsWindow(window->GetHWnd())) |
|
2808 |
{ |
|
2809 |
window->SetIconData(env, iconRaster, s->w, s->h, smallIconRaster, s->smw, s->smh); |
|
2810 |
||
2811 |
} |
|
2812 |
||
2813 |
ret: |
|
2814 |
env->DeleteGlobalRef(self); |
|
2815 |
env->DeleteGlobalRef(iconRaster); |
|
2816 |
env->DeleteGlobalRef(smallIconRaster); |
|
2817 |
delete s; |
|
2818 |
} |
|
2819 |
||
2820 |
void AwtWindow::_SetMinSize(void* param) |
|
2821 |
{ |
|
2822 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2823 |
||
2824 |
SizeStruct *ss = (SizeStruct *)param; |
|
2825 |
jobject self = ss->window; |
|
2826 |
jint w = ss->w; |
|
2827 |
jint h = ss->h; |
|
2828 |
//Perform size setting |
|
2829 |
AwtWindow *window = NULL; |
|
2830 |
||
2831 |
PDATA pData; |
|
2832 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2833 |
window = (AwtWindow *)pData; |
|
2834 |
window->m_minSize.x = w; |
|
2835 |
window->m_minSize.y = h; |
|
2836 |
ret: |
|
2837 |
env->DeleteGlobalRef(self); |
|
2838 |
delete ss; |
|
2839 |
} |
|
2840 |
||
2841 |
jint AwtWindow::_GetScreenImOn(void *param) |
|
2842 |
{ |
|
2843 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2844 |
||
2845 |
jobject self = (jobject)param; |
|
2846 |
||
2847 |
// It's entirely possible that our native resources have been destroyed |
|
2848 |
// before our java peer - if we're dispose()d, for instance. |
|
2849 |
// Alert caller w/ IllegalComponentStateException. |
|
2850 |
if (self == NULL) { |
|
2851 |
JNU_ThrowByName(env, "java/awt/IllegalComponentStateException", |
|
2852 |
"Peer null in JNI"); |
|
2853 |
return 0; |
|
2854 |
} |
|
2855 |
PDATA pData = JNI_GET_PDATA(self); |
|
2856 |
if (pData == NULL) { |
|
2857 |
JNU_ThrowByName(env, "java/awt/IllegalComponentStateException", |
|
2858 |
"Native resources unavailable"); |
|
2859 |
env->DeleteGlobalRef(self); |
|
2860 |
return 0; |
|
2861 |
} |
|
2862 |
||
2863 |
jint result = 0; |
|
2864 |
AwtWindow *w = (AwtWindow *)pData; |
|
2865 |
if (::IsWindow(w->GetHWnd())) |
|
2866 |
{ |
|
2867 |
result = (jint)w->GetScreenImOn(); |
|
2868 |
} |
|
2869 |
||
2870 |
env->DeleteGlobalRef(self); |
|
2871 |
||
2872 |
return result; |
|
2873 |
} |
|
2874 |
||
2875 |
void AwtWindow::_SetFocusableWindow(void *param) |
|
2876 |
{ |
|
2877 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2878 |
||
2879 |
SetFocusableWindowStruct *sfws = (SetFocusableWindowStruct *)param; |
|
2880 |
jobject self = sfws->window; |
|
2881 |
jboolean isFocusableWindow = sfws->isFocusableWindow; |
|
2882 |
||
2883 |
AwtWindow *window = NULL; |
|
2884 |
||
2885 |
PDATA pData; |
|
2886 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2887 |
window = (AwtWindow *)pData; |
|
2888 |
||
2889 |
window->m_isFocusableWindow = isFocusableWindow; |
|
2890 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2891 |
// A simple window is permanently set to WS_EX_NOACTIVATE |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2892 |
if (!window->IsSimpleWindow()) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2893 |
if (!window->m_isFocusableWindow) { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2894 |
LONG isPopup = window->GetStyle() & WS_POPUP; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2895 |
window->SetStyleEx(window->GetStyleEx() | (isPopup ? 0 : WS_EX_APPWINDOW) | WS_EX_NOACTIVATE); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2896 |
} else { |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2897 |
window->SetStyleEx(window->GetStyleEx() & ~WS_EX_APPWINDOW & ~WS_EX_NOACTIVATE); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
2898 |
} |
2 | 2899 |
} |
2900 |
||
2901 |
ret: |
|
2902 |
env->DeleteGlobalRef(self); |
|
2903 |
delete sfws; |
|
2904 |
} |
|
2905 |
||
2906 |
void AwtWindow::_ModalDisable(void *param) |
|
2907 |
{ |
|
2908 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2909 |
||
2910 |
ModalDisableStruct *mds = (ModalDisableStruct *)param; |
|
2911 |
jobject self = mds->window; |
|
2912 |
HWND blockerHWnd = (HWND)mds->blockerHWnd; |
|
2913 |
||
2914 |
AwtWindow *window = NULL; |
|
2915 |
HWND windowHWnd = 0; |
|
2916 |
||
2917 |
JNI_CHECK_NULL_GOTO(self, "peer", ret); |
|
2918 |
PDATA pData = JNI_GET_PDATA(self); |
|
2919 |
if (pData == NULL) { |
|
2920 |
env->DeleteGlobalRef(self); |
|
2921 |
delete mds; |
|
2922 |
return; |
|
2923 |
} |
|
2924 |
||
2925 |
window = (AwtWindow *)pData; |
|
2926 |
windowHWnd = window->GetHWnd(); |
|
2927 |
if (::IsWindow(windowHWnd)) { |
|
2928 |
AwtWindow::SetAndActivateModalBlocker(windowHWnd, blockerHWnd); |
|
2929 |
} |
|
2930 |
||
2931 |
ret: |
|
2932 |
env->DeleteGlobalRef(self); |
|
2933 |
||
2934 |
delete mds; |
|
2935 |
} |
|
2936 |
||
2937 |
void AwtWindow::_ModalEnable(void *param) |
|
2938 |
{ |
|
2939 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2940 |
||
2941 |
jobject self = (jobject)param; |
|
2942 |
||
2943 |
AwtWindow *window = NULL; |
|
2944 |
HWND windowHWnd = 0; |
|
2945 |
||
2946 |
JNI_CHECK_NULL_GOTO(self, "peer", ret); |
|
2947 |
PDATA pData = JNI_GET_PDATA(self); |
|
2948 |
if (pData == NULL) { |
|
2949 |
env->DeleteGlobalRef(self); |
|
2950 |
return; |
|
2951 |
} |
|
2952 |
||
2953 |
window = (AwtWindow *)pData; |
|
2954 |
windowHWnd = window->GetHWnd(); |
|
2955 |
if (::IsWindow(windowHWnd)) { |
|
2956 |
AwtWindow::SetModalBlocker(windowHWnd, NULL); |
|
2957 |
} |
|
2958 |
||
2959 |
ret: |
|
2960 |
env->DeleteGlobalRef(self); |
|
2961 |
} |
|
2962 |
||
2451 | 2963 |
void AwtWindow::_SetOpacity(void* param) |
2964 |
{ |
|
2965 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
2966 |
||
2967 |
OpacityStruct *os = (OpacityStruct *)param; |
|
2968 |
jobject self = os->window; |
|
2969 |
BYTE iOpacity = (BYTE)os->iOpacity; |
|
2970 |
||
2971 |
PDATA pData; |
|
2972 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2973 |
AwtWindow *window = (AwtWindow *)pData; |
|
2974 |
||
2975 |
window->SetTranslucency(iOpacity, window->isOpaque()); |
|
2976 |
||
2977 |
ret: |
|
2978 |
env->DeleteGlobalRef(self); |
|
2979 |
delete os; |
|
2980 |
} |
|
2981 |
||
2982 |
void AwtWindow::_SetOpaque(void* param) |
|
2 | 2983 |
{ |
2451 | 2984 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
2985 |
||
2986 |
OpaqueStruct *os = (OpaqueStruct *)param; |
|
2987 |
jobject self = os->window; |
|
2988 |
BOOL isOpaque = (BOOL)os->isOpaque; |
|
2989 |
||
2990 |
PDATA pData; |
|
2991 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
2992 |
AwtWindow *window = (AwtWindow *)pData; |
|
2993 |
||
2994 |
window->SetTranslucency(window->getOpacity(), isOpaque); |
|
2995 |
||
2996 |
ret: |
|
2997 |
env->DeleteGlobalRef(self); |
|
2998 |
delete os; |
|
2999 |
} |
|
3000 |
||
3001 |
void AwtWindow::_UpdateWindow(void* param) |
|
3002 |
{ |
|
3003 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
|
3004 |
||
3005 |
UpdateWindowStruct *uws = (UpdateWindowStruct *)param; |
|
3006 |
jobject self = uws->window; |
|
3007 |
jintArray data = uws->data; |
|
3008 |
||
3009 |
PDATA pData; |
|
3010 |
JNI_CHECK_PEER_GOTO(self, ret); |
|
3011 |
AwtWindow *window = (AwtWindow *)pData; |
|
3012 |
||
3013 |
window->UpdateWindow(env, data, (int)uws->width, (int)uws->height, |
|
3014 |
uws->hBitmap); |
|
3015 |
||
3016 |
ret: |
|
3017 |
env->DeleteGlobalRef(self); |
|
3018 |
if (data != NULL) { |
|
3019 |
env->DeleteGlobalRef(data); |
|
2 | 3020 |
} |
2451 | 3021 |
delete uws; |
2 | 3022 |
} |
3023 |
||
4256
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3024 |
void AwtWindow::_SetFullScreenExclusiveModeState(void *param) |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3025 |
{ |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3026 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3027 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3028 |
SetFullScreenExclusiveModeStateStruct * data = |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3029 |
(SetFullScreenExclusiveModeStateStruct*)param; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3030 |
jobject self = data->window; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3031 |
jboolean state = data->isFSEMState; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3032 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3033 |
PDATA pData; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3034 |
JNI_CHECK_PEER_GOTO(self, ret); |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3035 |
AwtWindow *window = (AwtWindow *)pData; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3036 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3037 |
window->setFullScreenExclusiveModeState(state != 0); |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3038 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3039 |
ret: |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3040 |
env->DeleteGlobalRef(self); |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3041 |
delete data; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3042 |
} |
2451 | 3043 |
|
2 | 3044 |
extern "C" { |
3045 |
||
3046 |
/* |
|
3047 |
* Class: java_awt_Window |
|
3048 |
* Method: initIDs |
|
3049 |
* Signature: ()V |
|
3050 |
*/ |
|
3051 |
JNIEXPORT void JNICALL |
|
3052 |
Java_java_awt_Window_initIDs(JNIEnv *env, jclass cls) |
|
3053 |
{ |
|
3054 |
TRY; |
|
3055 |
||
3056 |
AwtWindow::warningStringID = |
|
3057 |
env->GetFieldID(cls, "warningString", "Ljava/lang/String;"); |
|
3058 |
AwtWindow::locationByPlatformID = |
|
3059 |
env->GetFieldID(cls, "locationByPlatform", "Z"); |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3060 |
AwtWindow::securityWarningWidthID = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3061 |
env->GetFieldID(cls, "securityWarningWidth", "I"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3062 |
AwtWindow::securityWarningHeightID = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3063 |
env->GetFieldID(cls, "securityWarningHeight", "I"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3064 |
AwtWindow::getWarningStringMID = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3065 |
env->GetMethodID(cls, "getWarningString", "()Ljava/lang/String;"); |
2 | 3066 |
AwtWindow::autoRequestFocusID = |
3067 |
env->GetFieldID(cls, "autoRequestFocus", "Z"); |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3068 |
AwtWindow::calculateSecurityWarningPositionMID = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3069 |
env->GetMethodID(cls, "calculateSecurityWarningPosition", "(DDDD)Ljava/awt/geom/Point2D;"); |
2 | 3070 |
|
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3071 |
jclass windowTypeClass = env->FindClass("java/awt/Window$Type"); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3072 |
AwtWindow::windowTypeNameMID = |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3073 |
env->GetMethodID(windowTypeClass, "name", "()Ljava/lang/String;"); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3074 |
env->DeleteLocalRef(windowTypeClass); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3075 |
|
2 | 3076 |
CATCH_BAD_ALLOC; |
3077 |
} |
|
3078 |
||
3079 |
} /* extern "C" */ |
|
3080 |
||
3081 |
||
3082 |
/************************************************************************ |
|
3083 |
* WindowPeer native methods |
|
3084 |
*/ |
|
3085 |
||
3086 |
extern "C" { |
|
3087 |
||
3088 |
/* |
|
3089 |
* Class: sun_awt_windows_WWindowPeer |
|
3090 |
* Method: initIDs |
|
3091 |
* Signature: ()V |
|
3092 |
*/ |
|
3093 |
JNIEXPORT void JNICALL |
|
3094 |
Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls) |
|
3095 |
{ |
|
3096 |
TRY; |
|
3097 |
||
129
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
3098 |
AwtWindow::sysXID = env->GetFieldID(cls, "sysX", "I"); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
3099 |
AwtWindow::sysYID = env->GetFieldID(cls, "sysY", "I"); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
3100 |
AwtWindow::sysWID = env->GetFieldID(cls, "sysW", "I"); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
3101 |
AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I"); |
f995b9c9c5fa
6589527: Window and Frame instances can hide their "Applet Warning"
anthony
parents:
122
diff
changeset
|
3102 |
|
4366
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3103 |
AwtWindow::windowTypeID = env->GetFieldID(cls, "windowType", |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3104 |
"Ljava/awt/Window$Type;"); |
4446f3b8a9b4
6402325: Swing toolbars vs native toolbars on Windows
anthony
parents:
4256
diff
changeset
|
3105 |
|
2 | 3106 |
CATCH_BAD_ALLOC; |
3107 |
} |
|
3108 |
||
3109 |
/* |
|
3110 |
* Class: sun_awt_windows_WWindowPeer |
|
3111 |
* Method: toFront |
|
3112 |
* Signature: ()V |
|
3113 |
*/ |
|
3114 |
JNIEXPORT void JNICALL |
|
3115 |
Java_sun_awt_windows_WWindowPeer__1toFront(JNIEnv *env, jobject self) |
|
3116 |
{ |
|
3117 |
TRY; |
|
3118 |
||
3119 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_ToFront, |
|
3120 |
env->NewGlobalRef(self)); |
|
3121 |
// global ref is deleted in _ToFront() |
|
3122 |
||
3123 |
CATCH_BAD_ALLOC; |
|
3124 |
} |
|
3125 |
||
3126 |
/* |
|
3127 |
* Class: sun_awt_windows_WWindowPeer |
|
3128 |
* Method: toBack |
|
3129 |
* Signature: ()V |
|
3130 |
*/ |
|
3131 |
JNIEXPORT void JNICALL |
|
3132 |
Java_sun_awt_windows_WWindowPeer_toBack(JNIEnv *env, jobject self) |
|
3133 |
{ |
|
3134 |
TRY; |
|
3135 |
||
3136 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_ToBack, |
|
3137 |
env->NewGlobalRef(self)); |
|
3138 |
// global ref is deleted in _ToBack() |
|
3139 |
||
3140 |
CATCH_BAD_ALLOC; |
|
3141 |
} |
|
3142 |
||
3143 |
/* |
|
3144 |
* Class: sun_awt_windows_WWindowPeer |
|
3145 |
* Method: setAlwaysOnTop |
|
3146 |
* Signature: (Z)V |
|
3147 |
*/ |
|
3148 |
JNIEXPORT void JNICALL |
|
3149 |
Java_sun_awt_windows_WWindowPeer_setAlwaysOnTopNative(JNIEnv *env, jobject self, |
|
3150 |
jboolean value) |
|
3151 |
{ |
|
3152 |
TRY; |
|
3153 |
||
3154 |
SetAlwaysOnTopStruct *sas = new SetAlwaysOnTopStruct; |
|
3155 |
sas->window = env->NewGlobalRef(self); |
|
3156 |
sas->value = value; |
|
3157 |
||
3158 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetAlwaysOnTop, sas); |
|
3159 |
// global ref and sas are deleted in _SetAlwaysOnTop |
|
3160 |
||
3161 |
CATCH_BAD_ALLOC; |
|
3162 |
} |
|
3163 |
||
3164 |
/* |
|
3165 |
* Class: sun_awt_windows_WWindowPeer |
|
3166 |
* Method: _setTitle |
|
3167 |
* Signature: (Ljava/lang/String;)V |
|
3168 |
*/ |
|
3169 |
JNIEXPORT void JNICALL |
|
3170 |
Java_sun_awt_windows_WWindowPeer__1setTitle(JNIEnv *env, jobject self, |
|
3171 |
jstring title) |
|
3172 |
{ |
|
3173 |
TRY; |
|
3174 |
||
3175 |
SetTitleStruct *sts = new SetTitleStruct; |
|
3176 |
sts->window = env->NewGlobalRef(self); |
|
3177 |
sts->title = (jstring)env->NewGlobalRef(title); |
|
3178 |
||
3179 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetTitle, sts); |
|
3180 |
/// global refs and sts are deleted in _SetTitle() |
|
3181 |
||
3182 |
CATCH_BAD_ALLOC; |
|
3183 |
} |
|
3184 |
||
3185 |
/* |
|
3186 |
* Class: sun_awt_windows_WWindowPeer |
|
3187 |
* Method: _setResizable |
|
3188 |
* Signature: (Z)V |
|
3189 |
*/ |
|
3190 |
JNIEXPORT void JNICALL |
|
3191 |
Java_sun_awt_windows_WWindowPeer__1setResizable(JNIEnv *env, jobject self, |
|
3192 |
jboolean resizable) |
|
3193 |
{ |
|
3194 |
TRY; |
|
3195 |
||
3196 |
SetResizableStruct *srs = new SetResizableStruct; |
|
3197 |
srs->window = env->NewGlobalRef(self); |
|
3198 |
srs->resizable = resizable; |
|
3199 |
||
3200 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetResizable, srs); |
|
3201 |
// global ref and srs are deleted in _SetResizable |
|
3202 |
||
3203 |
CATCH_BAD_ALLOC; |
|
3204 |
} |
|
3205 |
||
3206 |
/* |
|
3207 |
* Class: sun_awt_windows_WWindowPeer |
|
3208 |
* Method: create |
|
3209 |
* Signature: (Lsun/awt/windows/WComponentPeer;)V |
|
3210 |
*/ |
|
3211 |
JNIEXPORT void JNICALL |
|
3212 |
Java_sun_awt_windows_WWindowPeer_createAwtWindow(JNIEnv *env, jobject self, |
|
3213 |
jobject parent) |
|
3214 |
{ |
|
3215 |
TRY; |
|
3216 |
||
3217 |
PDATA pData; |
|
3218 |
// JNI_CHECK_PEER_RETURN(parent); |
|
3219 |
AwtToolkit::CreateComponent(self, parent, |
|
3220 |
(AwtToolkit::ComponentFactory) |
|
3221 |
AwtWindow::Create); |
|
3222 |
JNI_CHECK_PEER_CREATION_RETURN(self); |
|
3223 |
||
3224 |
CATCH_BAD_ALLOC; |
|
3225 |
} |
|
3226 |
||
3227 |
/* |
|
3228 |
* Class: sun_awt_windows_WWindowPeer |
|
3229 |
* Method: updateInsets |
|
3230 |
* Signature: (Ljava/awt/Insets;)V |
|
3231 |
*/ |
|
3232 |
JNIEXPORT void JNICALL |
|
3233 |
Java_sun_awt_windows_WWindowPeer_updateInsets(JNIEnv *env, jobject self, |
|
3234 |
jobject insets) |
|
3235 |
{ |
|
3236 |
TRY; |
|
3237 |
||
3238 |
UpdateInsetsStruct *uis = new UpdateInsetsStruct; |
|
3239 |
uis->window = env->NewGlobalRef(self); |
|
3240 |
uis->insets = env->NewGlobalRef(insets); |
|
3241 |
||
3242 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_UpdateInsets, uis); |
|
3243 |
// global refs and uis are deleted in _UpdateInsets() |
|
3244 |
||
3245 |
CATCH_BAD_ALLOC; |
|
3246 |
} |
|
3247 |
||
3248 |
/* |
|
3249 |
* Class: sun_awt_windows_WWindowPeer |
|
3250 |
* Method: reshapeFrame |
|
3251 |
* Signature: (IIII)V |
|
3252 |
*/ |
|
3253 |
JNIEXPORT void JNICALL |
|
3254 |
Java_sun_awt_windows_WWindowPeer_reshapeFrame(JNIEnv *env, jobject self, |
|
3255 |
jint x, jint y, jint w, jint h) |
|
3256 |
{ |
|
3257 |
TRY; |
|
3258 |
||
3259 |
ReshapeFrameStruct *rfs = new ReshapeFrameStruct; |
|
3260 |
rfs->frame = env->NewGlobalRef(self); |
|
3261 |
rfs->x = x; |
|
3262 |
rfs->y = y; |
|
3263 |
rfs->w = w; |
|
3264 |
rfs->h = h; |
|
3265 |
||
3266 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_ReshapeFrame, rfs); |
|
3267 |
// global ref and rfs are deleted in _ReshapeFrame() |
|
3268 |
||
3269 |
CATCH_BAD_ALLOC; |
|
3270 |
} |
|
3271 |
||
3272 |
/* |
|
3273 |
* Class: sun_awt_windows_WWindowPeer |
|
3274 |
* Method: getSysMinWidth |
|
3275 |
* Signature: ()I |
|
3276 |
*/ |
|
3277 |
JNIEXPORT jint JNICALL |
|
3278 |
Java_sun_awt_windows_WWindowPeer_getSysMinWidth(JNIEnv *env, jclass self) |
|
3279 |
{ |
|
3280 |
TRY; |
|
3281 |
||
3282 |
return ::GetSystemMetrics(SM_CXMIN); |
|
3283 |
||
3284 |
CATCH_BAD_ALLOC_RET(0); |
|
3285 |
} |
|
3286 |
||
3287 |
/* |
|
3288 |
* Class: sun_awt_windows_WWindowPeer |
|
3289 |
* Method: getSysMinHeight |
|
3290 |
* Signature: ()I |
|
3291 |
*/ |
|
3292 |
JNIEXPORT jint JNICALL |
|
3293 |
Java_sun_awt_windows_WWindowPeer_getSysMinHeight(JNIEnv *env, jclass self) |
|
3294 |
{ |
|
3295 |
TRY; |
|
3296 |
||
3297 |
return ::GetSystemMetrics(SM_CYMIN); |
|
3298 |
||
3299 |
CATCH_BAD_ALLOC_RET(0); |
|
3300 |
} |
|
3301 |
||
3302 |
/* |
|
3303 |
* Class: sun_awt_windows_WWindowPeer |
|
3304 |
* Method: getSysIconHeight |
|
3305 |
* Signature: ()I |
|
3306 |
*/ |
|
3307 |
JNIEXPORT jint JNICALL |
|
3308 |
Java_sun_awt_windows_WWindowPeer_getSysIconHeight(JNIEnv *env, jclass self) |
|
3309 |
{ |
|
3310 |
TRY; |
|
3311 |
||
3312 |
return ::GetSystemMetrics(SM_CYICON); |
|
3313 |
||
3314 |
CATCH_BAD_ALLOC_RET(0); |
|
3315 |
} |
|
3316 |
||
3317 |
/* |
|
3318 |
* Class: sun_awt_windows_WWindowPeer |
|
3319 |
* Method: getSysIconWidth |
|
3320 |
* Signature: ()I |
|
3321 |
*/ |
|
3322 |
JNIEXPORT jint JNICALL |
|
3323 |
Java_sun_awt_windows_WWindowPeer_getSysIconWidth(JNIEnv *env, jclass self) |
|
3324 |
{ |
|
3325 |
TRY; |
|
3326 |
||
3327 |
return ::GetSystemMetrics(SM_CXICON); |
|
3328 |
||
3329 |
CATCH_BAD_ALLOC_RET(0); |
|
3330 |
} |
|
3331 |
||
3332 |
/* |
|
3333 |
* Class: sun_awt_windows_WWindowPeer |
|
3334 |
* Method: getSysSmIconHeight |
|
3335 |
* Signature: ()I |
|
3336 |
*/ |
|
3337 |
JNIEXPORT jint JNICALL |
|
3338 |
Java_sun_awt_windows_WWindowPeer_getSysSmIconHeight(JNIEnv *env, jclass self) |
|
3339 |
{ |
|
3340 |
TRY; |
|
3341 |
||
3342 |
return ::GetSystemMetrics(SM_CYSMICON); |
|
3343 |
||
3344 |
CATCH_BAD_ALLOC_RET(0); |
|
3345 |
} |
|
3346 |
||
3347 |
/* |
|
3348 |
* Class: sun_awt_windows_WWindowPeer |
|
3349 |
* Method: getSysSmIconWidth |
|
3350 |
* Signature: ()I |
|
3351 |
*/ |
|
3352 |
JNIEXPORT jint JNICALL |
|
3353 |
Java_sun_awt_windows_WWindowPeer_getSysSmIconWidth(JNIEnv *env, jclass self) |
|
3354 |
{ |
|
3355 |
TRY; |
|
3356 |
||
3357 |
return ::GetSystemMetrics(SM_CXSMICON); |
|
3358 |
||
3359 |
CATCH_BAD_ALLOC_RET(0); |
|
3360 |
} |
|
3361 |
||
3362 |
/* |
|
3363 |
* Class: sun_awt_windows_WWindowPeer |
|
3364 |
* Method: setIconImagesData |
|
3365 |
* Signature: ([I)V |
|
3366 |
*/ |
|
3367 |
JNIEXPORT void JNICALL |
|
3368 |
Java_sun_awt_windows_WWindowPeer_setIconImagesData(JNIEnv *env, jobject self, |
|
3369 |
jintArray iconRaster, jint w, jint h, |
|
3370 |
jintArray smallIconRaster, jint smw, jint smh) |
|
3371 |
{ |
|
3372 |
TRY; |
|
3373 |
||
3374 |
SetIconImagesDataStruct *sims = new SetIconImagesDataStruct; |
|
3375 |
||
3376 |
sims->window = env->NewGlobalRef(self); |
|
3377 |
sims->iconRaster = (jintArray)env->NewGlobalRef(iconRaster); |
|
3378 |
sims->w = w; |
|
3379 |
sims->h = h; |
|
3380 |
sims->smallIconRaster = (jintArray)env->NewGlobalRef(smallIconRaster); |
|
3381 |
sims->smw = smw; |
|
3382 |
sims->smh = smh; |
|
3383 |
||
3384 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetIconImagesData, sims); |
|
3385 |
// global refs and sims are deleted in _SetIconImagesData() |
|
3386 |
||
3387 |
CATCH_BAD_ALLOC; |
|
3388 |
} |
|
3389 |
||
3390 |
/* |
|
3391 |
* Class: sun_awt_windows_WWindowPeer |
|
3392 |
* Method: setMinSize |
|
3393 |
* Signature: (Lsun/awt/windows/WWindowPeer;)V |
|
3394 |
*/ |
|
3395 |
JNIEXPORT void JNICALL |
|
3396 |
Java_sun_awt_windows_WWindowPeer_setMinSize(JNIEnv *env, jobject self, |
|
3397 |
jint w, jint h) |
|
3398 |
{ |
|
3399 |
TRY; |
|
3400 |
||
3401 |
SizeStruct *ss = new SizeStruct; |
|
3402 |
ss->window = env->NewGlobalRef(self); |
|
3403 |
ss->w = w; |
|
3404 |
ss->h = h; |
|
3405 |
||
3406 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetMinSize, ss); |
|
3407 |
// global refs and mds are deleted in _SetMinSize |
|
3408 |
||
3409 |
CATCH_BAD_ALLOC; |
|
3410 |
} |
|
3411 |
||
3412 |
/* |
|
3413 |
* Class: sun_awt_windows_WWindowPeer |
|
3414 |
* Method: getScreenImOn |
|
3415 |
* Signature: ()I |
|
3416 |
*/ |
|
3417 |
JNIEXPORT jint JNICALL |
|
3418 |
Java_sun_awt_windows_WWindowPeer_getScreenImOn(JNIEnv *env, jobject self) |
|
3419 |
{ |
|
3420 |
TRY; |
|
3421 |
||
3422 |
return static_cast<jint>(reinterpret_cast<INT_PTR>(AwtToolkit::GetInstance().SyncCall( |
|
3423 |
(void *(*)(void *))AwtWindow::_GetScreenImOn, |
|
3424 |
env->NewGlobalRef(self)))); |
|
3425 |
// global ref is deleted in _GetScreenImOn() |
|
3426 |
||
3427 |
CATCH_BAD_ALLOC_RET(-1); |
|
3428 |
} |
|
3429 |
||
3430 |
/* |
|
3431 |
* Class: sun_awt_windows_WWindowPeer |
|
4256
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3432 |
* Method: setFullScreenExclusiveModeState |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3433 |
* Signature: (Z)V |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3434 |
*/ |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3435 |
JNIEXPORT void JNICALL |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3436 |
Java_sun_awt_windows_WWindowPeer_setFullScreenExclusiveModeState(JNIEnv *env, |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3437 |
jobject self, jboolean state) |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3438 |
{ |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3439 |
TRY; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3440 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3441 |
SetFullScreenExclusiveModeStateStruct *data = |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3442 |
new SetFullScreenExclusiveModeStateStruct; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3443 |
data->window = env->NewGlobalRef(self); |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3444 |
data->isFSEMState = state; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3445 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3446 |
AwtToolkit::GetInstance().SyncCall( |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3447 |
AwtWindow::_SetFullScreenExclusiveModeState, data); |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3448 |
// global ref and data are deleted in the invoked method |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3449 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3450 |
CATCH_BAD_ALLOC; |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3451 |
} |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3452 |
|
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3453 |
/* |
24d614d4764a
6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents:
3726
diff
changeset
|
3454 |
* Class: sun_awt_windows_WWindowPeer |
2 | 3455 |
* Method: modalDisable |
3456 |
* Signature: (J)V |
|
3457 |
*/ |
|
3458 |
JNIEXPORT void JNICALL |
|
3459 |
Java_sun_awt_windows_WWindowPeer_modalDisable(JNIEnv *env, jobject self, |
|
3460 |
jobject blocker, jlong blockerHWnd) |
|
3461 |
{ |
|
3462 |
TRY; |
|
3463 |
||
3464 |
ModalDisableStruct *mds = new ModalDisableStruct; |
|
3465 |
mds->window = env->NewGlobalRef(self); |
|
3466 |
mds->blockerHWnd = blockerHWnd; |
|
3467 |
||
3468 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_ModalDisable, mds); |
|
3469 |
// global ref and mds are deleted in _ModalDisable |
|
3470 |
||
3471 |
CATCH_BAD_ALLOC; |
|
3472 |
} |
|
3473 |
||
3474 |
/* |
|
3475 |
* Class: sun_awt_windows_WWindowPeer |
|
3476 |
* Method: modalEnable |
|
3477 |
* Signature: ()V |
|
3478 |
*/ |
|
3479 |
JNIEXPORT void JNICALL |
|
3480 |
Java_sun_awt_windows_WWindowPeer_modalEnable(JNIEnv *env, jobject self, jobject blocker) |
|
3481 |
{ |
|
3482 |
TRY; |
|
3483 |
||
3484 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_ModalEnable, |
|
3485 |
env->NewGlobalRef(self)); |
|
3486 |
// global ref is deleted in _ModalEnable |
|
3487 |
||
3488 |
CATCH_BAD_ALLOC; |
|
3489 |
} |
|
3490 |
||
3491 |
/* |
|
3492 |
* Class: sun_awt_windows_WWindowPeer |
|
3493 |
* Method: setFocusableWindow |
|
3494 |
* Signature: (Z)V |
|
3495 |
*/ |
|
3496 |
JNIEXPORT void JNICALL |
|
3497 |
Java_sun_awt_windows_WWindowPeer_setFocusableWindow(JNIEnv *env, jobject self, jboolean isFocusableWindow) |
|
3498 |
{ |
|
3499 |
TRY; |
|
3500 |
||
3501 |
SetFocusableWindowStruct *sfws = new SetFocusableWindowStruct; |
|
3502 |
sfws->window = env->NewGlobalRef(self); |
|
3503 |
sfws->isFocusableWindow = isFocusableWindow; |
|
3504 |
||
3505 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetFocusableWindow, sfws); |
|
3506 |
// global ref and sfws are deleted in _SetFocusableWindow() |
|
3507 |
||
3508 |
CATCH_BAD_ALLOC; |
|
3509 |
} |
|
3510 |
||
3511 |
JNIEXPORT void JNICALL |
|
3512 |
Java_sun_awt_windows_WWindowPeer_nativeGrab(JNIEnv *env, jobject self) |
|
3513 |
{ |
|
3514 |
TRY; |
|
3515 |
||
3516 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_Grab, env->NewGlobalRef(self)); |
|
3517 |
// global ref is deleted in _Grab() |
|
3518 |
||
3519 |
CATCH_BAD_ALLOC; |
|
3520 |
} |
|
3521 |
||
3522 |
JNIEXPORT void JNICALL |
|
3523 |
Java_sun_awt_windows_WWindowPeer_nativeUngrab(JNIEnv *env, jobject self) |
|
3524 |
{ |
|
3525 |
TRY; |
|
3526 |
||
3527 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_Ungrab, env->NewGlobalRef(self)); |
|
3528 |
// global ref is deleted in _Ungrab() |
|
3529 |
||
3530 |
CATCH_BAD_ALLOC; |
|
3531 |
} |
|
3532 |
||
2451 | 3533 |
/* |
3534 |
* Class: sun_awt_windows_WWindowPeer |
|
3535 |
* Method: setOpacity |
|
3536 |
* Signature: (I)V |
|
3537 |
*/ |
|
3538 |
JNIEXPORT void JNICALL |
|
3539 |
Java_sun_awt_windows_WWindowPeer_setOpacity(JNIEnv *env, jobject self, |
|
3540 |
jint iOpacity) |
|
3541 |
{ |
|
3542 |
TRY; |
|
3543 |
||
3544 |
OpacityStruct *os = new OpacityStruct; |
|
3545 |
os->window = env->NewGlobalRef(self); |
|
3546 |
os->iOpacity = iOpacity; |
|
3547 |
||
3548 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpacity, os); |
|
3549 |
// global refs and mds are deleted in _SetMinSize |
|
3550 |
||
3551 |
CATCH_BAD_ALLOC; |
|
3552 |
} |
|
3553 |
||
3554 |
/* |
|
3555 |
* Class: sun_awt_windows_WWindowPeer |
|
3556 |
* Method: setOpaqueImpl |
|
3557 |
* Signature: (Z)V |
|
3558 |
*/ |
|
3559 |
JNIEXPORT void JNICALL |
|
3560 |
Java_sun_awt_windows_WWindowPeer_setOpaqueImpl(JNIEnv *env, jobject self, |
|
3561 |
jboolean isOpaque) |
|
3562 |
{ |
|
3563 |
TRY; |
|
3564 |
||
3565 |
OpaqueStruct *os = new OpaqueStruct; |
|
3566 |
os->window = env->NewGlobalRef(self); |
|
3567 |
os->isOpaque = isOpaque; |
|
3568 |
||
3569 |
AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpaque, os); |
|
3570 |
// global refs and mds are deleted in _SetMinSize |
|
3571 |
||
3572 |
CATCH_BAD_ALLOC; |
|
3573 |
} |
|
3574 |
||
3575 |
/* |
|
3576 |
* Class: sun_awt_windows_WWindowPeer |
|
3577 |
* Method: updateWindowImpl |
|
3578 |
* Signature: ([III)V |
|
3579 |
*/ |
|
3580 |
JNIEXPORT void JNICALL |
|
3581 |
Java_sun_awt_windows_WWindowPeer_updateWindowImpl(JNIEnv *env, jobject self, |
|
3582 |
jintArray data, |
|
3583 |
jint width, jint height) |
|
3584 |
{ |
|
3585 |
TRY; |
|
3586 |
||
3587 |
UpdateWindowStruct *uws = new UpdateWindowStruct; |
|
3588 |
uws->window = env->NewGlobalRef(self); |
|
3589 |
uws->data = (jintArray)env->NewGlobalRef(data); |
|
3590 |
uws->hBitmap = NULL; |
|
3591 |
uws->width = width; |
|
3592 |
uws->height = height; |
|
3593 |
||
3594 |
AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_UpdateWindow, uws); |
|
3595 |
// global refs and mds are deleted in _UpdateWindow |
|
3596 |
||
3597 |
CATCH_BAD_ALLOC; |
|
3598 |
} |
|
3599 |
||
3600 |
/** |
|
3601 |
* This method is called from the WGL pipeline when it needs to update |
|
3602 |
* the layered window WindowPeer's C++ level object. |
|
3603 |
*/ |
|
3604 |
void AwtWindow_UpdateWindow(JNIEnv *env, jobject peer, |
|
3605 |
jint width, jint height, HBITMAP hBitmap) |
|
3606 |
{ |
|
3607 |
TRY; |
|
3608 |
||
3609 |
UpdateWindowStruct *uws = new UpdateWindowStruct; |
|
3610 |
uws->window = env->NewGlobalRef(peer); |
|
3611 |
uws->data = NULL; |
|
3612 |
uws->hBitmap = hBitmap; |
|
3613 |
uws->width = width; |
|
3614 |
uws->height = height; |
|
3615 |
||
3616 |
AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_UpdateWindow, uws); |
|
3617 |
// global refs and mds are deleted in _UpdateWindow |
|
3618 |
||
3619 |
CATCH_BAD_ALLOC; |
|
3620 |
} |
|
3621 |
||
2464
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3622 |
/* |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3623 |
* Class: sun_awt_windows_WComponentPeer |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3624 |
* Method: requestFocus |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3625 |
* Signature: (Z)Z |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3626 |
*/ |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3627 |
JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WWindowPeer_requestWindowFocus |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3628 |
(JNIEnv *env, jobject self, jboolean isMouseEventCause) |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3629 |
{ |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3630 |
TRY; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3631 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3632 |
jobject selfGlobalRef = env->NewGlobalRef(self); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3633 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3634 |
RequestWindowFocusStruct *rfs = new RequestWindowFocusStruct; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3635 |
rfs->component = selfGlobalRef; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3636 |
rfs->isMouseEventCause = isMouseEventCause; |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3637 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3638 |
return (jboolean)AwtToolkit::GetInstance().SyncCall( |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3639 |
(void*(*)(void*))AwtWindow::_RequestWindowFocus, rfs); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3640 |
// global refs and rfs are deleted in _RequestWindowFocus |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3641 |
|
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3642 |
CATCH_BAD_ALLOC_RET(JNI_FALSE); |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3643 |
} |
3c6755bdc55f
6806217: implement synthetic focus model for MS Windows
ant
parents:
2451
diff
changeset
|
3644 |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3645 |
/* |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3646 |
* Class: sun_awt_windows_WWindowPeer |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3647 |
* Method: repositionSecurityWarning |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3648 |
* Signature: ()V |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3649 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3650 |
JNIEXPORT void JNICALL |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3651 |
Java_sun_awt_windows_WWindowPeer_repositionSecurityWarning(JNIEnv *env, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3652 |
jobject self) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3653 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3654 |
TRY; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3655 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3656 |
RepositionSecurityWarningStruct *rsws = |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3657 |
new RepositionSecurityWarningStruct; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3658 |
rsws->window = env->NewGlobalRef(self); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3659 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3660 |
AwtToolkit::GetInstance().InvokeFunction( |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3661 |
AwtWindow::_RepositionSecurityWarning, rsws); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3662 |
// global refs and mds are deleted in _RepositionSecurityWarning |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3663 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3664 |
CATCH_BAD_ALLOC; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3665 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
2464
diff
changeset
|
3666 |
|
2 | 3667 |
} /* extern "C" */ |