Remove focus filtering from gpui so all focus events result in focus-in and focus-out calls
Remove pane focused event in favor of focus_in at the workspace level Added is_child to ViewContext to determine if a given view is a child of the current view Fix issue where dock would get in a infinite loop when activated after dragging an item out of it Fix issue where the last focused view in an item was not correctly refocused when a pane is focused after switching active tabs Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
81a3a22379
commit
1d8717f4de
6 changed files with 249 additions and 131 deletions
|
@ -618,7 +618,6 @@ pub struct MutableAppContext {
|
|||
HashMap<usize, (Rc<RefCell<Presenter>>, Box<dyn platform::Window>)>,
|
||||
foreground: Rc<executor::Foreground>,
|
||||
pending_effects: VecDeque<Effect>,
|
||||
pending_focus_index: Option<usize>,
|
||||
pending_notifications: HashSet<usize>,
|
||||
pending_global_notifications: HashSet<TypeId>,
|
||||
pending_flushes: usize,
|
||||
|
@ -673,7 +672,6 @@ impl MutableAppContext {
|
|||
presenters_and_platform_windows: Default::default(),
|
||||
foreground,
|
||||
pending_effects: VecDeque::new(),
|
||||
pending_focus_index: None,
|
||||
pending_notifications: Default::default(),
|
||||
pending_global_notifications: Default::default(),
|
||||
pending_flushes: 0,
|
||||
|
@ -1876,9 +1874,6 @@ impl MutableAppContext {
|
|||
let mut refreshing = false;
|
||||
loop {
|
||||
if let Some(effect) = self.pending_effects.pop_front() {
|
||||
if let Some(pending_focus_index) = self.pending_focus_index.as_mut() {
|
||||
*pending_focus_index = pending_focus_index.saturating_sub(1);
|
||||
}
|
||||
match effect {
|
||||
Effect::Subscription {
|
||||
entity_id,
|
||||
|
@ -2259,8 +2254,6 @@ impl MutableAppContext {
|
|||
}
|
||||
|
||||
fn handle_focus_effect(&mut self, window_id: usize, focused_id: Option<usize>) {
|
||||
self.pending_focus_index.take();
|
||||
|
||||
if self
|
||||
.cx
|
||||
.windows
|
||||
|
@ -2383,10 +2376,6 @@ impl MutableAppContext {
|
|||
}
|
||||
|
||||
pub fn focus(&mut self, window_id: usize, view_id: Option<usize>) {
|
||||
if let Some(pending_focus_index) = self.pending_focus_index {
|
||||
self.pending_effects.remove(pending_focus_index);
|
||||
}
|
||||
self.pending_focus_index = Some(self.pending_effects.len());
|
||||
self.pending_effects
|
||||
.push_back(Effect::Focus { window_id, view_id });
|
||||
}
|
||||
|
@ -3465,6 +3454,15 @@ impl<'a, T: View> ViewContext<'a, T> {
|
|||
self.app.focused_view_id(self.window_id) == Some(self.view_id)
|
||||
}
|
||||
|
||||
pub fn is_child(&self, view: impl Into<AnyViewHandle>) -> bool {
|
||||
let view = view.into();
|
||||
if self.window_id != view.window_id {
|
||||
return false;
|
||||
}
|
||||
self.parents(view.window_id, view.view_id)
|
||||
.any(|parent| parent == self.view_id)
|
||||
}
|
||||
|
||||
pub fn blur(&mut self) {
|
||||
self.app.focus(self.window_id, None);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue