Reduce the frequency writing window size and position information to the database (#10315)
Release Notes: - N/A
This commit is contained in:
parent
081e9b9a60
commit
3648d79ddb
1 changed files with 40 additions and 26 deletions
|
@ -571,6 +571,7 @@ pub struct Workspace {
|
||||||
_schedule_serialize: Option<Task<()>>,
|
_schedule_serialize: Option<Task<()>>,
|
||||||
pane_history_timestamp: Arc<AtomicUsize>,
|
pane_history_timestamp: Arc<AtomicUsize>,
|
||||||
bounds: Bounds<Pixels>,
|
bounds: Bounds<Pixels>,
|
||||||
|
bounds_save_task_queued: Option<Task<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventEmitter<Event> for Workspace {}
|
impl EventEmitter<Event> for Workspace {}
|
||||||
|
@ -737,7 +738,15 @@ impl Workspace {
|
||||||
|
|
||||||
let subscriptions = vec![
|
let subscriptions = vec![
|
||||||
cx.observe_window_activation(Self::on_window_activation_changed),
|
cx.observe_window_activation(Self::on_window_activation_changed),
|
||||||
cx.observe_window_bounds(move |_, cx| {
|
cx.observe_window_bounds(move |this, cx| {
|
||||||
|
if this.bounds_save_task_queued.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.bounds_save_task_queued = Some(cx.spawn(|this, mut cx| async move {
|
||||||
|
cx.background_executor()
|
||||||
|
.timer(Duration::from_millis(100))
|
||||||
|
.await;
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
if let Some(display) = cx.display() {
|
if let Some(display) = cx.display() {
|
||||||
let window_bounds = cx.window_bounds();
|
let window_bounds = cx.window_bounds();
|
||||||
let fullscreen = cx.is_fullscreen();
|
let fullscreen = cx.is_fullscreen();
|
||||||
|
@ -764,6 +773,10 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.bounds_save_task_queued.take();
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}),
|
}),
|
||||||
cx.observe_window_appearance(|_, cx| {
|
cx.observe_window_appearance(|_, cx| {
|
||||||
|
@ -830,6 +843,7 @@ impl Workspace {
|
||||||
workspace_actions: Default::default(),
|
workspace_actions: Default::default(),
|
||||||
// This data will be incorrect, but it will be overwritten by the time it needs to be used.
|
// This data will be incorrect, but it will be overwritten by the time it needs to be used.
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
|
bounds_save_task_queued: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue