Don't set the background color when initializing with transparency (#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).
This commit is contained in:
Mads Marquart 2024-04-27 15:41:14 +02:00 committed by GitHub
parent 0fc8c37721
commit 94664ff687
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 3 deletions

View file

@ -137,7 +137,6 @@ features = [
"NSApplication", "NSApplication",
"NSBitmapImageRep", "NSBitmapImageRep",
"NSButton", "NSButton",
"NSColor",
"NSControl", "NSControl",
"NSCursor", "NSCursor",
"NSDragging", "NSDragging",

View file

@ -260,3 +260,4 @@ changelog entry.
- On Wayland, fix decoration glitch on close with some compositors. - 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 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 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.

View file

@ -12,7 +12,7 @@ use objc2::{
}; };
use objc2_app_kit::{ use objc2_app_kit::{
NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSApplication, NSAppKitVersionNumber, NSAppKitVersionNumber10_12, NSAppearance, NSApplication,
NSApplicationPresentationOptions, NSBackingStoreType, NSColor, NSDraggingDestination, NSApplicationPresentationOptions, NSBackingStoreType, NSDraggingDestination,
NSFilenamesPboardType, NSPasteboard, NSRequestUserAttentionType, NSScreen, NSView, NSFilenamesPboardType, NSPasteboard, NSRequestUserAttentionType, NSScreen, NSView,
NSWindowButton, NSWindowDelegate, NSWindowFullScreenButton, NSWindowLevel, NSWindowButton, NSWindowDelegate, NSWindowFullScreenButton, NSWindowLevel,
NSWindowOcclusionState, NSWindowOrderingMode, NSWindowSharingType, NSWindowStyleMask, NSWindowOcclusionState, NSWindowOrderingMode, NSWindowSharingType, NSWindowStyleMask,
@ -605,7 +605,6 @@ fn new_window(attrs: &WindowAttributes, mtm: MainThreadMarker) -> Option<Id<Wini
if attrs.transparent { if attrs.transparent {
window.setOpaque(false); window.setOpaque(false);
window.setBackgroundColor(Some(unsafe { &NSColor::clearColor() }));
} }
// register for drag and drop operations. // register for drag and drop operations.

View file

@ -941,6 +941,8 @@ impl Window {
/// ///
/// ## Platform-specific /// ## 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. /// - **Web / iOS / Android:** Unsupported.
/// - **X11:** Can only be set while building the window, with /// - **X11:** Can only be set while building the window, with
/// [`WindowAttributes::with_transparent`]. /// [`WindowAttributes::with_transparent`].