diff --git a/Cargo.lock b/Cargo.lock index 9d23ca2..7dc6af9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3561,7 +3561,6 @@ dependencies = [ "gpui_macros", "gpui_shared_string", "gpui_util", - "hdrhistogram", "heapless 0.9.3", "http_client", "image", @@ -3745,20 +3744,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "gpui-fps" -version = "0.1.0" -source = "git+https://github.com/longbridge/gpui-component?rev=39c2c86dbee7ad445591462f8675f74082e10828#39c2c86dbee7ad445591462f8675f74082e10828" -dependencies = [ - "gpui", - "instant", - "libc", - "objc2-core-foundation", - "objc2-io-kit", - "sysinfo 0.37.2", - "windows 0.58.0", -] - [[package]] name = "gpui_apple" version = "0.1.0" @@ -4096,16 +4081,6 @@ dependencies = [ "foldhash 0.2.0", ] -[[package]] -name = "hdrhistogram" -version = "7.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49d1053f4708f0af3cf9fc5bffc7e68a914a3c45becb231c80068c9c3f78bea" -dependencies = [ - "byteorder", - "num-traits", -] - [[package]] name = "heapless" version = "0.8.0" @@ -6035,16 +6010,6 @@ dependencies = [ "objc2-core-foundation", ] -[[package]] -name = "objc2-io-kit" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" -dependencies = [ - "libc", - "objc2-core-foundation", -] - [[package]] name = "objc2-io-surface" version = "0.3.2" @@ -8526,20 +8491,6 @@ dependencies = [ "windows 0.57.0", ] -[[package]] -name = "sysinfo" -version = "0.37.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" -dependencies = [ - "libc", - "memchr", - "ntapi", - "objc2-core-foundation", - "objc2-io-kit", - "windows 0.61.3", -] - [[package]] name = "system-configuration" version = "0.6.1" @@ -10907,7 +10858,6 @@ dependencies = [ "gpui", "gpui-base", "gpui-component", - "gpui-fps", "log", "nostr", "paths", @@ -11333,7 +11283,7 @@ dependencies = [ "rand 0.8.8", "screencapturekit", "screencapturekit-sys", - "sysinfo 0.31.4", + "sysinfo", "tao-core-video-sys", "windows 0.61.3", "windows-capture", diff --git a/Cargo.toml b/Cargo.toml index 2327cfc..359ca4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ reqwest_client = { git = "https://github.com/zed-industries/zed" } # GPUI Kit gpui-component = { git = "https://github.com/longbridge/gpui-component", rev = "39c2c86dbee7ad445591462f8675f74082e10828", features = ["tree-sitter-languages"], } gpui-base = { git = "https://github.com/longbridge/gpui-component", rev = "39c2c86dbee7ad445591462f8675f74082e10828" } -gpui-fps = { git = "https://github.com/longbridge/gpui-component", rev = "39c2c86dbee7ad445591462f8675f74082e10828" } dock = { path = "crates/dock" } settings = { path = "crates/settings" } diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index 59d09f5..f093cde 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -18,7 +18,6 @@ utils = { path = "../utils" } gpui.workspace = true gpui-component.workspace = true gpui-base.workspace = true -gpui-fps.workspace = true gix.workspace = true nostr.workspace = true diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 05df0c0..6a0e209 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1,28 +1,22 @@ use dock::{DockArea, DockEvent, DockLayout, DockPlacement, SignedDockSkin, panel_handle}; use gpui::prelude::*; -use gpui::{Context, Entity, KeyBinding, Render, Subscription, Window, actions, div, px}; +use gpui::{Context, Entity, Render, Subscription, Window, div, px}; use gpui_component::{Root, StyledExt, Theme}; -use gpui_fps::{FpsMonitor, FpsOverlay}; +use settings::{AppearanceMode, SettingsStore}; use signed_state::{Backend, BackendEvent}; use crate::views::SidebarPanel; use crate::views::sidebar::passphrase_dialog; -actions!(workspace, [ToggleMonitor]); - pub struct Workspace { dock: Entity, - fps: Entity, - /// Debug HUD, toggled with `cmd-shift-f`. - show_fps: bool, _subscriptions: Vec, - _passphrase_subscription: Subscription, } impl Workspace { pub fn new(window: &mut Window, cx: &mut Context) -> Self { - let fps = cx.new(|cx| FpsMonitor::new(window, cx).continuous(false)); - cx.bind_keys([KeyBinding::new("cmd-shift-f", ToggleMonitor, None)]); + let backend = Backend::global(cx); + let settings = SettingsStore::global(cx); let dock = cx.new(|cx| { let skin = SignedDockSkin::new(cx); @@ -33,20 +27,16 @@ impl Workspace { let sidebar = cx.new(|cx| SidebarPanel::new(weak_dock.clone(), cx)); let weak_sidebar = sidebar.downgrade(); - dock.update(cx, |dock_area, cx| { - dock_area.set_dock( - DockPlacement::Left, - DockLayout::tabs().panel_view(panel_handle(sidebar), cx), - window, - cx, - ); - dock_area.set_dock_size(DockPlacement::Left, px(240.), window, cx); - }); - let mut subscriptions = vec![]; + // Sync the system appearance if the appearance mode is set to system. + if settings.read(cx).settings().appearance == AppearanceMode::System { + subscriptions.push(cx.observe_window_appearance(window, |_this, window, cx| { + Theme::sync_system_appearance(Some(window), cx); + })); + } + // A bottom or right dock whose last panel was dragged away is removed entirely. - let dock_for_pruning = dock.clone(); subscriptions.push(cx.subscribe_in( &dock, window, @@ -54,9 +44,9 @@ impl Workspace { if !matches!(event, DockEvent::LayoutChanged) { return; } - let dock = dock_for_pruning.clone(); + let weak = weak_dock.clone(); cx.spawn_in(window, async move |_, window| { - dock.update_in(window, |area, window, cx| { + weak.update_in(window, |area, window, cx| { for placement in [DockPlacement::Bottom, DockPlacement::Right] { if area.is_empty(placement, cx) { area.remove_dock(placement, window, cx); @@ -69,28 +59,36 @@ impl Workspace { }, )); - subscriptions.push(cx.observe_window_appearance(window, |_this, window, cx| { - Theme::sync_system_appearance(Some(window), cx); - })); - - let backend = Backend::global(cx); - // Ask for the passphrase when the stored identity is NIP-49 encrypted. - let passphrase_subscription = - window.subscribe(&backend, cx, |_backend, event, window, cx| { + subscriptions.push(cx.subscribe_in( + &backend, + window, + |_this, _state, event, window, cx| { if matches!(event, BackendEvent::PassphraseRequired) { passphrase_dialog::open(window, cx); } + }, + )); + + cx.defer_in(window, move |this, window, cx| { + // The event may have fired before this window existed. + // Fall back to the backend state in that case. + if backend.read(cx).passphrase_required() { + passphrase_dialog::open(window, cx); + } + + // Open the sidebar and explore panel. + this.dock.update(cx, |dock_area, cx| { + dock_area.set_dock( + DockPlacement::Left, + DockLayout::tabs().panel_view(panel_handle(sidebar), cx), + window, + cx, + ); + dock_area.set_dock_size(DockPlacement::Left, px(240.), window, cx); }); - // The event may have fired before this window existed. - // Fall back to the backend state in that case. - if backend.read(cx).passphrase_required() { - passphrase_dialog::open(window, cx); - } - - // Open the explore panel after the sidebar has been initialized. - cx.defer_in(window, move |_, window, cx| { + // Open the explore panel. weak_sidebar .update(cx, |this, cx| { this.open_explore(window, cx); @@ -100,10 +98,7 @@ impl Workspace { Self { dock, - show_fps: cfg!(debug_assertions), - fps, _subscriptions: subscriptions, - _passphrase_subscription: passphrase_subscription, } } } @@ -115,12 +110,6 @@ impl Render for Workspace { div() .id("workspace") - .on_action( - cx.listener(|this: &mut Self, _ev: &ToggleMonitor, _window, cx| { - this.show_fps = !this.show_fps; - cx.notify(); - }), - ) .v_flex() .size_full() .relative() @@ -129,7 +118,5 @@ impl Render for Workspace { .children(notification_layer) // Modals .children(dialog_layer) - // On top of everything, so it stays readable while debugging. - .when(self.show_fps, |this| this.child(FpsOverlay::new(&self.fps))) } }