From f19ada7b583e9bf78de38d228a956c365b5c417b Mon Sep 17 00:00:00 2001 From: DeadSix Date: Fri, 22 Sep 2023 15:35:39 +0200 Subject: win32: add option to change backdrop style --- DOCS/man/options.rst | 10 ++++++++++ options/options.c | 15 ++++++++++++--- options/options.h | 1 + video/out/w32_common.c | 17 +++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 8ffa5b3c34..681494a604 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -7110,6 +7110,16 @@ Miscellaneous This is a key/value list option. See `List Options`_ for details. +``--backdrop-type=`` + (Windows only) + Controls the backdrop/border style. + + :auto: Default Windows behavior + :none: The backdrop will be black or white depending on the system's theme settings. + :mica: Enables the Mica style, which is the default on Windows 11. + :acrylic: Enables the Acrylic style (frosted glass look). + :mica-alt: Same as Mica, except reversed. + ``--window-affinity=`` (Windows only) Controls the window affinity behavior of mpv. diff --git a/options/options.c b/options/options.c index 507b4b6067..e16a3a8d7d 100644 --- a/options/options.c +++ b/options/options.c @@ -190,14 +190,23 @@ static const m_option_t mp_vo_opt_list[] = { {"photo", 1}, {"video", 2}, {"game", 3})}, #endif #if HAVE_WIN32_DESKTOP - {"window-affinity", OPT_CHOICE(window_affinity, {"default", WDA_NONE}, - {"excludefromcapture", WDA_EXCLUDEFROMCAPTURE}, {"monitor", WDA_MONITOR})}, - {"vo-mmcss-profile", OPT_STRING(mmcss_profile)}, // For old MinGW-w64 compatibility #define DWMWCP_DEFAULT 0 #define DWMWCP_DONOTROUND 1 #define DWMWCP_ROUND 2 #define DWMWCP_ROUNDSMALL 3 + +#define DWMSBT_AUTO 0 +#define DWMSBT_NONE 1 +#define DWMSBT_MAINWINDOW 2 +#define DWMSBT_TRANSIENTWINDOW 3 +#define DWMSBT_TABBEDWINDOW 4 + + {"backdrop-type", OPT_CHOICE(backdrop_type, {"auto", DWMSBT_AUTO}, {"none", DWMSBT_NONE}, + {"mica", DWMSBT_MAINWINDOW}, {"acrylic", DWMSBT_TRANSIENTWINDOW}, {"mica-alt", DWMSBT_TABBEDWINDOW})}, + {"window-affinity", OPT_CHOICE(window_affinity, {"default", WDA_NONE}, + {"excludefromcapture", WDA_EXCLUDEFROMCAPTURE}, {"monitor", WDA_MONITOR})}, + {"vo-mmcss-profile", OPT_STRING(mmcss_profile)}, {"window-corners", OPT_CHOICE(window_corners, {"default", DWMWCP_DEFAULT}, {"donotround", DWMWCP_DONOTROUND}, diff --git a/options/options.h b/options/options.h index 58c15b9f74..1453620c96 100644 --- a/options/options.h +++ b/options/options.h @@ -64,6 +64,7 @@ typedef struct mp_vo_opts { bool force_render; bool force_window_position; + int backdrop_type; int window_affinity; char *mmcss_profile; int window_corners; diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 9664b4b980..0eafbcc4ae 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -58,7 +58,10 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase; #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif + +//Older MinGW compatibility #define DWMWA_WINDOW_CORNER_PREFERENCE 33 +#define DWMWA_SYSTEMBACKDROP_TYPE 38 #ifndef DPI_ENUMS_DECLARED typedef enum MONITOR_DPI_TYPE { @@ -1096,6 +1099,16 @@ static void update_dark_mode(const struct vo_w32_state *w32) &use_dark_mode, sizeof(use_dark_mode)); } +static void update_backdrop(const struct vo_w32_state *w32) +{ + if (w32->parent) + return; + + int backdropType = w32->opts->backdrop_type; + DwmSetWindowAttribute(w32->window, DWMWA_SYSTEMBACKDROP_TYPE, + &backdropType, sizeof(backdropType)); +} + static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -1674,6 +1687,8 @@ static void *gui_thread(void *ptr) update_corners_pref(w32); if (w32->opts->window_affinity) update_affinity(w32); + if (w32->opts->backdrop_type) + update_backdrop(w32); if (SUCCEEDED(OleInitialize(NULL))) { ole_ok = true; @@ -1852,6 +1867,8 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) update_affinity(w32); } else if (changed_option == &vo_opts->ontop) { update_window_state(w32); + } else if (changed_option == &vo_opts->backdrop_type) { + update_backdrop(w32); } else if (changed_option == &vo_opts->border || changed_option == &vo_opts->title_bar) { -- cgit v1.2.3