Skip to content

Commit 10fe424

Browse files
Replace nativeZoom of widgets with disabled autoscaling with 100
The nativeZoom of some widgets currently always has the original native zoom value, even if autoscaling is disabled for that widget such that they behave as if their native zoom is effectively 100. With this change the behavior of those widgets will be fixed as per autoscale disabled value.
1 parent 85879e7 commit 10fe424

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,7 +3534,7 @@ public void setLayoutData (Object layoutData) {
35343534
*/
35353535
public void setLocation (int x, int y) {
35363536
checkWidget ();
3537-
int zoom = getZoom();
3537+
int zoom = autoScaleDisabled ? parent.getZoom() : getZoom();
35383538
x = Win32DPIUtils.pointToPixel(x, zoom);
35393539
y = Win32DPIUtils.pointToPixel(y, zoom);
35403540
setLocationInPixels(x, y);
@@ -3791,7 +3791,7 @@ public void setRegion (Region region) {
37913791
*/
37923792
public void setSize (int width, int height) {
37933793
checkWidget ();
3794-
int zoom = getZoom();
3794+
int zoom = autoScaleDisabled ? parent.getZoom() : getZoom();
37953795
width = Win32DPIUtils.pointToPixel(width, zoom);
37963796
height = Win32DPIUtils.pointToPixel(height, zoom);
37973797
setSizeInPixels(width, height);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ public void setCursor(Cursor newCursor) {
823823
checkWidget();
824824
clientCursor = newCursor;
825825
if (newCursor != null) {
826-
if (inEvent) OS.SetCursor (Cursor.win32_getHandle(clientCursor, DPIUtil.getZoomForAutoscaleProperty(getNativeZoom())));
826+
if (inEvent) OS.SetCursor (Cursor.win32_getHandle(clientCursor, getZoom()));
827827
}
828828
}
829829

@@ -892,7 +892,7 @@ long transparentProc (long hwnd, long msg, long wParam, long lParam) {
892892
break;
893893
case OS.WM_SETCURSOR:
894894
if (clientCursor != null) {
895-
OS.SetCursor (Cursor.win32_getHandle(clientCursor, DPIUtil.getZoomForAutoscaleProperty(getNativeZoom())));
895+
OS.SetCursor (Cursor.win32_getHandle(clientCursor, getZoom()));
896896
return 1;
897897
}
898898
if (resizeCursor != 0) {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,7 @@ public void setData (String key, Object value) {
14731473

14741474
if (DATA_AUTOSCALE_DISABLED.equals(key)) {
14751475
autoScaleDisabled = Boolean.parseBoolean(value.toString());
1476+
this.nativeZoom = 100;
14761477
}
14771478
}
14781479

@@ -2711,9 +2712,6 @@ GC createNewGC(long hDC, GCData data) {
27112712
}
27122713

27132714
int getNativeZoom() {
2714-
if (autoScaleDisabled) {
2715-
return 100;
2716-
}
27172715
return nativeZoom;
27182716
}
27192717

@@ -2725,7 +2723,7 @@ int getZoom() {
27252723
}
27262724

27272725
void handleDPIChange(Event event, float scalingFactor) {
2728-
this.nativeZoom = event.detail;
2726+
this.nativeZoom = this.autoScaleDisabled ? 100 : event.detail;;
27292727
}
27302728

27312729
int getSystemMetrics(int nIndex) {

0 commit comments

Comments
 (0)