Initialize the SystemAppearance
using the app's global window appearance (#7508)
This PR changes our approach to initializing the `SystemAppearance` so that we can do it earlier in the startup process. Previously we were using the appearance from the window, meaning that we couldn't initialize the value until we first opened the window. Now we read the `window_appearance` from the `AppContext`. On macOS this is backed by the [`effectiveAppearance`](https://developer.apple.com/documentation/appkit/nsapplication/2967171-effectiveappearance) on the `NSApplication`. We currently still watch for changes to the appearance at the window level, as the only hook I could find in the documentation is [`viewDidChangeEffectiveAppearance`](https://developer.apple.com/documentation/appkit/nsview/2977088-viewdidchangeeffectiveappearance), which is at the `NSView` level. In my testing this makes it so Zed appropriately chooses the correct light/dark theme on startup. Release Notes: - N/A
This commit is contained in:
parent
b59e110c59
commit
c322179bb9
9 changed files with 46 additions and 28 deletions
|
@ -5,7 +5,7 @@ use futures::StreamExt;
|
|||
use gpui::{prelude::*, AppContext, WindowHandle};
|
||||
use settings::Settings;
|
||||
use std::sync::{Arc, Weak};
|
||||
use theme::{SystemAppearance, ThemeSettings};
|
||||
use theme::ThemeSettings;
|
||||
use ui::{prelude::*, Button, Label};
|
||||
use util::ResultExt;
|
||||
use workspace::AppState;
|
||||
|
@ -35,8 +35,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
|||
let options = notification_window_options(screen, window_size);
|
||||
let window = cx
|
||||
.open_window(options, |cx| {
|
||||
SystemAppearance::init_for_window(cx);
|
||||
|
||||
cx.new_view(|_| {
|
||||
IncomingCallNotification::new(
|
||||
incoming_call.clone(),
|
||||
|
|
|
@ -6,7 +6,7 @@ use collections::HashMap;
|
|||
use gpui::{AppContext, Size};
|
||||
use settings::Settings;
|
||||
use std::sync::{Arc, Weak};
|
||||
use theme::{SystemAppearance, ThemeSettings};
|
||||
use theme::ThemeSettings;
|
||||
use ui::{prelude::*, Button, Label};
|
||||
use workspace::AppState;
|
||||
|
||||
|
@ -28,8 +28,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
|||
for screen in cx.displays() {
|
||||
let options = notification_window_options(screen, window_size);
|
||||
let window = cx.open_window(options, |cx| {
|
||||
SystemAppearance::init_for_window(cx);
|
||||
|
||||
cx.new_view(|_| {
|
||||
ProjectSharedNotification::new(
|
||||
owner.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue