diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 30b779f2d2..ad09f6beea 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -1233,10 +1233,6 @@ impl<'a, T: 'static> InitData<'a, T> { win.set_content_protected(true); } - // Set visible before setting the size to ensure the - // attribute is correctly applied. - win.set_visible(attributes.visible); - win.set_enabled_buttons(attributes.enabled_buttons); if attributes.fullscreen.0.is_some() { @@ -1262,6 +1258,18 @@ impl<'a, T: 'static> InitData<'a, T> { } } + // Setting visible before setting the size causes black/white flickering; + // showing the decorated window directly results in an unpleasant white + // background. So here's a hack: set visible on the undecorated window, + // then apply the decorations again. The window will remain transparent + // until it gets repainted. Changes to flag `SWP_FRAMECHANGED` trigger + // `WM_NCCALCSIZE` event. + win.set_decorations(false); + win.set_undecorated_shadow(false); + win.set_visible(attributes.visible); + win.set_decorations(attributes.decorations); + win.set_undecorated_shadow(self.pl_attribs.decoration_shadow); + // let margins = MARGINS { // cxLeftWidth: 1, // cxRightWidth: 1,