From cef378b0a3a18aea04fd1dd2b3762525e15a1878 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Tue, 2 Jan 2024 16:24:41 -0500 Subject: [PATCH] w32_common: add function to control window transparency state Use the DWM API to enable and disable compositor transparency. --- video/out/w32_common.c | 21 +++++++++++++++++++++ video/out/w32_common.h | 1 + 2 files changed, 22 insertions(+) diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 683ee747aa..4f2e6f0e1e 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -2245,3 +2245,24 @@ void vo_w32_run_on_thread(struct vo *vo, void (*cb)(void *ctx), void *ctx) struct vo_w32_state *w32 = vo->w32; mp_dispatch_run(w32->dispatch, cb, ctx); } + +void vo_w32_set_transparency(struct vo *vo, bool enable) +{ + struct vo_w32_state *w32 = vo->w32; + if (w32->parent) + return; + + DWM_BLURBEHIND dbb = {0}; + if (enable) { + HRGN rgn = CreateRectRgn(0, 0, -1, -1); + dbb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; + dbb.hRgnBlur = rgn; + dbb.fEnable = TRUE; + DwmEnableBlurBehindWindow(w32->window, &dbb); + DeleteObject(rgn); + } else { + dbb.dwFlags = DWM_BB_ENABLE; + dbb.fEnable = FALSE; + DwmEnableBlurBehindWindow(w32->window, &dbb); + } +} diff --git a/video/out/w32_common.h b/video/out/w32_common.h index 528b21662c..bc22a2d3e0 100644 --- a/video/out/w32_common.h +++ b/video/out/w32_common.h @@ -32,5 +32,6 @@ int vo_w32_control(struct vo *vo, int *events, int request, void *arg); void vo_w32_config(struct vo *vo); HWND vo_w32_hwnd(struct vo *vo); void vo_w32_run_on_thread(struct vo *vo, void (*cb)(void *ctx), void *ctx); +void vo_w32_set_transparency(struct vo *vo, bool enable); #endif /* MPLAYER_W32_COMMON_H */