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
|
@ -67,6 +67,9 @@ pub(crate) trait Platform: 'static {
|
|||
options: WindowOptions,
|
||||
) -> Box<dyn PlatformWindow>;
|
||||
|
||||
/// Returns the appearance of the application's windows.
|
||||
fn window_appearance(&self) -> WindowAppearance;
|
||||
|
||||
fn set_display_link_output_callback(
|
||||
&self,
|
||||
display_id: DisplayId,
|
||||
|
@ -559,29 +562,30 @@ pub enum WindowBounds {
|
|||
Fixed(Bounds<GlobalPixels>),
|
||||
}
|
||||
|
||||
/// The appearance of the window, as defined by the operating system
|
||||
/// On macOS, this corresponds to named [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearance)
|
||||
/// values
|
||||
/// The appearance of the window, as defined by the operating system.
|
||||
///
|
||||
/// On macOS, this corresponds to named [`NSAppearance`](https://developer.apple.com/documentation/appkit/nsappearance)
|
||||
/// values.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum WindowAppearance {
|
||||
/// A light appearance
|
||||
/// A light appearance.
|
||||
///
|
||||
/// on macOS, this corresponds to the `aqua` appearance
|
||||
/// On macOS, this corresponds to the `aqua` appearance.
|
||||
Light,
|
||||
|
||||
/// A light appearance with vibrant colors
|
||||
/// A light appearance with vibrant colors.
|
||||
///
|
||||
/// on macOS, this corresponds to the `NSAppearanceNameVibrantLight` appearance
|
||||
/// On macOS, this corresponds to the `NSAppearanceNameVibrantLight` appearance.
|
||||
VibrantLight,
|
||||
|
||||
/// A dark appearance
|
||||
/// A dark appearance.
|
||||
///
|
||||
/// on macOS, this corresponds to the `darkAqua` appearance
|
||||
/// On macOS, this corresponds to the `darkAqua` appearance.
|
||||
Dark,
|
||||
|
||||
/// A dark appearance with vibrant colors
|
||||
/// A dark appearance with vibrant colors.
|
||||
///
|
||||
/// on macOS, this corresponds to the `NSAppearanceNameVibrantDark` appearance
|
||||
/// On macOS, this corresponds to the `NSAppearanceNameVibrantDark` appearance.
|
||||
VibrantDark,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue