aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/windows/native/sun/windows/awt.h1
-rw-r--r--src/windows/native/sun/windows/awt_Frame.cpp14
-rw-r--r--src/windows/native/sun/windows/awt_Toolkit.cpp2
-rw-r--r--src/windows/native/sun/windows/awt_Toolkit.h7
4 files changed, 20 insertions, 4 deletions
diff --git a/src/windows/native/sun/windows/awt.h b/src/windows/native/sun/windows/awt.h
index 79f17a6e1f..6afcd136c2 100644
--- a/src/windows/native/sun/windows/awt.h
+++ b/src/windows/native/sun/windows/awt.h
@@ -65,6 +65,7 @@ typedef enum _DPI_AWARENESS {
} DPI_AWARENESS;
*/
typedef BOOL(WINAPI EnableNonClientDpiScalingFunc)(HWND);
+typedef BOOL(WINAPI AdjustWindowRectExForDpiFunc)(LPRECT, DWORD, BOOL, DWORD, UINT);
//#endif
// val >= 0 todo [tav] until switch to VS'12
diff --git a/src/windows/native/sun/windows/awt_Frame.cpp b/src/windows/native/sun/windows/awt_Frame.cpp
index 5a03ec1bf3..48cfdd9d06 100644
--- a/src/windows/native/sun/windows/awt_Frame.cpp
+++ b/src/windows/native/sun/windows/awt_Frame.cpp
@@ -1713,12 +1713,18 @@ BOOL AwtFrame::HasCustomDecoration()
void GetSysInsets(RECT* insets, AwtFrame* pFrame) {
if (pFrame->IsUndecorated()) {
- ::SetRect(insets, 0, 0, 0, 0);
+ ::SetRectEmpty(insets);
return;
}
- insets->left = insets->right = ::GetSystemMetrics(pFrame->IsResizable() ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME);
- insets->top = insets->bottom = ::GetSystemMetrics(pFrame->IsResizable() ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME);
- insets->top += ::GetSystemMetrics(SM_CYCAPTION);
+ Devices::InstanceAccess devices;
+ AwtWin32GraphicsDevice* device = devices->GetDevice(AwtWin32GraphicsDevice::DeviceIndexForWindow(pFrame->GetHWnd()));
+ int dpi = device ? device->GetScaleX() * 96 : 96;
+
+ // GetSystemMetricsForDpi gives incorrect values, use AdjustWindowRectExForDpi for border metrics instead
+ RECT rect = {0};
+ DWORD style = pFrame->IsResizable() ? WS_OVERLAPPEDWINDOW : WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME;
+ AwtToolkit::AdjustWindowRectExForDpi(&rect, style, FALSE, NULL, dpi);
+ ::SetRect(insets, -rect.left, -rect.top, rect.right, rect.bottom);
}
LRESULT HitTestNCA(AwtFrame* frame, int x, int y) {
diff --git a/src/windows/native/sun/windows/awt_Toolkit.cpp b/src/windows/native/sun/windows/awt_Toolkit.cpp
index 2ebdde0db4..6d65e856c8 100644
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp
+++ b/src/windows/native/sun/windows/awt_Toolkit.cpp
@@ -132,6 +132,7 @@ extern "C" JNIEXPORT jboolean JNICALL AWTIsHeadless() {
#define IDT_AWT_MOUSECHECK 0x101
EnableNonClientDpiScalingFunc* AwtToolkit::lpEnableNonClientDpiScaling = NULL;
+AdjustWindowRectExForDpiFunc* AwtToolkit::lpAdjustWindowRectExForDpi = NULL;
static LPCTSTR szAwtToolkitClassName = TEXT("SunAwtToolkit");
@@ -683,6 +684,7 @@ BOOL AwtToolkit::Initialize(BOOL localPump) {
HMODULE hLibUser32Dll = JDK_LoadSystemLibrary("User32.dll");
if (hLibUser32Dll != NULL) {
lpEnableNonClientDpiScaling = (EnableNonClientDpiScalingFunc*)GetProcAddress(hLibUser32Dll, "EnableNonClientDpiScaling");
+ lpAdjustWindowRectExForDpi = (AdjustWindowRectExForDpiFunc*)GetProcAddress(hLibUser32Dll, "AdjustWindowRectExForDpi");
::FreeLibrary(hLibUser32Dll);
}
diff --git a/src/windows/native/sun/windows/awt_Toolkit.h b/src/windows/native/sun/windows/awt_Toolkit.h
index 664a986e3b..18fc2ad00e 100644
--- a/src/windows/native/sun/windows/awt_Toolkit.h
+++ b/src/windows/native/sun/windows/awt_Toolkit.h
@@ -444,6 +444,12 @@ public:
return lpEnableNonClientDpiScaling != NULL ? lpEnableNonClientDpiScaling(hwnd) : FALSE;
}
+ static INLINE BOOL AdjustWindowRectExForDpi(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi)
+ {
+ return lpAdjustWindowRectExForDpi != NULL ?
+ lpAdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi) : ::AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
+ }
+
HANDLE m_waitEvent;
DWORD eventNumber;
private:
@@ -506,6 +512,7 @@ private:
CriticalSection m_Sync;
static EnableNonClientDpiScalingFunc *lpEnableNonClientDpiScaling;
+ static AdjustWindowRectExForDpiFunc *lpAdjustWindowRectExForDpi;
/* track display changes - used by palette-updating code.
This is a workaround for a windows bug that prevents