gpui_macos: Fix deadlock during re-entrant key status changes (#51035)

Closes #50151

Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Fixed a deadlock that froze the entire app when opening a new window
from a PopUp window or switching focus between multiple windows on
macOS.
This commit is contained in:
João Soares authored and GitHub committed 2026-03-17 08:50:54 +00:00
1 parent 9a0a75ce73
commit c22fc3bd31
1 file changed
+4 -2
+4 -2
View File
@@ -2113,10 +2113,12 @@ extern "C" fn window_did_change_key_status(this: &Object, selector: Sel, _: id)
// in theory, we're not supposed to invoke this method manually but it balances out
// the spurious `becomeKeyWindow` event and helps us work around that bug.
if selector == sel!(windowDidBecomeKey:) && !is_active {
let native_window = lock.native_window;
drop(lock);
unsafe {
let _: () = msg_send![lock.native_window, resignKeyWindow];
return;
let _: () = msg_send![native_window, resignKeyWindow];
}
return;
}
let executor = lock.foreground_executor.clone();