mirror of https://github.com/mpv-player/mpv
w32_common: remove backward compatibility code
No longer needed after 9f8b4b38c9
.
This commit is contained in:
parent
c6a8b6852c
commit
1a3e3a0c98
|
@ -508,6 +508,8 @@ if features['win32-desktop']
|
|||
cc.find_library('imm32'),
|
||||
cc.find_library('ntdll'),
|
||||
cc.find_library('ole32'),
|
||||
cc.find_library('shcore'),
|
||||
cc.find_library('user32'),
|
||||
cc.find_library('uuid'),
|
||||
cc.find_library('uxtheme'),
|
||||
cc.find_library('version')]
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <dwmapi.h>
|
||||
#include <ole2.h>
|
||||
#include <process.h>
|
||||
#include <shellscalingapi.h>
|
||||
#include <shobjidl.h>
|
||||
#include <avrt.h>
|
||||
|
||||
|
@ -55,10 +56,6 @@
|
|||
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
||||
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
|
||||
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED (0x02E0)
|
||||
#endif
|
||||
|
||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||
#endif
|
||||
|
@ -75,24 +72,12 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
|||
#define DWMWA_SYSTEMBACKDROP_TYPE 38
|
||||
#endif
|
||||
|
||||
#ifndef DPI_ENUMS_DECLARED
|
||||
typedef enum MONITOR_DPI_TYPE {
|
||||
MDT_EFFECTIVE_DPI = 0,
|
||||
MDT_ANGULAR_DPI = 1,
|
||||
MDT_RAW_DPI = 2,
|
||||
MDT_DEFAULT = MDT_EFFECTIVE_DPI
|
||||
} MONITOR_DPI_TYPE;
|
||||
#endif
|
||||
|
||||
#define rect_w(r) ((r).right - (r).left)
|
||||
#define rect_h(r) ((r).bottom - (r).top)
|
||||
|
||||
#define WM_SHOWMENU (WM_USER + 1)
|
||||
|
||||
struct w32_api {
|
||||
HRESULT (WINAPI *pGetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*);
|
||||
BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi);
|
||||
int (WINAPI *pGetSystemMetricsForDpi)(int nIndex, UINT dpi);
|
||||
BOOLEAN (WINAPI *pShouldAppsUseDarkMode)(void);
|
||||
DWORD (WINAPI *pSetPreferredAppMode)(DWORD mode);
|
||||
};
|
||||
|
@ -207,9 +192,7 @@ struct vo_w32_state {
|
|||
|
||||
static inline int get_system_metrics(struct vo_w32_state *w32, int metric)
|
||||
{
|
||||
return w32->api.pGetSystemMetricsForDpi
|
||||
? w32->api.pGetSystemMetricsForDpi(metric, w32->dpi)
|
||||
: GetSystemMetrics(metric);
|
||||
return GetSystemMetricsForDpi(metric, w32->dpi);
|
||||
}
|
||||
|
||||
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)
|
|||
if (!w32->opts->border && !IsMaximized(w32->window))
|
||||
return;
|
||||
|
||||
if (w32->api.pAdjustWindowRectExForDpi) {
|
||||
w32->api.pAdjustWindowRectExForDpi(rc,
|
||||
GetWindowLongPtrW(hwnd, GWL_STYLE), 0,
|
||||
AdjustWindowRectExForDpi(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0,
|
||||
GetWindowLongPtrW(hwnd, GWL_EXSTYLE), w32->dpi);
|
||||
} else {
|
||||
AdjustWindowRect(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0);
|
||||
}
|
||||
}
|
||||
|
||||
static bool check_windows10_build(DWORD build)
|
||||
|
@ -689,8 +667,7 @@ static void update_dpi(struct vo_w32_state *w32)
|
|||
HDC hdc = NULL;
|
||||
int dpi = 0;
|
||||
|
||||
if (w32->api.pGetDpiForMonitor && w32->api.pGetDpiForMonitor(w32->monitor,
|
||||
MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) {
|
||||
if (GetDpiForMonitor(w32->monitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) {
|
||||
dpi = (int)dpiX;
|
||||
MP_VERBOSE(w32, "DPI detected from the new API: %d\n", dpi);
|
||||
} else if ((hdc = GetDC(NULL))) {
|
||||
|
@ -1998,18 +1975,6 @@ void vo_w32_config(struct vo *vo)
|
|||
|
||||
static void w32_api_load(struct vo_w32_state *w32)
|
||||
{
|
||||
HMODULE shcore_dll = LoadLibraryW(L"shcore.dll");
|
||||
// Available since Win8.1
|
||||
w32->api.pGetDpiForMonitor = !shcore_dll ? NULL :
|
||||
(void *)GetProcAddress(shcore_dll, "GetDpiForMonitor");
|
||||
|
||||
HMODULE user32_dll = LoadLibraryW(L"user32.dll");
|
||||
// Available since Win10
|
||||
w32->api.pAdjustWindowRectExForDpi = !user32_dll ? NULL :
|
||||
(void *)GetProcAddress(user32_dll, "AdjustWindowRectExForDpi");
|
||||
w32->api.pGetSystemMetricsForDpi = !user32_dll ? NULL :
|
||||
(void *)GetProcAddress(user32_dll, "GetSystemMetricsForDpi");
|
||||
|
||||
// Dark mode related functions, available since the 1809 Windows 10 update
|
||||
// Check the Windows build version as on previous versions used ordinals
|
||||
// may point to unexpected code/data. Alternatively could check uxtheme.dll
|
||||
|
|
Loading…
Reference in New Issue