No longer needed after 9f8b4b38c97f0697fbc3a9b30e4e856337cd6dcf.
Unified · Split
| @@ -508,6 +508,8 @@ if features['win32-desktop'] · 507 unmodified lines | ||
| 508 | 508 | cc.find_library('imm32'), |
| 509 | 509 | cc.find_library('ntdll'), |
| 510 | 510 | cc.find_library('ole32'), |
| 511 | + cc.find_library('shcore'), | |
| 512 | + cc.find_library('user32'), | |
| 511 | 513 | cc.find_library('uuid'), |
| 512 | 514 | cc.find_library('uxtheme'), |
| 513 | 515 | cc.find_library('version')] |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <dwmapi.h> |
| 27 | 27 | #include <ole2.h> |
| 28 | 28 | #include <process.h> |
| 29 | +#include <shellscalingapi.h> | |
| 29 | 30 | #include <shobjidl.h> |
| 30 | 31 | #include <avrt.h> |
| 31 | 32 | |
| @@ -55,10 +56,6 @@ · 23 unmodified lines | ||
| 55 | 56 | EXTERN_C IMAGE_DOS_HEADER __ImageBase; |
| 56 | 57 | #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase) |
| 57 | 58 | |
| 58 | −#ifndef WM_DPICHANGED | |
| 59 | −#define WM_DPICHANGED (0x02E0) | |
| 60 | −#endif | |
| 61 | − | |
| 62 | 59 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE |
| 63 | 60 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 |
| 64 | 61 | #endif |
| @@ -75,24 +72,12 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase; · 10 unmodified lines | ||
| 75 | 72 | #define DWMWA_SYSTEMBACKDROP_TYPE 38 |
| 76 | 73 | #endif |
| 77 | 74 | |
| 78 | −#ifndef DPI_ENUMS_DECLARED | |
| 79 | −typedef enum MONITOR_DPI_TYPE { | |
| 80 | − MDT_EFFECTIVE_DPI = 0, | |
| 81 | − MDT_ANGULAR_DPI = 1, | |
| 82 | − MDT_RAW_DPI = 2, | |
| 83 | − MDT_DEFAULT = MDT_EFFECTIVE_DPI | |
| 84 | −} MONITOR_DPI_TYPE; | |
| 85 | −#endif | |
| 86 | − | |
| 87 | 75 | #define rect_w(r) ((r).right - (r).left) |
| 88 | 76 | #define rect_h(r) ((r).bottom - (r).top) |
| 89 | 77 | |
| 90 | 78 | #define WM_SHOWMENU (WM_USER + 1) |
| 91 | 79 | |
| 92 | 80 | struct w32_api { |
| 93 | − HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); | |
| 94 | − BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); | |
| 95 | − int (WINAPI *pGetSystemMetricsForDpi)(int nIndex, UINT dpi); | |
| 96 | 81 | BOOLEAN (WINAPI *pShouldAppsUseDarkMode)(void); |
| 97 | 82 | DWORD (WINAPI *pSetPreferredAppMode)(DWORD mode); |
| 98 | 83 | }; |
| @@ -207,9 +192,7 @@ struct vo_w32_state { · 108 unmodified lines | ||
| 207 | 192 | |
| 208 | 193 | static inline int get_system_metrics(struct vo_w32_state *w32, int metric) |
| 209 | 194 | { |
| 210 | − return w32->api.pGetSystemMetricsForDpi | |
| 211 | − ? w32->api.pGetSystemMetricsForDpi(metric, w32->dpi) | |
| 212 | − : GetSystemMetrics(metric); | |
| 195 | + return GetSystemMetricsForDpi(metric, w32->dpi); | |
| 213 | 196 | } |
| 214 | 197 | |
| 215 | 198 | static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) |
| @@ -217,13 +200,8 @@ static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) · 1 unmodified line | ||
| 217 | 200 | if (!w32->opts->border && !IsMaximized(w32->window)) |
| 218 | 201 | return; |
| 219 | 202 | |
| 220 | − if (w32->api.pAdjustWindowRectExForDpi) { | |
| 221 | − w32->api.pAdjustWindowRectExForDpi(rc, | |
| 222 | − GetWindowLongPtrW(hwnd, GWL_STYLE), 0, | |
| 223 | − GetWindowLongPtrW(hwnd, GWL_EXSTYLE), w32->dpi); | |
| 224 | − } else { | |
| 225 | − AdjustWindowRect(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0); | |
| 226 | − } | |
| 203 | + AdjustWindowRectExForDpi(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0, | |
| 204 | + GetWindowLongPtrW(hwnd, GWL_EXSTYLE), w32->dpi); | |
| 227 | 205 | } |
| 228 | 206 | |
| 229 | 207 | static bool check_windows10_build(DWORD build) |
| @@ -689,8 +667,7 @@ static void update_dpi(struct vo_w32_state *w32) · 459 unmodified lines | ||
| 689 | 667 | HDC hdc = NULL; |
| 690 | 668 | int dpi = 0; |
| 691 | 669 | |
| 692 | − if (w32->api.pGetDpiForMonitor && w32->api.pGetDpiForMonitor(w32->monitor, | |
| 693 | − MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) { | |
| 670 | + if (GetDpiForMonitor(w32->monitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) { | |
| 694 | 671 | dpi = (int)dpiX; |
| 695 | 672 | MP_VERBOSE(w32, "DPI detected from the new API: %d\n", dpi); |
| 696 | 673 | } else if ((hdc = GetDC(NULL))) { |
| @@ -1998,18 +1975,6 @@ void vo_w32_config(struct vo *vo) · 1301 unmodified lines | ||
| 1998 | 1975 | |
| 1999 | 1976 | static void w32_api_load(struct vo_w32_state *w32) |
| 2000 | 1977 | { |
| 2001 | − HMODULE shcore_dll = LoadLibraryW(L"shcore.dll"); | |
| 2002 | − // Available since Win8.1 | |
| 2003 | − w32->api.pGetDpiForMonitor = !shcore_dll ? NULL : | |
| 2004 | − (void *)GetProcAddress(shcore_dll, "GetDpiForMonitor"); | |
| 2005 | − | |
| 2006 | − HMODULE user32_dll = LoadLibraryW(L"user32.dll"); | |
| 2007 | − // Available since Win10 | |
| 2008 | − w32->api.pAdjustWindowRectExForDpi = !user32_dll ? NULL : | |
| 2009 | − (void *)GetProcAddress(user32_dll, "AdjustWindowRectExForDpi"); | |
| 2010 | − w32->api.pGetSystemMetricsForDpi = !user32_dll ? NULL : | |
| 2011 | − (void *)GetProcAddress(user32_dll, "GetSystemMetricsForDpi"); | |
| 2012 | − | |
| 2013 | 1978 | // Dark mode related functions, available since the 1809 Windows 10 update |
| 2014 | 1979 | // Check the Windows build version as on previous versions used ordinals |
| 2015 | 1980 | // may point to unexpected code/data. Alternatively could check uxtheme.dll |