Skip to content

Commit c66545b

Browse files
amartya4256HeikoKlare
authored andcommitted
Replaced the DPIUtil scale by scale with zoom call
This commit replaces the DPIUtil calls from clients in win32 which are still using DPIUtil autoScale calls, with scale calls utilizing the zoom available within the clients. contributes to #62 and #127
1 parent 40b4fc6 commit c66545b

File tree

9 files changed

+30
-24
lines changed

9 files changed

+30
-24
lines changed

bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/awt/SWT_AWT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public static Frame new_Frame (final Composite parent) {
250250

251251
parent.getDisplay().asyncExec(() -> {
252252
if (parent.isDisposed()) return;
253-
final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea()); // To Pixels
253+
final Rectangle clientArea = DPIUtil.scaleUp(parent.getClientArea(), DPIUtil.getZoomForAutoscaleProperty(parent.nativeZoom)); // To Pixels
254254
EventQueue.invokeLater(() -> {
255255
frame.setSize (clientArea.width, clientArea.height);
256256
frame.validate ();

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,10 @@ private void drag(Event dragEvent) {
530530
*/
531531
int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
532532
OS.RedrawWindow (topControl.handle, null, 0, flags);
533+
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
533534
POINT pt = new POINT ();
534-
pt.x = DPIUtil.autoScaleUp(dragEvent.x);// To Pixels
535-
pt.y = DPIUtil.autoScaleUp(dragEvent.y);// To Pixels
535+
pt.x = DPIUtil.scaleUp(dragEvent.x, zoom);// To Pixels
536+
pt.y = DPIUtil.scaleUp(dragEvent.y, zoom);// To Pixels
536537
OS.MapWindowPoints (control.handle, 0, pt, 1);
537538
RECT rect = new RECT ();
538539
OS.GetWindowRect (hwndDrag, rect);

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,9 @@ int DragEnter_64(long pDataObject, int grfKeyState, long pt, long pdwEffect) {
281281
}
282282

283283
int DragEnter(long pDataObject, int grfKeyState, int pt_x, int pt_y, long pdwEffect) {
284-
pt_x = DPIUtil.autoScaleDown(pt_x);// To Points
285-
pt_y = DPIUtil.autoScaleDown(pt_y);// To Points
284+
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
285+
pt_x = DPIUtil.scaleDown(pt_x, zoom);// To Points
286+
pt_y = DPIUtil.scaleDown(pt_y, zoom);// To Points
286287
selectedDataType = null;
287288
selectedOperation = DND.DROP_NONE;
288289
if (iDataObject != null) iDataObject.Release();
@@ -348,8 +349,9 @@ int DragOver_64(int grfKeyState, long pt, long pdwEffect) {
348349
}
349350

350351
int DragOver(int grfKeyState, int pt_x, int pt_y, long pdwEffect) {
351-
pt_x = DPIUtil.autoScaleDown(pt_x);// To Points
352-
pt_y = DPIUtil.autoScaleDown(pt_y);// To Points
352+
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
353+
pt_x = DPIUtil.scaleDown(pt_x, zoom);// To Points
354+
pt_y = DPIUtil.scaleDown(pt_y, zoom);// To Points
353355
if (iDataObject == null) return COM.S_FALSE;
354356
int oldKeyOperation = keyOperation;
355357

@@ -403,8 +405,9 @@ int Drop_64(long pDataObject, int grfKeyState, long pt, long pdwEffect) {
403405

404406
int Drop(long pDataObject, int grfKeyState, int pt_x, int pt_y, long pdwEffect) {
405407
try {
406-
pt_x = DPIUtil.autoScaleDown(pt_x);// To Points
407-
pt_y = DPIUtil.autoScaleDown(pt_y);// To Points
408+
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
409+
pt_x = DPIUtil.scaleDown(pt_x, zoom);// To Points
410+
pt_y = DPIUtil.scaleDown(pt_y, zoom);// To Points
408411
DNDEvent event = new DNDEvent();
409412
event.widget = this;
410413
event.time = OS.GetMessageTime();

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDropTargetEffect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void dragOver(DropTargetEvent event) {
151151
int effect = checkEffect(event.feedback);
152152
long handle = table.handle;
153153
Point coordinates = new Point(event.x, event.y);
154-
coordinates = DPIUtil.autoScaleUp(table.toControl(coordinates)); // To Pixels
154+
coordinates = DPIUtil.scaleUp(table.toControl(coordinates), DPIUtil.getZoomForAutoscaleProperty(table.nativeZoom)); // To Pixels
155155
LVHITTESTINFO pinfo = new LVHITTESTINFO();
156156
pinfo.x = coordinates.x;
157157
pinfo.y = coordinates.y;

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDropTargetEffect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void dragOver(DropTargetEvent event) {
165165
int effect = checkEffect(event.feedback);
166166
long handle = tree.handle;
167167
Point coordinates = new Point(event.x, event.y);
168-
coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); // To Pixels
168+
coordinates = DPIUtil.scaleUp(tree.toControl(coordinates), DPIUtil.getZoomForAutoscaleProperty(tree.nativeZoom)); // To Pixels
169169
TVHITTESTINFO lpht = new TVHITTESTINFO ();
170170
lpht.x = coordinates.x;
171171
lpht.y = coordinates.y;

bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ protected int GetWindow(long phwnd) {
810810
return COM.S_OK;
811811
}
812812
RECT getRect() {
813-
Rectangle area = DPIUtil.autoScaleUp(getClientArea()); // To Pixels
813+
Rectangle area = DPIUtil.scaleUp(getClientArea(), DPIUtil.getZoomForAutoscaleProperty(nativeZoom)); // To Pixels
814814
RECT rect = new RECT();
815815
rect.left = area.x;
816816
rect.top = area.y;
@@ -987,14 +987,14 @@ private int OnInPlaceDeactivate() {
987987
return COM.S_OK;
988988
}
989989
private int OnPosRectChange(long lprcPosRect) {
990-
Point size = DPIUtil.autoScaleUp(getSize()); // To Pixels
990+
Point size = DPIUtil.scaleUp(getSize(), DPIUtil.getZoomForAutoscaleProperty(nativeZoom)); // To Pixels
991991
setExtent(size.x, size.y);
992992
return COM.S_OK;
993993
}
994994
private void onPaint(Event e) {
995995
if (state == STATE_RUNNING || state == STATE_INPLACEACTIVE) {
996996
SIZE size = getExtent();
997-
Rectangle area = DPIUtil.autoScaleUp(getClientArea()); // To Pixels
997+
Rectangle area = DPIUtil.scaleUp(getClientArea(), DPIUtil.getZoomForAutoscaleProperty(nativeZoom)); // To Pixels
998998
RECT rect = new RECT();
999999
if (getProgramID().startsWith("Excel.Sheet")) { //$NON-NLS-1$
10001000
rect.left = area.x; rect.right = area.x + (area.height * size.cx / size.cy);
@@ -1369,11 +1369,12 @@ void setBorderSpace(RECT newBorderwidth) {
13691369
setBounds();
13701370
}
13711371
void setBounds() {
1372-
Rectangle area = DPIUtil.autoScaleUp(frame.getClientArea()); // To Pixels
1373-
setBounds(DPIUtil.autoScaleDown(borderWidths.left),
1374-
DPIUtil.autoScaleDown(borderWidths.top),
1375-
DPIUtil.autoScaleDown(area.width - borderWidths.left - borderWidths.right),
1376-
DPIUtil.autoScaleDown(area.height - borderWidths.top - borderWidths.bottom));
1372+
int zoom = DPIUtil.getZoomForAutoscaleProperty(nativeZoom);
1373+
Rectangle area = DPIUtil.scaleDown(frame.getClientArea(), zoom); // To Pixels
1374+
setBounds(DPIUtil.scaleDown(borderWidths.left, zoom),
1375+
DPIUtil.scaleDown(borderWidths.top, zoom),
1376+
DPIUtil.scaleDown(area.width - borderWidths.left - borderWidths.right, zoom),
1377+
DPIUtil.scaleDown(area.height - borderWidths.top - borderWidths.bottom, zoom));
13771378
setObjectRects();
13781379
}
13791380
private void setExtent(int width, int height){

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ long EnumFontFamProc (long lpelfe, long lpntme, long FontType, long lParam) {
407407
*/
408408
public Rectangle getBounds() {
409409
checkDevice ();
410-
return DPIUtil.autoScaleDown(getBoundsInPixels());
410+
return DPIUtil.scaleDown(getBoundsInPixels(), getDeviceZoom());
411411
}
412412

413413
private Rectangle getBoundsInPixels () {
@@ -514,7 +514,7 @@ public Point getDPI () {
514514
int dpiX = OS.GetDeviceCaps (hDC, OS.LOGPIXELSX);
515515
int dpiY = OS.GetDeviceCaps (hDC, OS.LOGPIXELSY);
516516
internal_dispose_GC (hDC, null);
517-
return DPIUtil.autoScaleDown(new Point (dpiX, dpiY));
517+
return DPIUtil.scaleDown(new Point (dpiX, dpiY), getDeviceZoom());
518518
}
519519

520520
/**

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ public final class Image extends Resource implements Drawable {
204204
public Image(Device device, int width, int height) {
205205
super(device);
206206
initialNativeZoom = DPIUtil.getNativeDeviceZoom();
207-
width = DPIUtil.autoScaleUp (width);
208-
height = DPIUtil.autoScaleUp (height);
207+
final int zoom = getZoom();
208+
width = DPIUtil.scaleUp (width, zoom);
209+
height = DPIUtil.scaleUp (height, zoom);
209210
init(width, height);
210211
init();
211212
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public abstract class Widget {
6464
*
6565
* @noreference This field is not intended to be referenced by clients.
6666
*/
67-
protected int nativeZoom;
67+
public int nativeZoom;
6868
int style, state;
6969
Display display;
7070
EventTable eventTable;

0 commit comments

Comments
 (0)