Solaire / GLC

Lightweight, console-based, tool which automatically detects installed games and displays them to the user.
GNU General Public License v3.0
16 stars 3 forks source link

With desktop scaling enabled, icon is incorrectly placed #52

Closed Nutzzz closed 2 years ago

Nutzzz commented 2 years ago

image

Nutzzz commented 2 years ago

I've been working on this, so I figured I'd post an update.

First stumbling block: A method that gives me a usable scale or DPI for a command line program. I tried many possibilities, but I finally found one that worked for me: GetDpiForWindow() in user32.dll. Divide by 96, and you get the scaling percentage; though note this requires Windows 10 1607. The manifest need not be adjusted to change DPI_AWARENESS.

Now it's on to the second stumbling block: It seems the GDI surface needs to be resized as well somehow. Multiplying x, y, w, and h by the scaling factor moves the image out of the visible area. By multiplying just w and h, the problem becomes clear:

image

EDIT: Just to be clear, having gdiScaling set to true and/or dpiAware set to true/pm and dpiAwareness set to PerMonitorV2,PerMonitor [in the manifest] doesn't change the observed behavior.

EDIT 2: Hm, interesting. Going to the Compatibility tab for glc.exe and changing "Change high DPI settings" > "Override high DPI scaling behavior" to "Application" it working.

image

However, I'm having difficulty so far reproducing the equivalent behavior by changing the app.manifest, App.config, or programatically. I could force the compatibility registry setting, but I'd rather not resort to that except as a last resort.

Nutzzz commented 2 years ago

This did the trick: SetProcessDpiAwarenessContext(GetAwarenessFromDpiAwarenessContext(GetThreadDpiAwarenessContext()) - 3); // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE

EDIT: Fixed in PR #54