marchaesen / vcxsrv

Windows X-server based on the xorg git sources (like xming or cygwin's xwin), but compiled with Visual Studio 2012 Community Edition.
GNU General Public License v3.0
358 stars 14 forks source link

Add support for Visual Styles and DPI-Awareness #18

Closed KohChia closed 3 months ago

KohChia commented 3 months ago

The UI of the main program xlaunch.exe is outdated which uses the classic Windows styles, and also it does not support for high DPI monitor. I suggest that these features should be added. img0 After Visual Styles added: img1 After DPI-Awareness added (when running on high DPI monitor): img2 It is easy to add these features by adding an extra manifest file to resource script:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
        </dependentAssembly>
    </dependency>
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
            </requestedPrivileges>
        </security>
    </trustInfo>
    <application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings>
            <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
        </windowsSettings>
    </application>
</assembly>

Add the manifest resource in any resource script file (*.rc):

// add manifest for program (the content shown above):
1 24 "manifest.xml"

Update dialogs settings in all dialog relative resource script file (*.rc):

// always DIALOGEX not DIALOG
IDD_XXX DIALOGEX 0, 0, ..., ...
// change DS_SETFONT to DS_SHELLFONT (if any)
STYLE DS_SHELLFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE
// the caption...
CAPTION STR_CAPTION_XXX
// always use "MS Shell Dlg"
FONT 8, "MS Shell Dlg"

Update InitCommonControls to InitCommonControlsEx in main.cc.

// change
InitCommonControls();
// to
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&icex);
marchaesen commented 3 months ago

Added to 21.1.13 release

htngr commented 3 months ago

A similar manifest could be included in vcxsrv.exe itself so that X applications render correctly when using DPI scaling

abbno commented 1 month ago

when i use 4k screen , run then jetbrain idea on linux by x11 , idea is blurry, version 21.1.13

htngr commented 1 month ago

This can be solved by right clicking on the VcXsrv executable (probably under C:\ProgramFiles\VcXsrv) > Preferences > Override High DPI Scaling Behaviour > Scaling performed by: Application.

See https://stackoverflow.com/questions/45759789/change-override-high-dpi-scaling-behavior-in-c-sharp

But since I'm using VcXsrv inside a MSIX, the Windows registry which is modified by the above setting is isolated and DPI scaling is still not working. Maybe this can be solved by enabling DPI scaling via the executable manifest of vcxsrv.exe as described by OP?

Tagging @marchaesen