Skip to content

[Win32] Use primary monitor zoom in Display.getBounds() scaling - #3532

Open
sratz wants to merge 1 commit into
eclipse-platform:masterfrom
sratz:display-bounds-zoom
Open

[Win32] Use primary monitor zoom in Display.getBounds() scaling#3532
sratz wants to merge 1 commit into
eclipse-platform:masterfrom
sratz:display-bounds-zoom

Conversation

@sratz

@sratz sratz commented Aug 20, 2026

Copy link
Copy Markdown
Member

Display.getBounds() must not be affected by "zoom-of-the-last-moved-shell", which currently DPIUtil.getDeviceZoom() represents on Windows.

Instead, Display.getBounds() should be consistent with the way a GC for the display is created: via Display.getDeviceZoom(), which in turn uses the zoom of the primary monitor.

The same applies to Display.getClientArea() as well.

Fixes #3530.

@sratz
sratz requested a review from HeikoKlare August 20, 2026 11:59
Display.getBounds() must not be affected by
"zoom-of-the-last-moved-shell", which currently DPIUtil.getDeviceZoom()
represents on Windows.

Instead, Display.getBounds() should be consistent with the way a GC for
the display is created: via Display.getDeviceZoom(), which in turn uses
the zoom of the primary monitor.

The same applies to Display.getClientArea() as well.

Fixes eclipse-platform#3530.
@sratz
sratz force-pushed the display-bounds-zoom branch from 0e11d37 to 5626775 Compare August 20, 2026 12:00
@sratz

sratz commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

The unit test is not really what I envisioned. This is more of a "does not use the wrong API" kind of test instead of actually testing that the primary display zoom is used. But getPrimaryMonitor() returns a new instance every time so I haven't found a way to fake/mock that monitors zoom for testing purposes.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (win32)

   35 files  ±0     35 suites  ±0   4m 52s ⏱️ -36s
4 873 tests +1  4 797 ✅ +1  76 💤 ±0  0 ❌ ±0 
1 400 runs  +1  1 376 ✅ +1  24 💤 ±0  0 ❌ ±0 

Results for commit 5626775. ± Comparison against base commit 3e3b24b.

@HeikoKlare HeikoKlare left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for that fix. The change itself is sound, as we have already discussed in the issue. The only concern I see is about assumptions that other consumers of Display.getBounds()/getClientArea() may make. E.g., some consumers may just work by accident because the used zoom fits to the zoom of the monitor on which the (only) shell is placed, whereas after the change always the primary monitor zoom is used. But I think we should just try and see what happens. Most consumers I found in the Eclipse codebase seem to do some fitting of dialogs into the display bounds, which may not work that fine with the current calculations anyway.

I agree that a "positive" test for the expected behavior would be preferable over such a "negative" does-not-do-the-wrong-thing test. But having thought about it, I do not know a good way for such a test either without requiring to modify OS settings (basically the same issue that we have for monitor zoom testing in general).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Win32] [Hi-DPI] Non-deterministic Display.getBounds() / no way to create a consistent screenshot without internal API

2 participants