Skip to content

Commit

Permalink
unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 24, 2024
1 parent 4dbdd00 commit b59ce5d
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,18 +868,26 @@ impl UnownedWindow {

#[inline]
pub fn set_background_color(&self, color: Option<crate::window::RGBA>) {
let color = color
.map(|(r, g, b, a)| {
NSColor::colorWithRed_green_blue_alpha_(nil, r as f64, g as f64, b as f64, a as f64 / 255.0)
})
.unwrap_or_else(|| {
if self.transparent {
NSColor::clearColor(nil)
} else {
nil
}
});
self.ns_window.setBackgroundColor_(color);
unsafe {
let color = color
.map(|(r, g, b, a)| {
NSColor::colorWithRed_green_blue_alpha_(
nil,
r as f64,
g as f64,
b as f64,
a as f64 / 255.0,
)
})
.unwrap_or_else(|| {
if self.transparent {
NSColor::clearColor(nil)
} else {
nil
}
});
self.ns_window.setBackgroundColor_(color);
}
}

#[inline]
Expand Down

0 comments on commit b59ce5d

Please sign in to comment.