History

w32_common: remove backward compatibility code

No longer needed after 9f8b4b38c97f0697fbc3a9b30e4e856337cd6dcf.

Kacper Michajłow committed 2 years ago

Commit 1a3e3a01 parent c6a8b682 files · +7 −40Browse files

Unified · Split

2 files
  1. meson.build +2 −0
  2. video/out/w32_common.c +5 −40
meson.build+2−0
@@ -508,6 +508,8 @@ if features['win32-desktop'] · 507 unmodified lines
508508 cc.find_library('imm32'),
509509 cc.find_library('ntdll'),
510510 cc.find_library('ole32'),
511+ cc.find_library('shcore'),
512+ cc.find_library('user32'),
511513 cc.find_library('uuid'),
512514 cc.find_library('uxtheme'),
513515 cc.find_library('version')]
video/out/w32_common.c+5−40
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include <dwmapi.h>
2727 #include <ole2.h>
2828 #include <process.h>
29+#include <shellscalingapi.h>
2930 #include <shobjidl.h>
3031 #include <avrt.h>
3132
@@ -55,10 +56,6 @@ · 23 unmodified lines
5556 EXTERN_C IMAGE_DOS_HEADER __ImageBase;
5657 #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
5758
58−#ifndef WM_DPICHANGED
59−#define WM_DPICHANGED (0x02E0)
60−#endif
61−
6259 #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
6360 #define DWMWA_USE_IMMERSIVE_DARK_MODE 20
6461 #endif
@@ -75,24 +72,12 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase; · 10 unmodified lines
7572 #define DWMWA_SYSTEMBACKDROP_TYPE 38
7673 #endif
7774
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−
8775 #define rect_w(r) ((r).right - (r).left)
8876 #define rect_h(r) ((r).bottom - (r).top)
8977
9078 #define WM_SHOWMENU (WM_USER + 1)
9179
9280 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);
9681 BOOLEAN (WINAPI *pShouldAppsUseDarkMode)(void);
9782 DWORD (WINAPI *pSetPreferredAppMode)(DWORD mode);
9883 };
@@ -207,9 +192,7 @@ struct vo_w32_state { · 108 unmodified lines
207192
208193 static inline int get_system_metrics(struct vo_w32_state *w32, int metric)
209194 {
210− return w32->api.pGetSystemMetricsForDpi
211− ? w32->api.pGetSystemMetricsForDpi(metric, w32->dpi)
212− : GetSystemMetrics(metric);
195+ return GetSystemMetricsForDpi(metric, w32->dpi);
213196 }
214197
215198 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
217200 if (!w32->opts->border && !IsMaximized(w32->window))
218201 return;
219202
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);
227205 }
228206
229207 static bool check_windows10_build(DWORD build)
@@ -689,8 +667,7 @@ static void update_dpi(struct vo_w32_state *w32) · 459 unmodified lines
689667 HDC hdc = NULL;
690668 int dpi = 0;
691669
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) {
694671 dpi = (int)dpiX;
695672 MP_VERBOSE(w32, "DPI detected from the new API: %d\n", dpi);
696673 } else if ((hdc = GetDC(NULL))) {
@@ -1998,18 +1975,6 @@ void vo_w32_config(struct vo *vo) · 1301 unmodified lines
19981975
19991976 static void w32_api_load(struct vo_w32_state *w32)
20001977 {
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−
20131978 // Dark mode related functions, available since the 1809 Windows 10 update
20141979 // Check the Windows build version as on previous versions used ordinals
20151980 // may point to unexpected code/data. Alternatively could check uxtheme.dll

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t