Merge pull request #95009 from bruvzg/win_transp_checks

[Windows] Check if transparency is enabled in the project setting before applying DWM blur.
This commit is contained in:
Rémi Verschelde 2024-08-06 12:30:56 +02:00
commit 2b65ff9249
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -1333,6 +1333,7 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod
wd.is_popup = true;
}
if (p_flags & WINDOW_FLAG_TRANSPARENT_BIT) {
if (OS::get_singleton()->is_layered_allowed()) {
DWM_BLURBEHIND bb;
ZeroMemory(&bb, sizeof(bb));
HRGN hRgn = CreateRectRgn(0, 0, -1, -1);
@ -1340,6 +1341,7 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod
bb.hRgnBlur = hRgn;
bb.fEnable = TRUE;
DwmEnableBlurBehindWindow(wd.hWnd, &bb);
}
wd.layered_window = true;
}
@ -2119,8 +2121,8 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
} break;
case WINDOW_FLAG_TRANSPARENT: {
if (p_enabled) {
//enable per-pixel alpha
// Enable per-pixel alpha.
if (OS::get_singleton()->is_layered_allowed()) {
DWM_BLURBEHIND bb;
ZeroMemory(&bb, sizeof(bb));
HRGN hRgn = CreateRectRgn(0, 0, -1, -1);
@ -2128,12 +2130,12 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
bb.hRgnBlur = hRgn;
bb.fEnable = TRUE;
DwmEnableBlurBehindWindow(wd.hWnd, &bb);
}
wd.layered_window = true;
} else {
//disable per-pixel alpha
// Disable per-pixel alpha.
wd.layered_window = false;
if (OS::get_singleton()->is_layered_allowed()) {
DWM_BLURBEHIND bb;
ZeroMemory(&bb, sizeof(bb));
HRGN hRgn = CreateRectRgn(0, 0, -1, -1);
@ -2142,6 +2144,7 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W
bb.fEnable = FALSE;
DwmEnableBlurBehindWindow(wd.hWnd, &bb);
}
}
} break;
case WINDOW_FLAG_NO_FOCUS: {
wd.no_focus = p_enabled;