mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 09:58:03 +02:00
Display (Windows): supports dpi scale factor detection on Win 7
This commit is contained in:
@@ -32,6 +32,13 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
FF_LIST_AUTO_DESTROY monitors = ffListCreate(sizeof(FFMonitorInfo));
|
||||
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM) &monitors);
|
||||
|
||||
#if FF_WIN7_COMPAT
|
||||
HDC hdc = GetDC(NULL);
|
||||
uint32_t systemDpi = (uint32_t) GetDeviceCaps(hdc, LOGPIXELSX);
|
||||
if (systemDpi == 0) systemDpi = 96;
|
||||
ReleaseDC(NULL, hdc);
|
||||
#endif
|
||||
|
||||
DISPLAYCONFIG_PATH_INFO paths[128];
|
||||
uint32_t pathCount = ARRAY_SIZE(paths);
|
||||
DISPLAYCONFIG_MODE_INFO modes[256];
|
||||
@@ -161,12 +168,21 @@ static void detectDisplays(FFDisplayServerResult* ds)
|
||||
preferredRefreshRate = freq.Numerator / (double) freq.Denominator;
|
||||
}
|
||||
|
||||
uint32_t scaledWidth = (uint32_t) (monitorInfo->info.rcMonitor.right - monitorInfo->info.rcMonitor.left);
|
||||
uint32_t scaledHeight = (uint32_t) (monitorInfo->info.rcMonitor.bottom - monitorInfo->info.rcMonitor.top);
|
||||
|
||||
FFDisplayResult* display = ffdsAppendDisplay(ds,
|
||||
width,
|
||||
height,
|
||||
path->targetInfo.refreshRate.Numerator / (double) path->targetInfo.refreshRate.Denominator,
|
||||
(uint32_t) (monitorInfo->info.rcMonitor.right - monitorInfo->info.rcMonitor.left),
|
||||
(uint32_t) (monitorInfo->info.rcMonitor.bottom - monitorInfo->info.rcMonitor.top),
|
||||
#if FF_WIN7_COMPAT
|
||||
// Windows 7 always reports scaled width as the real width, as I tested on VM with 200% scaling.
|
||||
scaledWidth == width ? width * 96 / systemDpi : scaledWidth,
|
||||
scaledHeight == height ? height * 96 / systemDpi : scaledHeight,
|
||||
#else
|
||||
scaledWidth,
|
||||
scaledHeight,
|
||||
#endif
|
||||
preferredMode.width,
|
||||
preferredMode.height,
|
||||
preferredRefreshRate,
|
||||
|
||||
Reference in New Issue
Block a user