From 047c67baf31cf9bcdc6f0275037bb3b56f2bd268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=88=E3=81=A1=E3=82=87?= Date: Fri, 22 Jun 2018 10:33:29 +0900 Subject: [PATCH] windows feature WS_EX_NOREDIRECTIONBITMAP (#575) * set WS_EX_NOREDIRECTIONBITMAP * add CHANGELOG.md * more flexibility. * Skip DwmEnableBlurBehindWindow if no_redirection_bitmap is enabled. --- CHANGELOG.md | 1 + src/os/windows.rs | 9 +++++++++ src/platform/windows/mod.rs | 1 + src/platform/windows/window.rs | 5 ++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6bca654..19104a52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +- Windows additionally has `WindowBuilderExt::with_no_redirection_bitmap`. - **Breaking:** Removed `VirtualKeyCode::LMenu` and `VirtualKeyCode::RMenu`; Windows now generates `VirtualKeyCode::LAlt` and `VirtualKeyCode::RAlt` instead. - On X11, exiting fullscreen no longer leaves the window in the monitor's top left corner. - **Breaking:** `Window::hidpi_factor` has been renamed to `Window::get_hidpi_factor` for better consistency. `WindowEvent::HiDPIFactorChanged` has been renamed to `WindowEvent::HiDpiFactorChanged`. DPI factors are always represented as `f64` instead of `f32` now. diff --git a/src/os/windows.rs b/src/os/windows.rs index d9f427b2..62b16c7a 100644 --- a/src/os/windows.rs +++ b/src/os/windows.rs @@ -55,6 +55,9 @@ pub trait WindowBuilderExt { /// This sets `ICON_BIG`. A good ceiling here is 256x256. fn with_taskbar_icon(self, taskbar_icon: Option) -> WindowBuilder; + + /// This sets `WS_EX_NOREDIRECTIONBITMAP`. + fn with_no_redirection_bitmap(self, flag: bool) -> WindowBuilder; } impl WindowBuilderExt for WindowBuilder { @@ -69,6 +72,12 @@ impl WindowBuilderExt for WindowBuilder { self.platform_specific.taskbar_icon = taskbar_icon; self } + + #[inline] + fn with_no_redirection_bitmap(mut self, flag: bool) -> WindowBuilder { + self.platform_specific.no_redirection_bitmap = flag; + self + } } /// Additional methods on `MonitorId` that are specific to Windows. diff --git a/src/platform/windows/mod.rs b/src/platform/windows/mod.rs index 69c96d68..bd16c743 100644 --- a/src/platform/windows/mod.rs +++ b/src/platform/windows/mod.rs @@ -11,6 +11,7 @@ pub use self::window::Window; pub struct PlatformSpecificWindowBuilderAttributes { pub parent: Option, pub taskbar_icon: Option<::Icon>, + pub no_redirection_bitmap: bool, } unsafe impl Send for PlatformSpecificWindowBuilderAttributes {} diff --git a/src/platform/windows/window.rs b/src/platform/windows/window.rs index 385fbe6d..8dedc2ff 100644 --- a/src/platform/windows/window.rs +++ b/src/platform/windows/window.rs @@ -888,6 +888,9 @@ unsafe fn init( if attributes.always_on_top { ex_style |= winuser::WS_EX_TOPMOST; } + if pl_attribs.no_redirection_bitmap { + ex_style |= winuser::WS_EX_NOREDIRECTIONBITMAP; + } // adjusting the window coordinates using the style winuser::AdjustWindowRectEx(&mut rect, style, 0, ex_style); @@ -999,7 +1002,7 @@ unsafe fn init( }; // making the window transparent - if attributes.transparent { + if attributes.transparent && !pl_attribs.no_redirection_bitmap { let bb = dwmapi::DWM_BLURBEHIND { dwFlags: 0x1, // FIXME: DWM_BB_ENABLE; fEnable: 1,