update workspace

This commit is contained in:
2026-09-12 13:35:10 +07:00
parent 40deb9db66
commit 651ffec22d
4 changed files with 38 additions and 103 deletions
Generated
+1 -51
View File
@@ -3561,7 +3561,6 @@ 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",
@@ -3745,20 +3744,6 @@ dependencies = [
"syn 2.0.119", "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]] [[package]]
name = "gpui_apple" name = "gpui_apple"
version = "0.1.0" version = "0.1.0"
@@ -4096,16 +4081,6 @@ 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"
@@ -6035,16 +6010,6 @@ 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"
@@ -8526,20 +8491,6 @@ 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"
@@ -10907,7 +10858,6 @@ dependencies = [
"gpui", "gpui",
"gpui-base", "gpui-base",
"gpui-component", "gpui-component",
"gpui-fps",
"log", "log",
"nostr", "nostr",
"paths", "paths",
@@ -11333,7 +11283,7 @@ dependencies = [
"rand 0.8.8", "rand 0.8.8",
"screencapturekit", "screencapturekit",
"screencapturekit-sys", "screencapturekit-sys",
"sysinfo 0.31.4", "sysinfo",
"tao-core-video-sys", "tao-core-video-sys",
"windows 0.61.3", "windows 0.61.3",
"windows-capture", "windows-capture",
-1
View File
@@ -18,7 +18,6 @@ reqwest_client = { git = "https://github.com/zed-industries/zed" }
# GPUI Kit # GPUI Kit
gpui-component = { git = "https://github.com/longbridge/gpui-component", rev = "39c2c86dbee7ad445591462f8675f74082e10828", features = ["tree-sitter-languages"], } 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-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" } dock = { path = "crates/dock" }
settings = { path = "crates/settings" } settings = { path = "crates/settings" }
-1
View File
@@ -18,7 +18,6 @@ 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
+32 -45
View File
@@ -1,28 +1,22 @@
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, KeyBinding, Render, Subscription, Window, actions, div, px}; use gpui::{Context, Entity, Render, Subscription, Window, div, px};
use gpui_component::{Root, StyledExt, Theme}; use gpui_component::{Root, StyledExt, Theme};
use gpui_fps::{FpsMonitor, FpsOverlay}; use settings::{AppearanceMode, SettingsStore};
use signed_state::{Backend, BackendEvent}; use signed_state::{Backend, BackendEvent};
use crate::views::SidebarPanel; use crate::views::SidebarPanel;
use crate::views::sidebar::passphrase_dialog; use crate::views::sidebar::passphrase_dialog;
actions!(workspace, [ToggleMonitor]);
pub struct Workspace { pub struct Workspace {
dock: Entity<DockArea>, dock: Entity<DockArea>,
fps: Entity<FpsMonitor>,
/// Debug HUD, toggled with `cmd-shift-f`.
show_fps: bool,
_subscriptions: Vec<Subscription>, _subscriptions: Vec<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)); let backend = Backend::global(cx);
cx.bind_keys([KeyBinding::new("cmd-shift-f", ToggleMonitor, None)]); let settings = SettingsStore::global(cx);
let dock = cx.new(|cx| { let dock = cx.new(|cx| {
let skin = SignedDockSkin::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 sidebar = cx.new(|cx| SidebarPanel::new(weak_dock.clone(), cx));
let weak_sidebar = sidebar.downgrade(); 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![]; 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. // 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( subscriptions.push(cx.subscribe_in(
&dock, &dock,
window, window,
@@ -54,9 +44,9 @@ impl Workspace {
if !matches!(event, DockEvent::LayoutChanged) { if !matches!(event, DockEvent::LayoutChanged) {
return; return;
} }
let dock = dock_for_pruning.clone(); let weak = weak_dock.clone();
cx.spawn_in(window, async move |_, window| { 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] { for placement in [DockPlacement::Bottom, DockPlacement::Right] {
if area.is_empty(placement, cx) { if area.is_empty(placement, cx) {
area.remove_dock(placement, window, 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. // Ask for the passphrase when the stored identity is NIP-49 encrypted.
let passphrase_subscription = subscriptions.push(cx.subscribe_in(
window.subscribe(&backend, cx, |_backend, event, window, cx| { &backend,
window,
|_this, _state, event, window, cx| {
if matches!(event, BackendEvent::PassphraseRequired) { if matches!(event, BackendEvent::PassphraseRequired) {
passphrase_dialog::open(window, cx); passphrase_dialog::open(window, cx);
} }
}); },
));
cx.defer_in(window, move |this, window, cx| {
// The event may have fired before this window existed. // The event may have fired before this window existed.
// Fall back to the backend state in that case. // Fall back to the backend state in that case.
if backend.read(cx).passphrase_required() { if backend.read(cx).passphrase_required() {
passphrase_dialog::open(window, cx); passphrase_dialog::open(window, cx);
} }
// Open the explore panel after the sidebar has been initialized. // Open the sidebar and explore panel.
cx.defer_in(window, move |_, window, cx| { 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);
});
// Open the explore panel.
weak_sidebar weak_sidebar
.update(cx, |this, cx| { .update(cx, |this, cx| {
this.open_explore(window, cx); this.open_explore(window, cx);
@@ -100,10 +98,7 @@ impl Workspace {
Self { Self {
dock, dock,
show_fps: cfg!(debug_assertions),
fps,
_subscriptions: subscriptions, _subscriptions: subscriptions,
_passphrase_subscription: passphrase_subscription,
} }
} }
} }
@@ -115,12 +110,6 @@ impl Render for Workspace {
div() div()
.id("workspace") .id("workspace")
.on_action(
cx.listener(|this: &mut Self, _ev: &ToggleMonitor, _window, cx| {
this.show_fps = !this.show_fps;
cx.notify();
}),
)
.v_flex() .v_flex()
.size_full() .size_full()
.relative() .relative()
@@ -129,7 +118,5 @@ impl Render for Workspace {
.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)))
} }
} }