Skip to content

Commit

Permalink
Transparent window on macos (bevyengine#7617)
Browse files Browse the repository at this point in the history
# Objective

- Example `transparent_window` doesn't display a transparent window on macOS
- Fixes bevyengine#6330

## Solution

- Set the `composite_alpha_mode` of the window to the correct value
- Update docs
  • Loading branch information
mockersf authored and Shfty committed Mar 19, 2023
1 parent e95f275 commit 50544d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://github.com/gfx-rs/wgpu/issues/687>
///
/// macOS X transparent works with winit out of the box, so this issue might be related to: <https://github.com/gfx-rs/wgpu/issues/687>.
/// You should also set the window `composite_alpha_mode` to `CompositeAlphaMode::PostMultiplied`.
pub transparent: bool,
/// Should the window start focused?
pub focused: bool,
Expand Down
4 changes: 4 additions & 0 deletions examples/window/transparent_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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()
Expand Down

0 comments on commit 50544d6

Please sign in to comment.