Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.eclipse.swt.widgets;

import static org.eclipse.swt.internal.DPIUtil.setMonitorSpecificScaling;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
import org.junit.jupiter.api.*;
Expand Down Expand Up @@ -104,4 +104,23 @@ public void setRescaleAtRuntime_toggling() {
assertExpectedDpiAwareness(OS.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
}

// https://github.com/eclipse-platform/eclipse.platform.swt/issues/3530
@Test
public void getBoundsAndGetClientAreaUseZoomOfPrimaryMonitor_MatchingGCZoom() throws Exception {
Display display = Display.getDefault();

DPIUtil.setDeviceZoom(200); // must not be considered
Rectangle bounds1 = display.getBounds();
Rectangle clientArea1 = display.getClientArea();
DPIUtil.setDeviceZoom(100); // must not be considered
Rectangle bounds2 = display.getBounds();
Rectangle clientArea2 = display.getClientArea();

assertEquals(bounds2.width, bounds1.width);
assertEquals(clientArea2.width, clientArea1.width);

GC gc = new GC(display);
assertEquals(display.getPrimaryMonitor().getZoom(), gc.getGCData().nativeZoom);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ public Menu getMenuBar () {
@Override
public Rectangle getBounds() {
checkDevice ();
return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), DPIUtil.getDeviceZoom());
return Win32DPIUtils.pixelToPoint(getBoundsInPixels(), getDeviceZoom());
}

Rectangle getBoundsInPixels () {
Expand Down Expand Up @@ -1665,7 +1665,7 @@ int getClickCount (int type, int button, long hwnd, long lParam) {
@Override
public Rectangle getClientArea () {
checkDevice ();
return Win32DPIUtils.pixelToPoint(getClientAreaInPixels(), DPIUtil.getDeviceZoom());
return Win32DPIUtils.pixelToPoint(getClientAreaInPixels(), getDeviceZoom());
}

Rectangle getClientAreaInPixels () {
Expand Down
Loading