diff --git a/Cargo.lock b/Cargo.lock index 8b25f79..d574fe3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1238,7 +1238,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "gpui_util", "indexmap", @@ -1704,7 +1704,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "proc-macro2", "quote", @@ -2637,15 +2637,14 @@ dependencies = [ [[package]] name = "gix-command" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d96b8e8423ce2665232bda1b682a62541f07ab801ffad69a034ef962bed3244" +checksum = "aa00adbd2c77f584cfe41f348772d2f131af1fa519a7f6b98638f1144ead96a4" dependencies = [ "bstr", "gix-path", "gix-quote", "gix-trace", - "shell-words", ] [[package]] @@ -2763,9 +2762,9 @@ dependencies = [ [[package]] name = "gix-error" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73b2794a6a746953c24d4ed51e4d408b83d8d599ed4e5c39a47736d75687cf0" +checksum = "4a1ba536602db507119eb5f3cdf80bef3ca5a5ec0dfc6e9c7f46dc70ade7c112" dependencies = [ "bstr", ] @@ -3036,9 +3035,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b075e730586bba7341304d6fc1b4efc1d10cf64532622521c0e07f30e661046" +checksum = "38fc6f029ea67de83cbcbd33fd98c05a48360d2932b39d9fdacbc6eae802d475" dependencies = [ "bstr", "gix-trace", @@ -3240,9 +3239,9 @@ checksum = "be3eb81d9dc914335923e50d52829c551feefd6a72d176c4130c546b67a60814" [[package]] name = "gix-transport" -version = "0.59.1" +version = "0.59.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1295b6ada647b5b4ac6eb123d95a82ee80aef11a7d9db6ea9cb38dcbd411362" +checksum = "b3f41a64939953ff49117df4eb91334d299abc59ff57a90fb2193d8ffa5886f1" dependencies = [ "base64", "bstr", @@ -3485,7 +3484,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.2.2" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "accesskit", "anyhow", @@ -3507,6 +3506,7 @@ dependencies = [ "gpui_macros", "gpui_shared_string", "gpui_util", + "hdrhistogram", "heapless 0.9.3", "http_client", "image", @@ -3556,7 +3556,7 @@ dependencies = [ [[package]] name = "gpui-base" version = "0.5.2" -source = "git+https://github.com/longbridge/gpui-component#c5ade4889153094b23bf438ada7e58a23c0a96e6" +source = "git+https://github.com/longbridge/gpui-component#5cb094628d27acbd557a1c22fd830417a702f0e5" dependencies = [ "aho-corasick", "anyhow", @@ -3592,7 +3592,7 @@ dependencies = [ [[package]] name = "gpui-component" version = "0.5.2" -source = "git+https://github.com/longbridge/gpui-component#c5ade4889153094b23bf438ada7e58a23c0a96e6" +source = "git+https://github.com/longbridge/gpui-component#5cb094628d27acbd557a1c22fd830417a702f0e5" dependencies = [ "anyhow", "chrono", @@ -3669,7 +3669,7 @@ dependencies = [ [[package]] name = "gpui-component-assets" version = "0.5.1" -source = "git+https://github.com/longbridge/gpui-component#c5ade4889153094b23bf438ada7e58a23c0a96e6" +source = "git+https://github.com/longbridge/gpui-component#5cb094628d27acbd557a1c22fd830417a702f0e5" dependencies = [ "anyhow", "gpui", @@ -3683,17 +3683,31 @@ dependencies = [ [[package]] name = "gpui-component-macros" version = "0.5.1" -source = "git+https://github.com/longbridge/gpui-component#c5ade4889153094b23bf438ada7e58a23c0a96e6" +source = "git+https://github.com/longbridge/gpui-component#5cb094628d27acbd557a1c22fd830417a702f0e5" dependencies = [ "proc-macro2", "quote", "syn 2.0.119", ] +[[package]] +name = "gpui-fps" +version = "0.1.0" +source = "git+https://github.com/longbridge/gpui-component#5cb094628d27acbd557a1c22fd830417a702f0e5" +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" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "block", @@ -3716,7 +3730,7 @@ dependencies = [ [[package]] name = "gpui_linux" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "accesskit", "accesskit_unix", @@ -3762,7 +3776,7 @@ dependencies = [ [[package]] name = "gpui_macos" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "accesskit", "accesskit_macos", @@ -3808,7 +3822,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3819,7 +3833,7 @@ dependencies = [ [[package]] name = "gpui_platform" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "console_error_panic_hook", "gpui", @@ -3832,7 +3846,7 @@ dependencies = [ [[package]] name = "gpui_shared_string" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "schemars", "serde", @@ -3842,7 +3856,7 @@ dependencies = [ [[package]] name = "gpui_util" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "log", @@ -3852,7 +3866,7 @@ dependencies = [ [[package]] name = "gpui_web" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "console_error_panic_hook", @@ -3876,7 +3890,7 @@ dependencies = [ [[package]] name = "gpui_wgpu" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "bytemuck", @@ -3902,7 +3916,7 @@ dependencies = [ [[package]] name = "gpui_windows" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "accesskit", "accesskit_windows", @@ -4027,6 +4041,16 @@ 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" @@ -4206,7 +4230,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "async-compression", @@ -4226,7 +4250,7 @@ dependencies = [ [[package]] name = "http_client_tls" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "log", "rustls", @@ -5182,7 +5206,7 @@ dependencies = [ [[package]] name = "media" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "bindgen", @@ -5929,6 +5953,16 @@ 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" @@ -6230,7 +6264,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "perf" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "collections", "serde", @@ -7018,7 +7052,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "derive_refineable", ] @@ -7101,7 +7135,7 @@ dependencies = [ [[package]] name = "reqwest_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "bytes", @@ -7479,7 +7513,7 @@ dependencies = [ [[package]] name = "scheduler" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "async-task", "backtrace", @@ -7834,12 +7868,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shell-words" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77" - [[package]] name = "shellexpand" version = "3.1.2" @@ -8199,7 +8227,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "heapless 0.9.3", "log", @@ -8416,6 +8444,20 @@ 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" @@ -9583,7 +9625,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "util_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "perf", "quote", @@ -10783,6 +10825,7 @@ dependencies = [ "gpui", "gpui-base", "gpui-component", + "gpui-fps", "log", "nostr", "paths", @@ -11208,7 +11251,7 @@ dependencies = [ "rand 0.8.8", "screencapturekit", "screencapturekit-sys", - "sysinfo", + "sysinfo 0.31.4", "tao-core-video-sys", "windows 0.61.3", "windows-capture", @@ -11350,7 +11393,7 @@ checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12" [[package]] name = "zlog" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "anyhow", "chrono", @@ -11367,7 +11410,7 @@ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" [[package]] name = "ztracing" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" dependencies = [ "tracing", "tracing-subscriber", @@ -11378,7 +11421,7 @@ dependencies = [ [[package]] name = "ztracing_macro" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746" +source = "git+https://github.com/zed-industries/zed#f8c278352fcc4289de66db79b599c98c1a57d351" [[package]] name = "zune-core" diff --git a/Cargo.toml b/Cargo.toml index efb0416..a13c8ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ reqwest_client = { git = "https://github.com/zed-industries/zed" } # code preview (fenced code blocks are highlighted with tree-sitter). gpui-component = { git = "https://github.com/longbridge/gpui-component", features = ["tree-sitter-languages"] } gpui-base = { git = "https://github.com/longbridge/gpui-component" } +gpui-fps = { git = "https://github.com/longbridge/gpui-component" } dock = { path = "crates/dock" } settings = { path = "crates/settings" } diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index 7866cbb..f5a2fc3 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -18,6 +18,7 @@ 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 fb7e872..78ec7e1 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1,23 +1,32 @@ use dock::{DockArea, DockEvent, DockLayout, DockPlacement, SignedDockSkin, panel_handle}; use gpui::prelude::*; -use gpui::{Context, Entity, Render, Subscription, Window, div, px}; +use gpui::{Context, Entity, KeyBinding, Render, Subscription, Window, actions, div, px}; use gpui_component::{Root, StyledExt, Theme}; +use gpui_fps::{FpsMonitor, FpsOverlay}; use signed_state::{Backend, BackendEvent}; use signed_ui::image_cache::{MAX_IMAGES, image_cache}; use crate::views::SidebarPanel; use crate::views::sidebar::passphrase_dialog; +actions!(workspace, [ToggleFps]); + /// Root view of the app: dock area (whose center tab bar doubles as the /// window title bar), overlays. pub struct Workspace { dock: Entity, + /// Debug HUD, toggled with `cmd-alt-f`. + show_fps: bool, + fps: Entity, _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-alt-f", ToggleFps, None)]); + let dock = cx.new(|cx| { let skin = SignedDockSkin::new(cx); DockArea::new("dock", Some(1), window, cx).with_renderer(skin) @@ -37,8 +46,6 @@ impl Workspace { dock_area.set_dock_size(DockPlacement::Left, px(240.), window, cx); }); - let backend = Backend::global(cx); - let mut subscriptions = vec![]; // A bottom/right dock whose last panel was dragged away is removed @@ -72,6 +79,8 @@ impl Workspace { Theme::sync_system_appearance(Some(window), cx); })); + let backend = Backend::global(cx); + // Ask for the passphrase when the stored identity is NIP-49 // encrypted. Subscribed via the window, since opening a dialog // needs one. @@ -100,6 +109,8 @@ impl Workspace { Self { dock, + show_fps: cfg!(debug_assertions), + fps, _subscriptions: subscriptions, _passphrase_subscription: passphrase_subscription, } @@ -116,10 +127,17 @@ impl Render for Workspace { .id("workspace") .v_flex() .size_full() + .relative() + .on_action(cx.listener(|this: &mut Self, _: &ToggleFps, _, cx| { + this.show_fps = !this.show_fps; + cx.notify(); + })) .child(self.dock.clone()) // Notifications .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))) } }