summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-01-02 16:24:41 -0500
committerDudemanguy <random342@airmail.cc>2024-02-17 16:06:33 +0000
commitcef378b0a3a18aea04fd1dd2b3762525e15a1878 (patch)
treedd2d3aaf3ae41f18e7e631d2b967efd37cf85acb
parent965119a2b7c1bb4769f5027dd645b9926847de20 (diff)
downloadmpv-cef378b0a3a18aea04fd1dd2b3762525e15a1878.tar.bz2
mpv-cef378b0a3a18aea04fd1dd2b3762525e15a1878.tar.xz
w32_common: add function to control window transparency state
Use the DWM API to enable and disable compositor transparency.
-rw-r--r--video/out/w32_common.c21
-rw-r--r--video/out/w32_common.h1
2 files changed, 22 insertions, 0 deletions
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 */