fix: window controls not visible on macos when on light theme in dark mode
This commit is contained in:
@@ -29,18 +29,22 @@ unsafe fn set_transparent_titlebar(id: cocoa::base::id) {
|
||||
|
||||
id.setTitlebarAppearsTransparent_(cocoa::base::YES);
|
||||
id.setTitleVisibility_(cocoa::appkit::NSWindowTitleVisibility::NSWindowTitleHidden);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn set_window_controls_pos(window: cocoa::base::id, x: f64, y: f64) {
|
||||
use cocoa::{appkit::{NSWindow, NSWindowButton, NSView}, foundation::NSRect};
|
||||
use cocoa::{
|
||||
appkit::{NSAppearance, NSAppearanceNameVibrantLight, NSView, NSWindow, NSWindowButton},
|
||||
foundation::NSRect,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
// Set appearance windows to be light for better visibility when on light theme
|
||||
// TODO: Detect when on dark theme and set to dark and on light switch to light
|
||||
NSWindow::setAppearance(window, NSAppearance(NSAppearanceNameVibrantLight));
|
||||
|
||||
let close = window.standardWindowButton_(NSWindowButton::NSWindowCloseButton);
|
||||
let miniaturize =
|
||||
window.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton);
|
||||
let miniaturize = window.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton);
|
||||
let zoom = window.standardWindowButton_(NSWindowButton::NSWindowZoomButton);
|
||||
|
||||
let title_bar_container_view = close.superview().superview();
|
||||
@@ -303,9 +307,7 @@ pub fn setup_mac_window(app: &mut App) {
|
||||
// }
|
||||
|
||||
// Are we deallocing this properly ? (I miss safe Rust :( )
|
||||
let app_state = HoppAppState {
|
||||
window,
|
||||
};
|
||||
let app_state = HoppAppState { window };
|
||||
let app_box = Box::into_raw(Box::new(app_state)) as *mut c_void;
|
||||
|
||||
ns_win.setDelegate_(delegate!("MainWindowDelegate", {
|
||||
@@ -339,7 +341,5 @@ pub fn setup_mac_window(app: &mut App) {
|
||||
}))
|
||||
}
|
||||
|
||||
app.get_window("main")
|
||||
.unwrap()
|
||||
.set_transparent_titlebar();
|
||||
app.get_window("main").unwrap().set_transparent_titlebar();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user