From 57bf771f9a00eadd0c9510855ef8ef1269e407e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sat, 4 Mar 2023 14:51:23 +0000 Subject: [PATCH] Transparent window on macos (#7617) # Objective - Example `transparent_window` doesn't display a transparent window on macOS - Fixes #6330 ## Solution - Set the `composite_alpha_mode` of the window to the correct value - Update docs --- crates/bevy_window/src/window.rs | 4 +++- examples/window/transparent_window.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/bevy_window/src/window.rs b/crates/bevy_window/src/window.rs index 51f5562635..e41415a0e8 100644 --- a/crates/bevy_window/src/window.rs +++ b/crates/bevy_window/src/window.rs @@ -130,7 +130,9 @@ pub struct Window { /// ## Platform-specific /// - iOS / Android / Web: Unsupported. /// - macOS X: Not working as expected. - /// macOS X transparent works with winit out of the box, so this issue might be related to: + /// + /// macOS X transparent works with winit out of the box, so this issue might be related to: . + /// You should also set the window `composite_alpha_mode` to `CompositeAlphaMode::PostMultiplied`. pub transparent: bool, /// Should the window start focused? pub focused: bool, diff --git a/examples/window/transparent_window.rs b/examples/window/transparent_window.rs index b0cec2e563..8bd34d008b 100644 --- a/examples/window/transparent_window.rs +++ b/examples/window/transparent_window.rs @@ -4,6 +4,8 @@ //! [documentation](https://docs.rs/bevy/latest/bevy/prelude/struct.WindowDescriptor.html#structfield.transparent) //! for more details. +#[cfg(target_os = "macos")] +use bevy::window::CompositeAlphaMode; use bevy::{ prelude::*, window::{Window, WindowPlugin}, @@ -20,6 +22,8 @@ fn main() { transparent: true, // Disabling window decorations to make it feel more like a widget than a window decorations: false, + #[cfg(target_os = "macos")] + composite_alpha_mode: CompositeAlphaMode::PostMultiplied, ..default() }), ..default()