Unified · Split
| @@ -78,6 +78,7 @@ typedef enum MONITOR_DPI_TYPE { · 77 unmodified lines | |||
| 78 | struct w32_api { | 78 | struct w32_api { |
| 79 | HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); | 79 | HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); |
| 80 | BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); | 80 | BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi); |
| 81 | int (WINAPI *pGetSystemMetricsForDpi)(int nIndex, UINT dpi); | ||
| 81 | BOOLEAN (WINAPI *pShouldAppsUseDarkMode)(void); | 82 | BOOLEAN (WINAPI *pShouldAppsUseDarkMode)(void); |
| 82 | DWORD (WINAPI *pSetPreferredAppMode)(DWORD mode); | 83 | DWORD (WINAPI *pSetPreferredAppMode)(DWORD mode); |
| 83 | }; | 84 | }; |
| @@ -188,6 +189,13 @@ struct vo_w32_state { · 104 unmodified lines | |||
| 188 | bool unmaximize; | 189 | bool unmaximize; |
| 189 | }; | 190 | }; |
| 190 | 191 | ||
| 192 | static inline int get_system_metrics(struct vo_w32_state *w32, int metric) | ||
| 193 | { | ||
| 194 | return w32->api.pGetSystemMetricsForDpi | ||
| 195 | ? w32->api.pGetSystemMetricsForDpi(metric, w32->dpi) | ||
| 196 | : GetSystemMetrics(metric); | ||
| 197 | } | ||
| 198 | |||
| 191 | static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) | 199 | static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) |
| 192 | { | 200 | { |
| 193 | if (!w32->opts->border) | 201 | if (!w32->opts->border) |
| @@ -231,13 +239,13 @@ static LRESULT borderless_nchittest(struct vo_w32_state *w32, int x, int y) · 37 unmodified lines | |||
| 231 | if (!GetWindowRect(w32->window, &rc)) | 239 | if (!GetWindowRect(w32->window, &rc)) |
| 232 | return HTNOWHERE; | 240 | return HTNOWHERE; |
| 233 | 241 | ||
| 234 | POINT frame = {GetSystemMetrics(SM_CXSIZEFRAME), | 242 | POINT frame = {get_system_metrics(w32, SM_CXSIZEFRAME), |
| 235 | GetSystemMetrics(SM_CYSIZEFRAME)}; | 243 | get_system_metrics(w32, SM_CYSIZEFRAME)}; |
| 236 | if (w32->opts->border) { | 244 | if (w32->opts->border) { |
| 237 | frame.x += GetSystemMetrics(SM_CXPADDEDBORDER); | 245 | frame.x += get_system_metrics(w32, SM_CXPADDEDBORDER); |
| 238 | frame.y += GetSystemMetrics(SM_CXPADDEDBORDER); | 246 | frame.y += get_system_metrics(w32, SM_CXPADDEDBORDER); |
| 239 | if (!w32->opts->title_bar) | 247 | if (!w32->opts->title_bar) |
| 240 | rc.top -= GetSystemMetrics(SM_CXPADDEDBORDER); | 248 | rc.top -= get_system_metrics(w32, SM_CXPADDEDBORDER); |
| 241 | } | 249 | } |
| 242 | InflateRect(&rc, -frame.x, -frame.y); | 250 | InflateRect(&rc, -frame.x, -frame.y); |
| 243 | 251 | ||
| @@ -760,10 +768,10 @@ static RECT get_screen_area(struct vo_w32_state *w32) · 516 unmodified lines | |||
| 760 | { | 768 | { |
| 761 | // Handle --fs-screen=all | 769 | // Handle --fs-screen=all |
| 762 | if (w32->current_fs && w32->opts->fsscreen_id == -2) { | 770 | if (w32->current_fs && w32->opts->fsscreen_id == -2) { |
| 763 | const int x = GetSystemMetrics(SM_XVIRTUALSCREEN); | 771 | const int x = get_system_metrics(w32, SM_XVIRTUALSCREEN); |
| 764 | const int y = GetSystemMetrics(SM_YVIRTUALSCREEN); | 772 | const int y = get_system_metrics(w32, SM_YVIRTUALSCREEN); |
| 765 | return (RECT) { x, y, x + GetSystemMetrics(SM_CXVIRTUALSCREEN), | 773 | return (RECT) { x, y, x + get_system_metrics(w32, SM_CXVIRTUALSCREEN), |
| 766 | y + GetSystemMetrics(SM_CYVIRTUALSCREEN) }; | 774 | y + get_system_metrics(w32, SM_CYVIRTUALSCREEN) }; |
| 767 | } | 775 | } |
| 768 | return get_monitor_info(w32).rcMonitor; | 776 | return get_monitor_info(w32).rcMonitor; |
| 769 | } | 777 | } |
| @@ -1837,6 +1845,8 @@ static void w32_api_load(struct vo_w32_state *w32) · 1067 unmodified lines | |||
| 1837 | // Available since Win10 | 1845 | // Available since Win10 |
| 1838 | w32->api.pAdjustWindowRectExForDpi = !user32_dll ? NULL : | 1846 | w32->api.pAdjustWindowRectExForDpi = !user32_dll ? NULL : |
| 1839 | (void *)GetProcAddress(user32_dll, "AdjustWindowRectExForDpi"); | 1847 | (void *)GetProcAddress(user32_dll, "AdjustWindowRectExForDpi"); |
| 1848 | w32->api.pGetSystemMetricsForDpi = !user32_dll ? NULL : | ||
| 1849 | (void *)GetProcAddress(user32_dll, "GetSystemMetricsForDpi"); | ||
| 1840 | 1850 | ||
| 1841 | // Dark mode related functions, available since the 1809 Windows 10 update | 1851 | // Dark mode related functions, available since the 1809 Windows 10 update |
| 1842 | // Check the Windows build version as on previous versions used ordinals | 1852 | // Check the Windows build version as on previous versions used ordinals |