Fix setting DPI awareness#6245
Merged
dipeshmsft merged 1 commit intodotnet:mainfrom May 9, 2022
AustinWise:austin/FixDpiAwareness
Merged
Fix setting DPI awareness#6245dipeshmsft merged 1 commit intodotnet:mainfrom AustinWise:austin/FixDpiAwareness
dipeshmsft merged 1 commit intodotnet:mainfrom
AustinWise:austin/FixDpiAwareness
Conversation
Contributor
ThomasGoulet73
left a comment
There was a problem hiding this comment.
Thank you! This is definitely a mistake on my part and I believe that this is the right fix.
Contributor
There was a problem hiding this comment.
Could you keep the comments at the same place as the previous C++ code? You can use this code for reference:
wpf/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/main.cpp
Lines 184 to 205 in 560f243
Contributor
Author
There was a problem hiding this comment.
I changed it it to match the original C++ code more closely. I renamed bDisableDpiAware to disableDpiAware, so that it matches typical C# conventions.
Currently it is only setting DPI awareness if the entry assembly has a DisableDpiAwarenessAttribute applied to it.
dipeshmsft
approved these changes
Mar 17, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently DPI awareness will be enabled only if a
DisableDpiAwarenessAttributeattribute is applied to the entry assembly. Which does not make a lot of sense. This also does not match the behavior of .NET 6.This PR changes the logic to always enable DPI awareness unless a
DisableDpiAwarenessAttributeattribute is applied to the entry assembly.Customer Impact
WPF applications are not DPI aware. This can be seen by:
And then checking the DPI Awareness column in Task Manager. On .NET 6 the DPI awareness is "System". In .NET 7 preview 1, it is "Unaware".
Regression
This regression was introduced by #5765, which migrated the DPI awareness enablement code from C++ to C#.
Testing
Then replace the contents of
MainWindow.xml.cswith:Results of running this program on different versions of WPF:
Risk
Low.