Skip to content

Commit 86288d0

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] Adapt autoscaling behavior in the getters for bounds
This commit adapt the behavior of Control#getBounds getSize and getLocation if autoscaling of a control is disabled, but the autoscaling of the parent is not disabled. As of now it always used the parent zoom to scale down the pixel values. This led to issues with existing implementations that were built to use the bounds of the control in its own zoom context.
1 parent 63d5582 commit 86288d0

File tree

1 file changed

+11
-4
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ int getBorderWidthInPixels () {
12141214
*/
12151215
public Rectangle getBounds (){
12161216
checkWidget ();
1217-
return Win32DPIUtils.pixelToPoint(getBoundsInPixels (), computeBoundsZoom());
1217+
return Win32DPIUtils.pixelToPoint(getBoundsInPixels (), computeGetBoundsZoom());
12181218
}
12191219

12201220
Rectangle getBoundsInPixels () {
@@ -1410,7 +1410,7 @@ public Object getLayoutData () {
14101410
public Point getLocation () {
14111411
checkWidget ();
14121412
//For a location the closest point values is okay
1413-
return Win32DPIUtils.pixelToPointAsLocation(getLocationInPixels(), computeBoundsZoom());
1413+
return Win32DPIUtils.pixelToPointAsLocation(getLocationInPixels(), computeGetBoundsZoom());
14141414
}
14151415

14161416
Point getLocationInPixels () {
@@ -1566,7 +1566,7 @@ public Shell getShell () {
15661566
*/
15671567
public Point getSize (){
15681568
checkWidget ();
1569-
return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels (), computeBoundsZoom());
1569+
return Win32DPIUtils.pixelToPointAsSize(getSizeInPixels (), computeGetBoundsZoom());
15701570
}
15711571

15721572
Point getSizeInPixels () {
@@ -4831,7 +4831,14 @@ int getShellZoom() {
48314831
return nativeZoom;
48324832
}
48334833

4834-
private int computeBoundsZoom() {
4834+
private int computeGetBoundsZoom() {
4835+
if (parent != null && !autoScaleDisabled) {
4836+
return parent.getZoom();
4837+
}
4838+
return getZoom();
4839+
}
4840+
4841+
int computeBoundsZoom() {
48354842
if (parent != null) {
48364843
return parent.getZoom();
48374844
}

0 commit comments

Comments
 (0)