< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Window.h

Print this page
rev 60071 : 8211999: Window positioning bugs due to overlapping GraphicsDevice bounds (Windows/HiDPI)
Reviewed-by: XXX
   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


  40 #define WH_MOUSE_LL 14
  41 #endif
  42 
  43 class AwtFrame;
  44 
  45 /************************************************************************
  46  * AwtWindow class
  47  */
  48 
  49 class AwtWindow : public AwtCanvas {
  50 public:
  51 
  52     /* java.awt.Window field ids */
  53     static jfieldID warningStringID;
  54     static jfieldID locationByPlatformID;
  55     static jfieldID screenID; /* screen number passed over from WindowPeer */
  56     static jfieldID autoRequestFocusID;
  57     static jfieldID securityWarningWidthID;
  58     static jfieldID securityWarningHeightID;
  59 
  60     // The coordinates at the peer.
  61     static jfieldID sysXID;
  62     static jfieldID sysYID;
  63     static jfieldID sysWID;
  64     static jfieldID sysHID;
  65 
  66     static jfieldID windowTypeID;
  67 
  68     static jmethodID getWarningStringMID;
  69     static jmethodID calculateSecurityWarningPositionMID;
  70     static jmethodID windowTypeNameMID;
  71 
  72     AwtWindow();
  73     virtual ~AwtWindow();
  74 
  75     virtual void Dispose();
  76 
  77     virtual LPCTSTR GetClassName();
  78     virtual void FillClassInfo(WNDCLASSEX *lpwc);
  79 
  80     static AwtWindow* Create(jobject self, jobject parent);
  81 
  82     // Returns TRUE if this Window is equal to or one of owners of wnd
  83     BOOL IsOneOfOwnersOf(AwtWindow * wnd);
  84 
  85     /* Update the insets for this Window (container), its peer &


 109 
 110     /* We can hold children */
 111     virtual BOOL IsContainer() { return TRUE;}
 112 
 113     virtual BOOL IsUndecorated() { return TRUE; }
 114 
 115     INLINE virtual BOOL IsSimpleWindow() { return TRUE; }
 116 
 117     INLINE BOOL IsRetainingHierarchyZOrder() { return m_isRetainingHierarchyZOrder; }
 118 
 119     /* WARNING: don't invoke on Toolkit thread! */
 120     INLINE BOOL IsAutoRequestFocus() {
 121         JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 122         return env->GetBooleanField(GetTarget(env), AwtWindow::autoRequestFocusID);
 123     }
 124 
 125     INLINE virtual BOOL IsFocusedWindowModalBlocker() {
 126         return FALSE;
 127     }
 128 

 129     virtual void Invalidate(RECT* r);
 130     virtual void Show();
 131     virtual void SetResizable(BOOL isResizable);
 132     BOOL IsResizable();
 133     virtual void RecalcNonClient();
 134     virtual void RedrawNonClient();
 135     virtual int  GetScreenImOn();
 136     virtual void CheckIfOnNewScreen();
 137     virtual void Grab();
 138     virtual void Ungrab();
 139     virtual void Ungrab(BOOL doPost);
 140     virtual void SetIconData(JNIEnv* env, jintArray iconData, jint w, jint h,
 141                              jintArray smallIconData, jint smw, jint smh);
 142     virtual void DoUpdateIcon();
 143     INLINE HICON GetHIcon() {return m_hIcon;};
 144     INLINE HICON GetHIconSm() {return m_hIconSm;};
 145     INLINE BOOL IsIconInherited() {return m_iconInherited;};
 146     INLINE virtual BOOL IsLightweightFrame() {return FALSE;}
 147 
 148     /* Post events to the EventQueue */
 149     void SendComponentEvent(jint eventId);
 150     void SendWindowEvent(jint id, HWND opposite = NULL,
 151                          jint oldState = 0, jint newState = 0);
 152 
 153     BOOL IsFocusableWindow();
 154 
 155     /* some helper methods about blocking windows by modal dialogs */
 156     INLINE static HWND GetModalBlocker(HWND window) {


 227     static void _Grab(void *param);
 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 GetOverriddenHWnd() { return m_overriddenHwnd; }
 265     inline void OverrideHWnd(HWND hwnd) { m_overriddenHwnd = hwnd; }
 266 
 267 private:


 388     enum Type {
 389         NORMAL, UTILITY, POPUP
 390     };
 391 
 392     inline Type GetType() { return m_windowType; }
 393 
 394 private:
 395     int m_screenNum;
 396 
 397     typedef struct {
 398         jint screen;
 399         jfloat scaleX;
 400         jfloat scaleY;
 401     } ScaleRec;
 402 
 403     BOOL m_winSizeMove;
 404     ScaleRec prevScaleRec;
 405 
 406     void InitOwner(AwtWindow *owner);
 407     void CheckWindowDPIChange();
 408     void WindowDPIChange(int prevScreen, float prevScaleX, float prevScaleY,
 409                          int newScreen, float scaleX, float scaleY);
 410 
 411     Type m_windowType;
 412     void InitType(JNIEnv *env, jobject peer);
 413 
 414     // Tweak the style according to the type of the window
 415     void TweakStyle(DWORD & style, DWORD & exStyle);
 416 
 417     // Set in _SetAlwaysOnTop()
 418     bool m_alwaysOnTop;
 419 public:
 420     inline bool IsAlwaysOnTop() { return m_alwaysOnTop; }
 421 };
 422 
 423 HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h);
 424 
 425 #endif /* AWT_WINDOW_H */
   1 /*
   2  * Copyright (c) 1996, 2020, 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


  40 #define WH_MOUSE_LL 14
  41 #endif
  42 
  43 class AwtFrame;
  44 
  45 /************************************************************************
  46  * AwtWindow class
  47  */
  48 
  49 class AwtWindow : public AwtCanvas {
  50 public:
  51 
  52     /* java.awt.Window field ids */
  53     static jfieldID warningStringID;
  54     static jfieldID locationByPlatformID;
  55     static jfieldID screenID; /* screen number passed over from WindowPeer */
  56     static jfieldID autoRequestFocusID;
  57     static jfieldID securityWarningWidthID;
  58     static jfieldID securityWarningHeightID;
  59 






  60     static jfieldID windowTypeID;
  61 
  62     static jmethodID getWarningStringMID;
  63     static jmethodID calculateSecurityWarningPositionMID;
  64     static jmethodID windowTypeNameMID;
  65 
  66     AwtWindow();
  67     virtual ~AwtWindow();
  68 
  69     virtual void Dispose();
  70 
  71     virtual LPCTSTR GetClassName();
  72     virtual void FillClassInfo(WNDCLASSEX *lpwc);
  73 
  74     static AwtWindow* Create(jobject self, jobject parent);
  75 
  76     // Returns TRUE if this Window is equal to or one of owners of wnd
  77     BOOL IsOneOfOwnersOf(AwtWindow * wnd);
  78 
  79     /* Update the insets for this Window (container), its peer &


 103 
 104     /* We can hold children */
 105     virtual BOOL IsContainer() { return TRUE;}
 106 
 107     virtual BOOL IsUndecorated() { return TRUE; }
 108 
 109     INLINE virtual BOOL IsSimpleWindow() { return TRUE; }
 110 
 111     INLINE BOOL IsRetainingHierarchyZOrder() { return m_isRetainingHierarchyZOrder; }
 112 
 113     /* WARNING: don't invoke on Toolkit thread! */
 114     INLINE BOOL IsAutoRequestFocus() {
 115         JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 116         return env->GetBooleanField(GetTarget(env), AwtWindow::autoRequestFocusID);
 117     }
 118 
 119     INLINE virtual BOOL IsFocusedWindowModalBlocker() {
 120         return FALSE;
 121     }
 122 
 123     virtual void Reshape(int x, int y, int w, int h);
 124     virtual void Invalidate(RECT* r);
 125     virtual void Show();
 126     virtual void SetResizable(BOOL isResizable);
 127     BOOL IsResizable();
 128     virtual void RecalcNonClient();
 129     virtual void RedrawNonClient();
 130     virtual int  GetScreenImOn();
 131     virtual void CheckIfOnNewScreen(BOOL force);
 132     virtual void Grab();
 133     virtual void Ungrab();
 134     virtual void Ungrab(BOOL doPost);
 135     virtual void SetIconData(JNIEnv* env, jintArray iconData, jint w, jint h,
 136                              jintArray smallIconData, jint smw, jint smh);
 137     virtual void DoUpdateIcon();
 138     INLINE HICON GetHIcon() {return m_hIcon;};
 139     INLINE HICON GetHIconSm() {return m_hIconSm;};
 140     INLINE BOOL IsIconInherited() {return m_iconInherited;};
 141     INLINE virtual BOOL IsLightweightFrame() {return FALSE;}
 142 
 143     /* Post events to the EventQueue */
 144     void SendComponentEvent(jint eventId);
 145     void SendWindowEvent(jint id, HWND opposite = NULL,
 146                          jint oldState = 0, jint newState = 0);
 147 
 148     BOOL IsFocusableWindow();
 149 
 150     /* some helper methods about blocking windows by modal dialogs */
 151     INLINE static HWND GetModalBlocker(HWND window) {


 222     static void _Grab(void *param);
 223     static void _Ungrab(void *param);
 224     static void _SetAlwaysOnTop(void *param);
 225     static void _SetTitle(void *param);
 226     static void _SetResizable(void *param);
 227     static void _UpdateInsets(void *param);
 228     static void _ReshapeFrame(void *param);
 229     static void _SetIconImagesData(void * param);
 230     static void _SetMinSize(void* param);
 231     static jint _GetScreenImOn(void *param);
 232     static void _SetFocusableWindow(void *param);
 233     static void _SetModalExcludedNativeProp(void *param);
 234     static void _ModalDisable(void *param);
 235     static void _ModalEnable(void *param);
 236     static void _SetOpacity(void* param);
 237     static void _SetOpaque(void* param);
 238     static void _UpdateWindow(void* param);
 239     static void _RepositionSecurityWarning(void* param);
 240     static void _SetFullScreenExclusiveModeState(void* param);
 241     static void _GetNativeWindowSize(void* param);

 242     static void _OverrideHandle(void *param);
 243 
 244     inline static BOOL IsResizing() {
 245         return sm_resizing;
 246     }
 247 
 248     virtual void CreateHWnd(JNIEnv *env, LPCWSTR title,
 249             DWORD windowStyle, DWORD windowExStyle,
 250             int x, int y, int w, int h,
 251             HWND hWndParent, HMENU hMenu,
 252             COLORREF colorForeground, COLORREF colorBackground,
 253             jobject peer);
 254     virtual void DestroyHWnd();
 255 
 256     static void FocusedWindowChanged(HWND from, HWND to);
 257 
 258     inline HWND GetOverriddenHWnd() { return m_overriddenHwnd; }
 259     inline void OverrideHWnd(HWND hwnd) { m_overriddenHwnd = hwnd; }
 260 
 261 private:


 382     enum Type {
 383         NORMAL, UTILITY, POPUP
 384     };
 385 
 386     inline Type GetType() { return m_windowType; }
 387 
 388 private:
 389     int m_screenNum;
 390 
 391     typedef struct {
 392         jint screen;
 393         jfloat scaleX;
 394         jfloat scaleY;
 395     } ScaleRec;
 396 
 397     BOOL m_winSizeMove;
 398     ScaleRec prevScaleRec;
 399 
 400     void InitOwner(AwtWindow *owner);
 401     void CheckWindowDPIChange();
 402     void WmDPIChanged(const LPARAM &lParam);

 403 
 404     Type m_windowType;
 405     void InitType(JNIEnv *env, jobject peer);
 406 
 407     // Tweak the style according to the type of the window
 408     void TweakStyle(DWORD & style, DWORD & exStyle);
 409 
 410     // Set in _SetAlwaysOnTop()
 411     bool m_alwaysOnTop;
 412 public:
 413     inline bool IsAlwaysOnTop() { return m_alwaysOnTop; }
 414 };
 415 
 416 HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h);
 417 
 418 #endif /* AWT_WINDOW_H */
< prev index next >