Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc - High-DPI support is now enabled by default in Chromium #4410

Open
amaitland opened this issue Feb 27, 2023 · 6 comments
Open

Doc - High-DPI support is now enabled by default in Chromium #4410

amaitland opened this issue Feb 27, 2023 · 6 comments

Comments

@amaitland
Copy link
Member

amaitland commented Feb 27, 2023

Starting in M108 High-DPI support is now enabled by default in Chromium.

Additionally, as a refactor to move responsibility out of the embedder
this change moves the existing EnableHighDPISupport calls in
chrome_exe_main_win.cc into the respective GpuMain &
BrowserMainRunnerImpl for the GPU & Browser processes.

chromiumembedded/cef#3452

amaitland added a commit to cefsharp/CefSharp.MinimalExample that referenced this issue Mar 7, 2023
- Remove DPI entries from app.manifest
- Remove Cef.EnableHighDPISupport (Method will be removed in M113 (cefsharp/CefSharp#4417))

Issue cefsharp/CefSharp#4410
amaitland added a commit that referenced this issue Mar 7, 2023
- Chromium now enables DPI awareness programmatically by default
- Remove Cef.EnableHighDPISupport calls and mark as obsolete
- Remove dpiawareness entries from app.manifest

Issues #4417 #4410
@amaitland
Copy link
Member Author

For WPF the default would appear to be still System aware, WPF must be setting that somewhere internally (which makes sense as that's the default that WPF uses). So setting via the app.manifest is still required.

amaitland added a commit that referenced this issue Mar 13, 2023
- NetCore has it's own exe which still had a call to EnableHighDPISupport
- WPF seems to default to System DPI aware, revert to using app.manifest for PerMonitorV2

Follow up to b17cd2a

Issues #4417 #4410
@amaitland amaitland added this to the 111.1.x milestone Mar 13, 2023
amaitland added a commit that referenced this issue Mar 13, 2023
- NetCore has it's own exe which still had a call to EnableHighDPISupport
- WPF seems to default to System DPI aware, revert to using app.manifest for PerMonitorV2

Follow up to b17cd2a

Issues #4417 #4410
@amaitland amaitland changed the title Doc - Chromium DPI Awareness Changes Doc - High-DPI support is now enabled by default in Chromium Mar 15, 2023
@amaitland
Copy link
Member Author

amaitland commented Mar 15, 2023

M111 will be the first version to rely on the Chromium default. The BrowserSubProcess no longer has app.manifest entries for DPI Awareness. Setting the DPI Awareness programmatically looks like it also influences the GPU process. See #2927 (comment)

@UweKeim
Copy link

UweKeim commented May 9, 2023

I want to continue using CefSharp in a WinForms app that is currently not yet capable of running in High-DPI mode.

Is there still a way to fall back to non-High-DPI mode?


Update 1

It seems that disabling High-DPI through the application manifest did not help.

Instead, I removed all High-DPI related stuff from the manifest and instead did call the following right at the beginning of my application:

SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);

So far, it seems that this works.

(Context: I'm using CefSharp as "self-hosted" in a .NET 7 WinForms application, 64-bit)

@Yokomoko
Copy link

I cannot seem to find this SetProcessDpiAwarenessContext method, do you know where this is? As I also need this.

@UweKeim
Copy link

UweKeim commented May 10, 2023

@Yokomoko Sure, it is P/Invoke:

[DllImport(@"user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetProcessDpiAwarenessContext(IntPtr dpiAWarenessContext);

private const int DPI_AWARENESS_CONTEXT_UNAWARE = -1;
private const int DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = -5;

My call then looks like:

var r = SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
if (!r)
{
    var error = Marshal.GetLastWin32Error();
    Trace.TraceWarning($@"Error settings DPI awareness: {error}.");
}

@amaitland amaitland modified the milestones: 112.2.x, 113.0.x May 12, 2023
@amaitland amaitland modified the milestones: 113.1.x, 114.2.x Jun 8, 2023
@amaitland amaitland modified the milestones: 114.2.x, 115.2.x Jul 26, 2023
@amaitland amaitland modified the milestones: 115.2.x, 116.0.x Aug 19, 2023
@amaitland amaitland modified the milestones: 116.0.x, 117.2.x Oct 8, 2023
@amaitland amaitland modified the milestones: 117.2.x, 118.6.x Oct 27, 2023
@amaitland amaitland removed this from the 118.6.x milestone Nov 10, 2023
@amaitland amaitland added this to the 119.1.x milestone Nov 10, 2023
@amaitland amaitland removed this from the 119.1.x milestone Dec 16, 2023
@jquerijero
Copy link

jquerijero commented May 24, 2024

There is a bitmap scaling that is used by Terminal Server and newer Windows versions for non-DPI aware (manifest not modified) application. Chromium instance is overriding that function by re-rendering the application (including windows that doesn't contain an embedded browser) causing it to resize and remove bitmap scaling.

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

No branches or pull requests

4 participants