Windows: enable window_background_opacity
This causes DWM to respect the alpha channel we set during rendering, allowing the window opacity to be respected on Windows. refs: #141
This commit is contained in:
1 parent
41b6c4a5ad
commit
2364b0a20e
1 file changed
+22
@@ -316,6 +316,7 @@ impl Window {
|
||||
};
|
||||
|
||||
enable_dark_mode(hwnd.0);
|
||||
enable_blur_behind(hwnd.0);
|
||||
|
||||
Connection::get()
|
||||
.expect("Connection::init was not called")
|
||||
@@ -558,6 +559,27 @@ unsafe fn wm_ncdestroy(
|
||||
None
|
||||
}
|
||||
|
||||
/// "Blur behind" is the old vista term for a cool blurring
|
||||
/// effect that the DWM could enable. Subsequent windows
|
||||
/// versions have removed the blurring. We use this call
|
||||
/// to tell DWM that we set proper alpha channel info as
|
||||
/// a result of rendering our window content.
|
||||
fn enable_blur_behind(hwnd: HWND) {
|
||||
use winapi::shared::minwindef::*;
|
||||
use winapi::um::dwmapi::*;
|
||||
|
||||
let bb = DWM_BLURBEHIND {
|
||||
dwFlags: DWM_BB_ENABLE,
|
||||
fEnable: TRUE,
|
||||
hRgnBlur: null_mut(),
|
||||
fTransitionOnMaximized: FALSE,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
DwmEnableBlurBehindWindow(hwnd, &bb);
|
||||
}
|
||||
}
|
||||
|
||||
fn enable_dark_mode(hwnd: HWND) {
|
||||
// Prefer to run in dark mode. This could be made configurable without
|
||||
// a huge amount of effort, but I think it's fine to just be always
|
||||
|
||||
Reference in new issue
Block a user