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:
K Simmons 2022-10-12 15:10:00 -07:00
parent 81a3a22379
commit 1d8717f4de
6 changed files with 249 additions and 131 deletions

View file

@ -170,7 +170,11 @@ impl Dock {
} else {
cx.focus(pane);
}
} else if let Some(last_active_center_pane) = workspace.last_active_center_pane.clone() {
} else if let Some(last_active_center_pane) = workspace
.last_active_center_pane
.as_ref()
.and_then(|pane| pane.upgrade(cx))
{
cx.focus(last_active_center_pane);
}
cx.emit(crate::Event::DockAnchorChanged);
@ -583,10 +587,11 @@ mod tests {
}
pub fn center_pane_handle(&self) -> ViewHandle<Pane> {
self.workspace(|workspace, _| {
self.workspace(|workspace, cx| {
workspace
.last_active_center_pane
.clone()
.and_then(|pane| pane.upgrade(cx))
.unwrap_or_else(|| workspace.center.panes()[0].clone())
})
}
@ -597,6 +602,7 @@ mod tests {
let pane = workspace
.last_active_center_pane
.clone()
.and_then(|pane| pane.upgrade(cx))
.unwrap_or_else(|| workspace.center.panes()[0].clone());
Pane::add_item(
workspace,