From c9c2324e4f13e66c75d886f94dbacac1e28b191f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 May 2025 17:25:26 +0300 Subject: fixes #5009 ("Pin to desktop" option doesn't work in all modern Windows) --- plugins/Clist_modern/src/modern_utils.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'plugins/Clist_modern/src/modern_utils.cpp') diff --git a/plugins/Clist_modern/src/modern_utils.cpp b/plugins/Clist_modern/src/modern_utils.cpp index 2cea1b9a1a..2210a2c3ab 100644 --- a/plugins/Clist_modern/src/modern_utils.cpp +++ b/plugins/Clist_modern/src/modern_utils.cpp @@ -62,3 +62,27 @@ BOOL DestroyIcon_protect(HICON icon) if (icon) return DestroyIcon(icon); return FALSE; } + +void GetMonitorRectFromWindow(HWND hWnd, RECT *rc) +{ + POINT pt; + GetWindowRect(hWnd, rc); + pt.x = rc->left; + pt.y = rc->top; + + MONITORINFO monitorInfo; + HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always returns a valid value + monitorInfo.cbSize = sizeof(MONITORINFO); + + if (GetMonitorInfoW(hMonitor, &monitorInfo)) { + memcpy(rc, &monitorInfo.rcMonitor, sizeof(RECT)); + return; + } + + // "generic" win95/NT support, also serves as failsafe + rc->left = 0; + rc->top = 0; + rc->bottom = GetSystemMetrics(SM_CYSCREEN); + rc->right = GetSystemMetrics(SM_CXSCREEN); + +} -- cgit v1.2.3