Skip to content

[Win32] Remove runtime change of process DPI awareness#3363

Open
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:win32-programmatic-process-dpiawareness
Open

[Win32] Remove runtime change of process DPI awareness#3363
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:win32-programmatic-process-dpiawareness

Conversation

@HeikoKlare

@HeikoKlare HeikoKlare commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

SWT initialization modifies the process DPI awareness via the static initializer of the OS class. This has been implemented for DPI awareness on Windows Vista long time ago (c9bc8bf). Changing process DPI awareness programmatically is discouraged and should rather be done by the application's manifest: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware

In addition, relevant executables into which SWT is embedded (JVM, Equinox launcher etc.) already have state-of-the-art settings for DPI awareness, which even activate higher levels of DPI awareness than what the call to setProcessDPIAware (conforming to "System" DPI awareness) does. In consequence, this call has no benefit but may rather interfere with DPI awareness settings already done via the manifest.

This change thus removes the obsolete programmatic setting of process DPI awareness along with the now unused native method.

SWT initialization modifies the process DPI awareness via the static
initializer of the OS class. This has been implemented for DPI awareness
on Windows Vista long time ago. Changing process DPI awareness
programmatically is discouraged and should rather be done by the
application's manifest. In addition, relevant executables into which SWT
is embedded (JVM, Equinox launcher etc.) already have state-of-the-art
settings for DPI awareness, which even activate higher levels of DPI
awareness than what the call to setProcessDPIAware (conforming to
"System" DPI awareness) does. In consequence, this call has no benefit
but may rather interfere with DPI awareness settings already done via
the manifest.

This change thus removes the obsolete programmatic setting of process
DPI awareness along with the now unused native method.
@HeikoKlare HeikoKlare force-pushed the win32-programmatic-process-dpiawareness branch from 5848adc to 23d3655 Compare June 4, 2026 09:49
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Test Results (win32)

   30 files  +    2     30 suites  +2   5m 50s ⏱️ + 5m 45s
4 704 tests +4 609  4 629 ✅ +4 534  75 💤 +75  0 ❌ ±0 
1 234 runs  +1 113  1 210 ✅ +1 089  24 💤 +24  0 ❌ ±0 

Results for commit 23d3655. ± Comparison against base commit 60e822c.

@HeikoKlare HeikoKlare marked this pull request as ready for review June 4, 2026 10:32
@Phillipus

Copy link
Copy Markdown
Contributor

In consequence, this call has no benefit but may rather interfere with DPI awareness settings already done via the manifest.

Are there any known side-effects of this in the wild?

@HeikoKlare

Copy link
Copy Markdown
Contributor Author

Are there any known side-effects of this in the wild?

No, I am not aware of any. From the API documentation, I would expect the method to "downgrade" the DPI awareness, but even though the method returns "true" (which means "success"), it does actually not change the DPI awareness (otherwise we would have already noticed at many places). The processes still run at PerMonitorV2, so it effectively seems to only upgrade if no DPI awareness is set.

@tmssngr

tmssngr commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

So it might be necessary to fix the launcher executable for all SWT based applications?

@HeikoKlare

Copy link
Copy Markdown
Contributor Author

So it might be necessary to fix the launcher executable for all SWT based applications?

In case you have a custom executable that was configured in a way that setting process DPI awareness from within the process to "System" had any effect, then: in theory, yes.
But I don't see how one should have come into that situation. Conceptually, you would need to have configured a custom manifest for your executable that downgrades default DPI awareness (to something like "unaware") without wanting that, as the process itself then has upgraded that to "system" afterwards (with the statement removed by this PR). This does not sound like a realistic and reasonable scenario.
In addition, practically I seems like even this scenario is not possible to produce: I tried by using a JVM with DPI awareness set to "false"/"unaware" via the manifest and even then this setting was not overridden by the code removed by this PR.

So in summary, I am not sure how the removed code can have had any effect at all. If you have a concrete scenario where the code did anything reasonable (and maybe was even necessary), please let me know.

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.

3 participants