Skip to content

Commit

Permalink
Don't set the background color when initializing with transparency (#…
Browse files Browse the repository at this point in the history
…3657)

Setting the background color changes how the window title bar appears,
which is something that the application should customize itself if it
wants this behaviour (and also, it wasn't set when calling
`set_transparent`, so the behaviour wasn't consistent).
  • Loading branch information
madsmtm committed Apr 27, 2024
1 parent 0fc8c37 commit 94664ff
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Expand Up @@ -137,7 +137,6 @@ features = [
"NSApplication",
"NSBitmapImageRep",
"NSButton",
"NSColor",
"NSControl",
"NSCursor",
"NSDragging",
Expand Down
1 change: 1 addition & 0 deletions src/changelog/unreleased.md
Expand Up @@ -260,3 +260,4 @@ changelog entry.
- On Wayland, fix decoration glitch on close with some compositors.
- On Android, fix a regression introduced in #2748 to allow volume key events to be received again.
- On Windows, don't return a valid window handle outside of the GUI thread.
- On macOS, don't set the background color when initializing a window with transparency.
3 changes: 1 addition & 2 deletions src/platform_impl/macos/window_delegate.rs
Expand Up @@ -12,7 +12,7 @@ use objc2::{
};
use objc2_app_kit::{
NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSApplication,
NSApplicationPresentationOptions, NSBackingStoreType, NSColor, NSDraggingDestination,
NSApplicationPresentationOptions, NSBackingStoreType, NSDraggingDestination,
NSFilenamesPboardType, NSPasteboard, NSRequestUserAttentionType, NSScreen, NSView,
NSWindowButton, NSWindowDelegate, NSWindowFullScreenButton, NSWindowLevel,
NSWindowOcclusionState, NSWindowOrderingMode, NSWindowSharingType, NSWindowStyleMask,
Expand Down Expand Up @@ -605,7 +605,6 @@ fn new_window(attrs: &WindowAttributes, mtm: MainThreadMarker) -> Option<Id<Wini

if attrs.transparent {
window.setOpaque(false);
window.setBackgroundColor(Some(unsafe { &NSColor::clearColor() }));
}

// register for drag and drop operations.
Expand Down
2 changes: 2 additions & 0 deletions src/window.rs
Expand Up @@ -941,6 +941,8 @@ impl Window {
///
/// ## Platform-specific
///
/// - **macOS:** If you're not drawing to the window yourself, you might have to set the
/// background color of the window to enable transparency.
/// - **Web / iOS / Android:** Unsupported.
/// - **X11:** Can only be set while building the window, with
/// [`WindowAttributes::with_transparent`].
Expand Down

0 comments on commit 94664ff

Please sign in to comment.