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('imm32'),
|
||||||
cc.find_library('ntdll'),
|
cc.find_library('ntdll'),
|
||||||
cc.find_library('ole32'),
|
cc.find_library('ole32'),
|
||||||
|
cc.find_library('shcore'),
|
||||||
|
cc.find_library('user32'),
|
||||||
cc.find_library('uuid'),
|
cc.find_library('uuid'),
|
||||||
cc.find_library('uxtheme'),
|
cc.find_library('uxtheme'),
|
||||||
cc.find_library('version')]
|
cc.find_library('version')]
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
#include <ole2.h>
|
#include <ole2.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
#include <shellscalingapi.h>
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
#include <avrt.h>
|
#include <avrt.h>
|
||||||
|
|
||||||
|
@ -55,10 +56,6 @@
|
||||||
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
||||||
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
|
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
|
||||||
|
|
||||||
#ifndef WM_DPICHANGED
|
|
||||||
#define WM_DPICHANGED (0x02E0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,24 +72,12 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
||||||
#define DWMWA_SYSTEMBACKDROP_TYPE 38
|
#define DWMWA_SYSTEMBACKDROP_TYPE 38
|
||||||
#endif
|
#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_w(r) ((r).right - (r).left)
|
||||||
#define rect_h(r) ((r).bottom - (r).top)
|
#define rect_h(r) ((r).bottom - (r).top)
|
||||||
|
|
||||||
#define WM_SHOWMENU (WM_USER + 1)
|
#define WM_SHOWMENU (WM_USER + 1)
|
||||||
|
|
||||||
struct w32_api {
|
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);
|
BOOLEAN (WINAPI *pShouldAppsUseDarkMode)(void);
|
||||||
DWORD (WINAPI *pSetPreferredAppMode)(DWORD mode);
|
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)
|
static inline int get_system_metrics(struct vo_w32_state *w32, int metric)
|
||||||
{
|
{
|
||||||
return w32->api.pGetSystemMetricsForDpi
|
return GetSystemMetricsForDpi(metric, w32->dpi);
|
||||||
? w32->api.pGetSystemMetricsForDpi(metric, w32->dpi)
|
|
||||||
: GetSystemMetrics(metric);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc)
|
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))
|
if (!w32->opts->border && !IsMaximized(w32->window))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (w32->api.pAdjustWindowRectExForDpi) {
|
AdjustWindowRectExForDpi(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0,
|
||||||
w32->api.pAdjustWindowRectExForDpi(rc,
|
|
||||||
GetWindowLongPtrW(hwnd, GWL_STYLE), 0,
|
|
||||||
GetWindowLongPtrW(hwnd, GWL_EXSTYLE), w32->dpi);
|
GetWindowLongPtrW(hwnd, GWL_EXSTYLE), w32->dpi);
|
||||||
} else {
|
|
||||||
AdjustWindowRect(rc, GetWindowLongPtrW(hwnd, GWL_STYLE), 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_windows10_build(DWORD build)
|
static bool check_windows10_build(DWORD build)
|
||||||
|
@ -689,8 +667,7 @@ static void update_dpi(struct vo_w32_state *w32)
|
||||||
HDC hdc = NULL;
|
HDC hdc = NULL;
|
||||||
int dpi = 0;
|
int dpi = 0;
|
||||||
|
|
||||||
if (w32->api.pGetDpiForMonitor && w32->api.pGetDpiForMonitor(w32->monitor,
|
if (GetDpiForMonitor(w32->monitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) {
|
||||||
MDT_EFFECTIVE_DPI, &dpiX, &dpiY) == S_OK) {
|
|
||||||
dpi = (int)dpiX;
|
dpi = (int)dpiX;
|
||||||
MP_VERBOSE(w32, "DPI detected from the new API: %d\n", dpi);
|
MP_VERBOSE(w32, "DPI detected from the new API: %d\n", dpi);
|
||||||
} else if ((hdc = GetDC(NULL))) {
|
} 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)
|
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
|
// Dark mode related functions, available since the 1809 Windows 10 update
|
||||||
// Check the Windows build version as on previous versions used ordinals
|
// Check the Windows build version as on previous versions used ordinals
|
||||||
// may point to unexpected code/data. Alternatively could check uxtheme.dll
|
// may point to unexpected code/data. Alternatively could check uxtheme.dll
|
||||||
|
|
Loading…
Reference in New Issue