Skip to content

Commit 7d0ba65

Browse files
committed
[win32] different coordinate system strategie
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display Contributes to #62 and #131
1 parent f3e2582 commit 7d0ba65

File tree

5 files changed

+370
-33
lines changed

5 files changed

+370
-33
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,9 @@ void subclass () {
39703970
public Point toControl (int x, int y) {
39713971
checkWidget ();
39723972
int zoom = getZoom();
3973-
return DPIUtil.scaleDown(toControlInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom)), zoom);
3973+
Point displayPointInPixels = getDisplay().translateToDisplayCoordinates(new Point(x, y), zoom);
3974+
final Point controlPointInPixels = toControlInPixels(displayPointInPixels.x, displayPointInPixels.y);
3975+
return DPIUtil.scaleDown(controlPointInPixels, zoom);
39743976
}
39753977

39763978
Point toControlInPixels (int x, int y) {
@@ -4003,9 +4005,7 @@ Point toControlInPixels (int x, int y) {
40034005
public Point toControl (Point point) {
40044006
checkWidget ();
40054007
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
4006-
int zoom = getZoom();
4007-
point = DPIUtil.scaleUp(point, zoom);
4008-
return DPIUtil.scaleDown(toControlInPixels(point.x, point.y), zoom);
4008+
return toControl(point.x, point.y);
40094009
}
40104010

40114011
/**
@@ -4031,7 +4031,8 @@ public Point toControl (Point point) {
40314031
public Point toDisplay (int x, int y) {
40324032
checkWidget ();
40334033
int zoom = getZoom();
4034-
return DPIUtil.scaleDown(toDisplayInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom)), zoom);
4034+
Point displayPointInPixels = toDisplayInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom));
4035+
return getDisplay().translateFromDisplayCoordinates(displayPointInPixels, zoom);
40354036
}
40364037

40374038
Point toDisplayInPixels (int x, int y) {
@@ -4064,9 +4065,7 @@ Point toDisplayInPixels (int x, int y) {
40644065
public Point toDisplay (Point point) {
40654066
checkWidget ();
40664067
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
4067-
int zoom = getZoom();
4068-
point = DPIUtil.scaleUp(point, zoom);
4069-
return DPIUtil.scaleDown(toDisplayInPixels(point.x, point.y), zoom);
4068+
return toDisplay(point.x, point.y);
40704069
}
40714070

40724071
long topHandle () {

0 commit comments

Comments
 (0)