Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: clear stale tray picker hover on keyboard navigation
Ilyae4e26e55689f
diff --git a/apps/desktop-gpui/src/tray.rs b/apps/desktop-gpui/src/tray.rsindex ed8fa30dc..3e16092a9 100644--- a/apps/desktop-gpui/src/tray.rs+++ b/apps/desktop-gpui/src/tray.rs@@ -988,7 +988,9 @@ mod mac {};use objc2_foundation::{MainThreadMarker, NSData, NSRunLoop, NSString, NSTimer};- use super::mac_mode_picker::{append_mode_picker, install_key_hook, stop_flash};+ use super::mac_mode_picker::{+ append_mode_picker, clear_hover, clear_hover_unless, install_key_hook, stop_flash,+ };use super::{Accelerator, Entry, PREVIOUS_SYMBOL, PreviousItem, STOP_ICON, TrayItem,current_menu_entries, handle_item, mode_icon, mode_submenu, row_symbol, scan_previous,@@ -1067,15 +1069,22 @@ mod mac {unsafe impl NSObjectProtocol for TrayTarget {}unsafe impl NSMenuDelegate for TrayTarget {+ #[unsafe(method(menu:willHighlightItem:))]+ fn menu_will_highlight_item(&self, _menu: &NSMenu, item: Option<&NSMenuItem>) {+ clear_hover_unless(item);+ }+#[unsafe(method(menuWillOpen:))]fn menu_will_open(&self, _menu: &NSMenu) {MENU_OPEN.with(|o| o.set(true));+ clear_hover();start_option_tracking();}#[unsafe(method(menuDidClose:))]fn menu_did_close(&self, _menu: &NSMenu) {MENU_OPEN.with(|o| o.set(false));+ clear_hover();stop_option_tracking();stop_flash();if REBUILD_PENDING.with(|p| p.replace(false)) {diff --git a/apps/desktop-gpui/src/tray/mac_mode_picker.rs b/apps/desktop-gpui/src/tray/mac_mode_picker.rsindex 693c35788..2936c21a1 100644--- a/apps/desktop-gpui/src/tray/mac_mode_picker.rs+++ b/apps/desktop-gpui/src/tray/mac_mode_picker.rs@@ -500,6 +500,12 @@ impl ModePickerView {}}+ fn clear_focus(&self) {+ if self.ivars().focused.replace(None).is_some() {+ self.refresh();+ }+ }+/// Moves keyboard focus one pill. Returns false at either end, so the key falls/// through to the menu and moves to the neighbouring tray menu.fn move_focus(&self, delta: isize) -> bool {@@ -527,6 +533,26 @@ impl ModePickerView {}}+pub(super) fn clear_hover_unless(item: Option<&NSMenuItem>) {+ PICKER.with(|p| {+ let p = p.borrow();+ let Some((picker, view)) = p.as_ref() else {+ return;+ };+ if !item.is_some_and(|item| std::ptr::eq(item, &**picker)) {+ view.clear_focus();+ }+ });+}++pub(super) fn clear_hover() {+ PICKER.with(|p| {+ if let Some((_, view)) = p.borrow().as_ref() {+ view.clear_focus();+ }+ });+}+pub(super) fn stop_flash() {FLASH_TIMER.with(|slot| {if let Some(timer) = slot.borrow_mut().take() {