1 /*
2 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
228 static void _Ungrab(void *param);
229 static void _SetAlwaysOnTop(void *param);
230 static void _SetTitle(void *param);
231 static void _SetResizable(void *param);
232 static void _UpdateInsets(void *param);
233 static void _ReshapeFrame(void *param);
234 static void _SetIconImagesData(void * param);
235 static void _SetMinSize(void* param);
236 static jint _GetScreenImOn(void *param);
237 static void _SetFocusableWindow(void *param);
238 static void _SetModalExcludedNativeProp(void *param);
239 static void _ModalDisable(void *param);
240 static void _ModalEnable(void *param);
241 static void _SetOpacity(void* param);
242 static void _SetOpaque(void* param);
243 static void _UpdateWindow(void* param);
244 static void _RepositionSecurityWarning(void* param);
245 static void _SetFullScreenExclusiveModeState(void* param);
246 static void _GetNativeWindowSize(void* param);
247 static void _WindowDPIChange(void* param);
248
249 inline static BOOL IsResizing() {
250 return sm_resizing;
251 }
252
253 virtual void CreateHWnd(JNIEnv *env, LPCWSTR title,
254 DWORD windowStyle, DWORD windowExStyle,
255 int x, int y, int w, int h,
256 HWND hWndParent, HMENU hMenu,
257 COLORREF colorForeground, COLORREF colorBackground,
258 jobject peer);
259 virtual void DestroyHWnd();
260
261 static void FocusedWindowChanged(HWND from, HWND to);
262
263 private:
264 static int ms_instanceCounter;
265 static HHOOK ms_hCBTFilter;
266 static LRESULT CALLBACK CBTFilter(int nCode, WPARAM wParam, LPARAM lParam);
267 static BOOL sm_resizing; /* in the middle of a resizing operation */
268
269 RECT m_insets; /* a cache of the insets being used */
270 RECT m_old_insets; /* help determine if insets change */
271 POINT m_sizePt; /* the last value of WM_SIZE */
272 RECT m_warningRect; /* The window's warning banner area, if any. */
273 AwtFrame *m_owningFrameDialog; /* The nearest Frame/Dialog which owns us */
274 BOOL m_isFocusableWindow; /* a cache of Window.isFocusableWindow() return value */
275 POINT m_minSize; /* Minimum size of the window for WM_GETMINMAXINFO message */
276 BOOL m_grabbed; // Whether the current window is grabbed
277 BOOL m_isRetainingHierarchyZOrder; // Is this a window that shouldn't change z-order of any window
278 // from its hierarchy when shown. Currently applied to instances of
279 // javax/swing/Popup$HeavyWeightWindow class.
280
281 // SetTranslucency() is the setter for the following two fields
282 BYTE m_opacity; // The opacity level. == 0xff by default (when opacity mode is disabled)
294 HBITMAP hContentBitmap;
295 UINT contentWidth;
296 UINT contentHeight;
297
298 void SetTranslucency(BYTE opacity, BOOL opaque, BOOL setValues = TRUE,
299 BOOL useDefaultForOldValues = FALSE);
300 void UpdateWindow(int width, int height, HBITMAP hBitmap);
301 void UpdateWindowImpl(int width, int height, HBITMAP hBitmap);
302 void RedrawWindow();
303 void DeleteContentBitmap();
304
305 static UINT untrustedWindowsCounter;
306
307 WCHAR * warningString;
308
309 // The warning icon
310 HWND warningWindow;
311 // The tooltip that appears when hovering the icon
312 HWND securityTooltipWindow;
313
314 UINT warningWindowWidth;
315 UINT warningWindowHeight;
316 void InitSecurityWarningSize(JNIEnv *env);
317 HICON GetSecurityWarningIcon();
318
319 void CreateWarningWindow(JNIEnv *env);
320 void DestroyWarningWindow();
321 static LPCTSTR GetWarningWindowClassName();
322 void FillWarningWindowClassInfo(WNDCLASS *lpwc);
323 void RegisterWarningWindowClass();
324 void UnregisterWarningWindowClass();
325 static LRESULT CALLBACK WarningWindowProc(
326 HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
327
328 static void PaintWarningWindow(HWND warningWindow);
329 static void PaintWarningWindow(HWND warningWindow, HDC hdc);
330 void RepaintWarningWindow();
331 void CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect);
332
333 void AnimateSecurityWarning(bool enable);
|
1 /*
2 * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
228 static void _Ungrab(void *param);
229 static void _SetAlwaysOnTop(void *param);
230 static void _SetTitle(void *param);
231 static void _SetResizable(void *param);
232 static void _UpdateInsets(void *param);
233 static void _ReshapeFrame(void *param);
234 static void _SetIconImagesData(void * param);
235 static void _SetMinSize(void* param);
236 static jint _GetScreenImOn(void *param);
237 static void _SetFocusableWindow(void *param);
238 static void _SetModalExcludedNativeProp(void *param);
239 static void _ModalDisable(void *param);
240 static void _ModalEnable(void *param);
241 static void _SetOpacity(void* param);
242 static void _SetOpaque(void* param);
243 static void _UpdateWindow(void* param);
244 static void _RepositionSecurityWarning(void* param);
245 static void _SetFullScreenExclusiveModeState(void* param);
246 static void _GetNativeWindowSize(void* param);
247 static void _WindowDPIChange(void* param);
248 static void _OverrideHandle(void *param);
249
250 inline static BOOL IsResizing() {
251 return sm_resizing;
252 }
253
254 virtual void CreateHWnd(JNIEnv *env, LPCWSTR title,
255 DWORD windowStyle, DWORD windowExStyle,
256 int x, int y, int w, int h,
257 HWND hWndParent, HMENU hMenu,
258 COLORREF colorForeground, COLORREF colorBackground,
259 jobject peer);
260 virtual void DestroyHWnd();
261
262 static void FocusedWindowChanged(HWND from, HWND to);
263
264 inline HWND GetOverridenHWnd() { return m_overridenHwnd; }
265 inline void OverrideHWnd(HWND hwnd) { m_overridenHwnd = hwnd; }
266
267 private:
268 static int ms_instanceCounter;
269 static HHOOK ms_hCBTFilter;
270 static LRESULT CALLBACK CBTFilter(int nCode, WPARAM wParam, LPARAM lParam);
271 static BOOL sm_resizing; /* in the middle of a resizing operation */
272
273 RECT m_insets; /* a cache of the insets being used */
274 RECT m_old_insets; /* help determine if insets change */
275 POINT m_sizePt; /* the last value of WM_SIZE */
276 RECT m_warningRect; /* The window's warning banner area, if any. */
277 AwtFrame *m_owningFrameDialog; /* The nearest Frame/Dialog which owns us */
278 BOOL m_isFocusableWindow; /* a cache of Window.isFocusableWindow() return value */
279 POINT m_minSize; /* Minimum size of the window for WM_GETMINMAXINFO message */
280 BOOL m_grabbed; // Whether the current window is grabbed
281 BOOL m_isRetainingHierarchyZOrder; // Is this a window that shouldn't change z-order of any window
282 // from its hierarchy when shown. Currently applied to instances of
283 // javax/swing/Popup$HeavyWeightWindow class.
284
285 // SetTranslucency() is the setter for the following two fields
286 BYTE m_opacity; // The opacity level. == 0xff by default (when opacity mode is disabled)
298 HBITMAP hContentBitmap;
299 UINT contentWidth;
300 UINT contentHeight;
301
302 void SetTranslucency(BYTE opacity, BOOL opaque, BOOL setValues = TRUE,
303 BOOL useDefaultForOldValues = FALSE);
304 void UpdateWindow(int width, int height, HBITMAP hBitmap);
305 void UpdateWindowImpl(int width, int height, HBITMAP hBitmap);
306 void RedrawWindow();
307 void DeleteContentBitmap();
308
309 static UINT untrustedWindowsCounter;
310
311 WCHAR * warningString;
312
313 // The warning icon
314 HWND warningWindow;
315 // The tooltip that appears when hovering the icon
316 HWND securityTooltipWindow;
317
318 //Allows substitute parent window with JavaFX stage to make it below a dialog
319 HWND m_overridenHwnd;
320
321 UINT warningWindowWidth;
322 UINT warningWindowHeight;
323 void InitSecurityWarningSize(JNIEnv *env);
324 HICON GetSecurityWarningIcon();
325
326 void CreateWarningWindow(JNIEnv *env);
327 void DestroyWarningWindow();
328 static LPCTSTR GetWarningWindowClassName();
329 void FillWarningWindowClassInfo(WNDCLASS *lpwc);
330 void RegisterWarningWindowClass();
331 void UnregisterWarningWindowClass();
332 static LRESULT CALLBACK WarningWindowProc(
333 HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
334
335 static void PaintWarningWindow(HWND warningWindow);
336 static void PaintWarningWindow(HWND warningWindow, HDC hdc);
337 void RepaintWarningWindow();
338 void CalculateWarningWindowBounds(JNIEnv *env, LPRECT rect);
339
340 void AnimateSecurityWarning(bool enable);
|