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

Optional Windows application manifest file to enable DPI awareness #4191

Closed
Demonese opened this issue Jun 2, 2021 · 4 comments
Closed

Optional Windows application manifest file to enable DPI awareness #4191

Demonese opened this issue Jun 2, 2021 · 4 comments

Comments

@Demonese
Copy link
Contributor

Demonese commented Jun 2, 2021

Version/Branch of Dear ImGui:

Version: any
Branch: any

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp + imgui_impl_win32.cpp
Compiler: MSVC
Operating System: Windows

My Issue/Question:

I think we can provide a sample application manifest file in misc directory:

  • common.manifest
<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <assemblyIdentity type="win32" name="Application" version="1.0.0.0"/>
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
            <!-- Windows 10 -->
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
            <!-- Windows 8.1 -->
            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
            <!-- Windows 8 -->
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
            <!-- Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
            <!-- Windows Vista -->
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
        </application>
    </compatibility>
    <asmv3:application>
        <asmv3:windowsSettings>
            <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
            <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
        </asmv3:windowsSettings>
    </asmv3:application>
</assembly>
  • your cmake file
target_sources(foo PRIVATE
    common.manifest
)

This manifest file can replace the complex loading DLL/function call. If anyone needs it.

@ocornut
Copy link
Owner

ocornut commented Jun 2, 2021 via email

@ocornut
Copy link
Owner

ocornut commented Jun 4, 2021

FYI the function we provide is ImGui_ImplWin32_EnableDpiAwareness().
Hopefully the manifest can be useful too, with other or custom backends.
I believe GLFW always enable this, and SDL has a flag on the window for it.
Closing it as there's no specific action required but this thread is now nicely findable and labeled :) Thank you!

@ocornut
Copy link
Owner

ocornut commented Jun 6, 2021

As pointed by #4200 there is indeed an issue with our function, which is that it seems to requires a manifest to "upgrade" DPI handling from 8.1-era support to 10-era support (varying DPI), so there are ways we can improve that.

ocornut added a commit that referenced this issue Jun 8, 2021
@ocornut
Copy link
Owner

ocornut commented Jun 8, 2021

PS: See improvement done in #4200 (comment)

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

2 participants