Skip to content

Commit 8478450

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] Calculate zoom for Control#getSystemMetrics via Shell
This commit overrides Widget#getSystemMetrics for Control to utilize Shell#getZoom if possible to define the target zoom. This is necessary if the control has its autoscaling disabled.
1 parent 42fcb47 commit 8478450

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6097,6 +6097,13 @@ void handleDPIChange(Event event, float scalingFactor) {
60976097
}
60986098
}
60996099

6100+
@Override
6101+
int getSystemMetrics(int nIndex) {
6102+
Shell shell = getShell();
6103+
int zoom = shell != null ? shell.getZoom() : nativeZoom;
6104+
return OS.GetSystemMetricsForDpi(nIndex, DPIUtil.mapZoomToDPI(zoom));
6105+
}
6106+
61006107
boolean adjustWindowRectEx(RECT lpRect, int dwStyle, boolean bMenu, int dwExStyle) {
61016108
Shell shell = getShell();
61026109
int zoom = shell != null ? shell.getZoom() : nativeZoom;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,4 +999,12 @@ LRESULT wmScrollChild (long wParam, long lParam) {
999999
return null;
10001000
}
10011001

1002+
@Override
1003+
int getSystemMetrics(int nIndex) {
1004+
// Control#getSystemMetrics should be used if possible,
1005+
// as it considers if autoscaling of a Control is
1006+
// disabled which would affect the ScrollBar as well,
1007+
// therefore the value is fetched via the parent
1008+
return parent.getSystemMetrics(nIndex);
1009+
}
10021010
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,4 +762,13 @@ void handleDPIChange(Event event, float scalingFactor) {
762762
setImage(image);
763763
}
764764
}
765+
766+
@Override
767+
int getSystemMetrics(int nIndex) {
768+
// Control#getSystemMetrics should be used if possible,
769+
// as it considers if autoscaling of a Control is
770+
// disabled which would affect the TreeColumn as well,
771+
// therefore the value is fetched via the parent
772+
return parent.getSystemMetrics(nIndex);
773+
}
765774
}

0 commit comments

Comments
 (0)