add fps monitor

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