diff --git a/crates/story/src/list_story.rs b/crates/story/src/list_story.rs index 5f91baf1..58a20ebf 100644 --- a/crates/story/src/list_story.rs +++ b/crates/story/src/list_story.rs @@ -1,4 +1,3 @@ -use core::time; use std::time::Duration; use fake::Fake; @@ -306,22 +305,19 @@ impl ListStory { // Spawn a background to random refresh the list cx.spawn(move |this, mut cx| async move { - loop { - Timer::after(time::Duration::from_secs_f64(0.5)).await; - this.update(&mut cx, |this, cx| { - this.company_list.update(cx, |picker, _| { - picker - .delegate_mut() - .companies - .iter_mut() - .for_each(|company| { - company.random_update(); - }); - }); - cx.notify(); - }) - .ok(); - } + this.update(&mut cx, |this, cx| { + this.company_list.update(cx, |picker, _| { + picker + .delegate_mut() + .companies + .iter_mut() + .for_each(|company| { + company.random_update(); + }); + }); + cx.notify(); + }) + .ok(); }) .detach(); diff --git a/crates/ui/src/dock/dock.rs b/crates/ui/src/dock/dock.rs index b1c668e6..7f01502c 100644 --- a/crates/ui/src/dock/dock.rs +++ b/crates/ui/src/dock/dock.rs @@ -3,10 +3,10 @@ use std::sync::Arc; use gpui::{ - div, prelude::FluentBuilder as _, px, AnyView, App, AppContext, Axis, Context, Element, Empty, - Entity, InteractiveElement as _, IntoElement, MouseMoveEvent, MouseUpEvent, ParentElement as _, - Pixels, Point, Render, StatefulInteractiveElement, Style, StyleRefinement, Styled as _, - WeakEntity, Window, + div, prelude::FluentBuilder as _, px, App, AppContext, Axis, Context, Element, Empty, Entity, + InteractiveElement as _, IntoElement, MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, + Point, Render, StatefulInteractiveElement, Style, StyleRefinement, Styled as _, WeakEntity, + Window, }; use serde::{Deserialize, Serialize}; @@ -411,9 +411,7 @@ impl Render for Dock { }) .map(|this| match &self.panel { DockItem::Split { view, .. } => this.child(view.clone()), - DockItem::Tabs { view, .. } => { - this.child(AnyView::from(view.clone()).cached(cache_style)) - } + DockItem::Tabs { view, .. } => this.child(view.clone()), DockItem::Panel { view, .. } => this.child(view.clone().view().cached(cache_style)), // Not support to render Tiles and Tile into Dock DockItem::Tiles { .. } => this, @@ -472,14 +470,20 @@ impl Element for DockElement { _: &mut Self::RequestLayoutState, _: &mut Self::PrepaintState, window: &mut gpui::Window, - _: &mut App, + cx: &mut App, ) { window.on_mouse_event({ let view = self.view.clone(); + let is_resizing = view.read(cx).is_resizing; move |e: &MouseMoveEvent, phase, window, cx| { - if phase.bubble() { - view.update(cx, |view, cx| view.resize(e.position, window, cx)) + if !is_resizing { + return; } + if !phase.bubble() { + return; + } + + view.update(cx, |view, cx| view.resize(e.position, window, cx)) } }); diff --git a/crates/ui/src/popup_menu.rs b/crates/ui/src/popup_menu.rs index 4f4260ae..5437b0f3 100644 --- a/crates/ui/src/popup_menu.rs +++ b/crates/ui/src/popup_menu.rs @@ -143,7 +143,6 @@ impl PopupMenu { scroll_state: Rc::new(Cell::new(ScrollbarState::default())), _subscriptions, }; - window.refresh(); f(menu, window, cx) }) } diff --git a/crates/ui/src/resizable/panel.rs b/crates/ui/src/resizable/panel.rs index 714bf396..138ff062 100644 --- a/crates/ui/src/resizable/panel.rs +++ b/crates/ui/src/resizable/panel.rs @@ -496,41 +496,38 @@ impl Element for ResizePanelGroupElement { let axis = self.axis; let current_ix = view.read(cx).resizing_panel_ix; move |e: &MouseMoveEvent, phase, window, cx| { - if phase.bubble() { - if let Some(ix) = current_ix { - view.update(cx, |view, cx| { - let panel = view - .panels - .get(ix) - .expect("BUG: invalid panel index") - .read(cx); - - match axis { - Axis::Horizontal => view.resize_panels( - ix, - e.position.x - panel.bounds.left(), - window, - cx, - ), - Axis::Vertical => { - view.resize_panels( - ix, - e.position.y - panel.bounds.top(), - window, - cx, - ); - } - } - }) - } + if !phase.bubble() { + return; } + let Some(ix) = current_ix else { return }; + + view.update(cx, |view, cx| { + let panel = view + .panels + .get(ix) + .expect("BUG: invalid panel index") + .read(cx); + + match axis { + Axis::Horizontal => { + view.resize_panels(ix, e.position.x - panel.bounds.left(), window, cx) + } + Axis::Vertical => { + view.resize_panels(ix, e.position.y - panel.bounds.top(), window, cx); + } + } + }) } }); // When any mouse up, stop dragging window.on_mouse_event({ let view = self.view.clone(); + let current_ix = view.read(cx).resizing_panel_ix; move |_: &MouseUpEvent, phase, window, cx| { + if current_ix.is_none() { + return; + } if phase.bubble() { view.update(cx, |view, cx| view.done_resizing(window, cx)); } diff --git a/crates/ui/src/window_border.rs b/crates/ui/src/window_border.rs index 0b911e8b..957a91e6 100644 --- a/crates/ui/src/window_border.rs +++ b/crates/ui/src/window_border.rs @@ -124,7 +124,6 @@ impl RenderOnce for WindowBorder { .when(!tiling.bottom, |div| div.pb(SHADOW_SIZE)) .when(!tiling.left, |div| div.pl(SHADOW_SIZE)) .when(!tiling.right, |div| div.pr(SHADOW_SIZE)) - .on_mouse_move(|_e, window, _| window.refresh()) .on_mouse_down(MouseButton::Left, move |_, window, _| { let size = window.window_bounds().get_bounds().size; let pos = window.mouse_position();