This commit is contained in:
Smit Barmase 2025-07-16 23:31:11 +05:30
parent d7d12b2510
commit dbed047caa
No known key found for this signature in database
3 changed files with 7 additions and 1 deletions

View file

@ -949,10 +949,12 @@ impl App {
.write()
.retain(|handle_id, count| {
if count.load(SeqCst) == 0 {
println!("Dropping {handle_id}");
for window_handle in self.windows() {
window_handle
.update(self, |_, window, _| {
if window.focus == Some(handle_id) {
println!("released focus handle blur");
window.blur();
}
})

View file

@ -227,7 +227,7 @@ pub(crate) type FocusMap = RwLock<SlotMap<FocusId, AtomicUsize>>;
impl FocusId {
/// Obtains whether the element associated with this handle is currently focused.
pub fn is_focused(&self, window: &Window) -> bool {
window.focus == Some(*self)
dbg!(window.focus) == Some(*self)
}
/// Obtains whether the element associated with this handle contains the focused
@ -1295,6 +1295,7 @@ impl Window {
/// Blur the window and don't allow anything in it to be focused again.
pub fn disable_focus(&mut self) {
println!("disable_focus");
self.blur();
self.focus_enabled = false;
}

View file

@ -1219,6 +1219,7 @@ impl Workspace {
.detach();
cx.on_focus_lost(window, |this, window, cx| {
println!("workspace on_focus_lost");
let focus_handle = this.focus_handle(cx);
window.focus(&focus_handle);
})
@ -1245,6 +1246,8 @@ impl Workspace {
window.focus(&center_pane.focus_handle(cx));
// center_pane.focus_handle(cx).is_focused(window);
cx.emit(Event::PaneAdded(center_pane.clone()));
let window_handle = window.window_handle().downcast::<Workspace>().unwrap();