Skip to content

Commit

Permalink
[win] GetDpiForMonitor: prevent devision by zero #193
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T authored and jukzi committed Apr 26, 2024
1 parent 3525ab0 commit 04f724a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -28,7 +28,7 @@ public final class Monitor {
long handle;
int x, y, width, height;
int clientX, clientY, clientWidth, clientHeight;
int zoom;
int zoom = 100;

/**
* Prevents uninitialized instances from being created outside the package.
Expand Down
Expand Up @@ -2153,6 +2153,10 @@ Monitor getMonitor (long hmonitor) {
int [] dpiY = new int[1];
int result = OS.GetDpiForMonitor (monitor.handle, OS.MDT_EFFECTIVE_DPI, dpiX, dpiY);
result = (result == OS.S_OK) ? DPIUtil.mapDPIToZoom (dpiX[0]) : 100;
if (result == 0) {
System.err.println("***WARNING: GetDpiForMonitor: SWT could not get valid monitor scaling factor.");
result = 100;
}
/*
* Always return true monitor zoom value as fetched from native, else will lead
* to scaling issue on OS Win8.1 and above, for more details refer bug 537614.
Expand Down

0 comments on commit 04f724a

Please sign in to comment.