w32_common: add function to control window transparency state

Use the DWM API to enable and disable compositor transparency.
This commit is contained in:
nanahi 2024-01-02 16:24:41 -05:00 committed by Dudemanguy
parent 965119a2b7
commit cef378b0a3
2 changed files with 22 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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 */