Skip to content

Commit 3969a1a

Browse files
fix(macos): Fix color mappings in window.rs (#1138)
Co-authored-by: FabianLars <github@fabianlars.de>
1 parent ff015b4 commit 3969a1a

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

.changes/fix-macos-bg-color.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tao: patch
3+
---
4+
5+
On macOS, fixed an issue that caused the window background color to be applied incorrectly (typically black).

examples/timer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright 2021-2023 Tauri Programme within The Commons Conservancy
33
// SPDX-License-Identifier: Apache-2.0
44

5-
use std::time::Duration;
6-
use std::time::Instant;
5+
use std::time::{Duration, Instant};
76

87
use tao::{
98
event::{Event, StartCause, WindowEvent},

src/event_loop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
//! [create_proxy]: crate::event_loop::EventLoop::create_proxy
1414
//! [event_loop_proxy]: crate::event_loop::EventLoopProxy
1515
//! [send_event]: crate::event_loop::EventLoopProxy::send_event
16-
use std::time::Instant;
17-
use std::{error, fmt, marker::PhantomData, ops::Deref};
16+
use std::{error, fmt, marker::PhantomData, ops::Deref, time::Instant};
1817

1918
use crate::{
2019
dpi::PhysicalPosition,

src/platform_impl/android/ndk_glue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub static PACKAGE: OnceCell<&str> = OnceCell::new();
4747
/// - `private external fun focus(focus: Boolean)`
4848
/// 4. a one time setup function that will be ran once after tao has created its event loop in the `create` function above.
4949
/// 5. the main entry point of your android application.
50+
#[rustfmt::skip]
5051
#[macro_export]
5152
macro_rules! android_binding {
5253
($domain:ident, $package:ident, $activity:ident, $setup:path, $main:ident) => {

src/platform_impl/macos/window.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,12 @@ impl UnownedWindow {
550550
let color = win_attribs
551551
.background_color
552552
.map(|(r, g, b, a)| {
553-
NSColor::colorWithRed_green_blue_alpha(r as f64, g as f64, b as f64, a as f64 / 255.0)
553+
NSColor::colorWithRed_green_blue_alpha(
554+
r as f64 / 255.0,
555+
g as f64 / 255.0,
556+
b as f64 / 255.0,
557+
a as f64 / 255.0,
558+
)
554559
})
555560
.unwrap_or_else(|| NSColor::clearColor());
556561
ns_window.setBackgroundColor(Some(&color));
@@ -906,9 +911,9 @@ impl UnownedWindow {
906911
let color = color
907912
.map(|(r, g, b, a)| {
908913
Some(NSColor::colorWithRed_green_blue_alpha(
909-
r as f64,
910-
g as f64,
911-
b as f64,
914+
r as f64 / 255.0,
915+
g as f64 / 255.0,
916+
b as f64 / 255.0,
912917
a as f64 / 255.0,
913918
))
914919
})

0 commit comments

Comments
 (0)