mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 22:34:13 +00:00
Don't notify when drawing
This commit is contained in:
parent
26a31b41b9
commit
1e4a7e6ef1
1 changed files with 14 additions and 6 deletions
|
@ -237,6 +237,7 @@ pub struct Window {
|
||||||
bounds_observers: SubscriberSet<(), AnyObserver>,
|
bounds_observers: SubscriberSet<(), AnyObserver>,
|
||||||
active: bool,
|
active: bool,
|
||||||
pub(crate) dirty: bool,
|
pub(crate) dirty: bool,
|
||||||
|
pub(crate) drawing: bool,
|
||||||
activation_observers: SubscriberSet<(), AnyObserver>,
|
activation_observers: SubscriberSet<(), AnyObserver>,
|
||||||
pub(crate) last_blur: Option<Option<FocusId>>,
|
pub(crate) last_blur: Option<Option<FocusId>>,
|
||||||
pub(crate) focus: Option<FocusId>,
|
pub(crate) focus: Option<FocusId>,
|
||||||
|
@ -371,6 +372,7 @@ impl Window {
|
||||||
bounds_observers: SubscriberSet::new(),
|
bounds_observers: SubscriberSet::new(),
|
||||||
active: false,
|
active: false,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
|
drawing: false,
|
||||||
activation_observers: SubscriberSet::new(),
|
activation_observers: SubscriberSet::new(),
|
||||||
last_blur: None,
|
last_blur: None,
|
||||||
focus: None,
|
focus: None,
|
||||||
|
@ -422,8 +424,10 @@ impl<'a> WindowContext<'a> {
|
||||||
|
|
||||||
/// Mark the window as dirty, scheduling it to be redrawn on the next frame.
|
/// Mark the window as dirty, scheduling it to be redrawn on the next frame.
|
||||||
pub fn notify(&mut self) {
|
pub fn notify(&mut self) {
|
||||||
|
if !self.window.drawing {
|
||||||
self.window.dirty = true;
|
self.window.dirty = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Close this window.
|
/// Close this window.
|
||||||
pub fn remove_window(&mut self) {
|
pub fn remove_window(&mut self) {
|
||||||
|
@ -1237,6 +1241,8 @@ impl<'a> WindowContext<'a> {
|
||||||
/// Draw pixels to the display for this window based on the contents of its scene.
|
/// Draw pixels to the display for this window based on the contents of its scene.
|
||||||
pub(crate) fn draw(&mut self) -> Scene {
|
pub(crate) fn draw(&mut self) -> Scene {
|
||||||
let t0 = std::time::Instant::now();
|
let t0 = std::time::Instant::now();
|
||||||
|
self.window.dirty = false;
|
||||||
|
self.window.drawing = true;
|
||||||
|
|
||||||
let window_was_focused = self
|
let window_was_focused = self
|
||||||
.window
|
.window
|
||||||
|
@ -1327,7 +1333,7 @@ impl<'a> WindowContext<'a> {
|
||||||
self.platform.set_cursor_style(cursor_style);
|
self.platform.set_cursor_style(cursor_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.window.dirty = false;
|
self.window.drawing = false;
|
||||||
eprintln!("frame: {:?}", t0.elapsed());
|
eprintln!("frame: {:?}", t0.elapsed());
|
||||||
|
|
||||||
scene
|
scene
|
||||||
|
@ -2346,11 +2352,13 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify(&mut self) {
|
pub fn notify(&mut self) {
|
||||||
|
if !self.window.drawing {
|
||||||
self.window_cx.notify();
|
self.window_cx.notify();
|
||||||
self.window_cx.app.push_effect(Effect::Notify {
|
self.window_cx.app.push_effect(Effect::Notify {
|
||||||
emitter: self.view.model.entity_id,
|
emitter: self.view.model.entity_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn observe_window_bounds(
|
pub fn observe_window_bounds(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
Loading…
Reference in a new issue