Skip to content

Commit a0648ed

Browse files
Addressing Comments
1 parent 7ea6253 commit a0648ed

File tree

6 files changed

+26
-10
lines changed

6 files changed

+26
-10
lines changed

bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,15 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(AdjustWindowRectExForDpi)
130130
{
131131
RECT _arg0, *lparg0=NULL;
132132
jboolean rc = 0;
133+
133134
OS_NATIVE_ENTER(env, that, AdjustWindowRectExForDpi_FUNC);
134135
if (arg0) if ((lparg0 = getRECTFields(env, arg0, &_arg0)) == NULL) goto fail;
135-
rc = (jboolean)AdjustWindowRectExForDpi(lparg0, arg1, arg2, arg3, arg4);
136+
{
137+
OS_LOAD_FUNCTION(fp, GetSystemMetricsForDpi)
138+
if (fp) {
139+
rc = (jboolean)((jboolean (CALLING_CONVENTION*)(RECT *, jint, jboolean, jint, jint))fp)(&lparg0, arg1, arg2, arg3, arg4);
140+
}
141+
}
136142
fail:
137143
if (arg0 && lparg0) setRECTFields(env, arg0, lparg0);
138144
OS_NATIVE_EXIT(env, that, AdjustWindowRectExForDpi_FUNC);

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Control computeTabRoot () {
313313
int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
314314
int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
315315
boolean hasMenu = OS.GetMenu (handle) != 0;
316-
OS.AdjustWindowRectExForDpi (rect, bits1, hasMenu, bits2, getZoom());
316+
adjustWindowRectEx(rect, bits1, hasMenu, bits2);
317317

318318
/* Get the size of the scroll bars */
319319
if (horizontalBar != null) rect.bottom += getSystemMetrics (OS.SM_CYHSCROLL);
@@ -472,7 +472,7 @@ void fixDecorations (Decorations newDecorations, Control control, Menu [] menus)
472472
int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
473473
int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
474474
boolean hasMenu = OS.GetMenu (handle) != 0;
475-
OS.AdjustWindowRectExForDpi (rect, bits1, hasMenu, bits2, getZoom());
475+
adjustWindowRectEx(rect, bits1, hasMenu, bits2);
476476
width = Math.max (0, width - (rect.right - rect.left));
477477
height = Math.max (0, height - (rect.bottom - rect.top));
478478
return new Rectangle (0, 0, width, height);

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) {
134134
OS.SetRect (rect, x, y, x + width, y + height);
135135
int bits1 = OS.GetWindowLong (scrolledHandle, OS.GWL_STYLE);
136136
int bits2 = OS.GetWindowLong (scrolledHandle, OS.GWL_EXSTYLE);
137-
OS.AdjustWindowRectExForDpi (rect, bits1, false, bits2, getZoom());
137+
adjustWindowRectEx(rect, bits1, false, bits2);
138138
if (horizontalBar != null) rect.bottom += getSystemMetrics (OS.SM_CYHSCROLL);
139139
if (verticalBar != null) rect.right += getSystemMetrics (OS.SM_CXVSCROLL);
140140
int nWidth = rect.right - rect.left, nHeight = rect.bottom - rect.top;

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ Point getMaximumSizeInPixels () {
10681068
RECT rect = new RECT ();
10691069
int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
10701070
int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
1071-
OS.AdjustWindowRectExForDpi (rect, bits1, false, bits2, getZoom());
1071+
adjustWindowRectEx(rect, bits1, false, bits2);
10721072
height = Math.min (height, rect.bottom - rect.top);
10731073
}
10741074
}
@@ -1109,7 +1109,7 @@ Point getMinimumSizeInPixels () {
11091109
RECT rect = new RECT ();
11101110
int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
11111111
int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
1112-
OS.AdjustWindowRectExForDpi (rect, bits1, false, bits2, getZoom());
1112+
adjustWindowRectEx(rect, bits1, false, bits2);
11131113
height = Math.max (height, rect.bottom - rect.top);
11141114
}
11151115
}
@@ -1815,7 +1815,7 @@ void setMaximumSizeInPixels (int width, int height) {
18151815
RECT rect = new RECT ();
18161816
int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
18171817
int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
1818-
OS.AdjustWindowRectExForDpi (rect, bits1, false, bits2, getZoom());
1818+
adjustWindowRectEx(rect, bits1, false, bits2);
18191819
heightLimit = rect.bottom - rect.top;
18201820
}
18211821
}
@@ -1861,7 +1861,7 @@ void setMinimumSizeInPixels (int width, int height) {
18611861
RECT rect = new RECT ();
18621862
int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
18631863
int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
1864-
OS.AdjustWindowRectExForDpi (rect, bits1, false, bits2, getZoom());
1864+
adjustWindowRectEx(rect, bits1, false, bits2);
18651865
heightLimit = rect.bottom - rect.top;
18661866
}
18671867
}
@@ -2671,7 +2671,7 @@ LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) {
26712671
RECT rect = new RECT ();
26722672
int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
26732673
int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
2674-
OS.AdjustWindowRectExForDpi (rect, bits1, false, bits2, getZoom());
2674+
adjustWindowRectEx(rect, bits1, false, bits2);
26752675
lpwp.cy = Math.max (lpwp.cy, rect.bottom - rect.top);
26762676
}
26772677
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void addVerifyListener (VerifyListener listener) {
320320
bits0 &= ~OS.WS_BORDER;
321321
bits1 |= OS.WS_EX_CLIENTEDGE;
322322
}
323-
OS.AdjustWindowRectExForDpi (rect, bits0, false, bits1, getZoom());
323+
adjustWindowRectEx(rect, bits0, false, bits1);
324324
width = rect.right - rect.left;
325325
height = rect.bottom - rect.top;
326326

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,5 +2708,15 @@ int getSystemMetrics(int nIndex) {
27082708
return OS.GetSystemMetrics(nIndex);
27092709
}
27102710

2711+
boolean adjustWindowRectEx(RECT lpRect, int dwStyle, boolean bMenu, int dwExStyle) {
2712+
/*
2713+
* DPI dependent metrics were introduced after 2016 version of windows 10
2714+
*/
2715+
if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607) {
2716+
return OS.AdjustWindowRectExForDpi (lpRect, dwStyle, bMenu, dwExStyle, getZoom());
2717+
}
2718+
return OS.AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
2719+
}
2720+
27112721

27122722
}

0 commit comments

Comments
 (0)