@@ -29,8 +29,6 @@ pub fn run() {
2929 window. on_window_event ( move |event| {
3030 if let tauri:: WindowEvent :: Focused ( false ) = event {
3131 let win = w. clone ( ) ;
32- // Small delay: if focus returns within 200ms (e.g. DevTools, HMR),
33- // don't hide. This prevents the panel flickering in dev mode.
3432 std:: thread:: spawn ( move || {
3533 std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 200 ) ) ;
3634 if !win. is_focused ( ) . unwrap_or ( true ) {
@@ -41,27 +39,70 @@ pub fn run() {
4139 } ) ;
4240 }
4341
44- // Register global hotkey: Cmd+Shift+R
42+ // Hide spotlight when it loses focus
43+ if let Some ( window) = app. get_webview_window ( "spotlight" ) {
44+ let w = window. clone ( ) ;
45+ window. on_window_event ( move |event| {
46+ if let tauri:: WindowEvent :: Focused ( false ) = event {
47+ let win = w. clone ( ) ;
48+ std:: thread:: spawn ( move || {
49+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 200 ) ) ;
50+ if !win. is_focused ( ) . unwrap_or ( true ) {
51+ let _ = win. hide ( ) ;
52+ }
53+ } ) ;
54+ }
55+ } ) ;
56+ }
57+
58+ // Register global hotkeys
4559 #[ cfg( desktop) ]
4660 {
4761 use tauri_plugin_global_shortcut:: {
4862 Code , GlobalShortcutExt , Modifiers , Shortcut , ShortcutState ,
4963 } ;
5064
51- let shortcut =
65+ let shortcut_panel =
5266 Shortcut :: new ( Some ( Modifiers :: META | Modifiers :: SHIFT ) , Code :: KeyR ) ;
67+ let shortcut_spotlight =
68+ Shortcut :: new ( Some ( Modifiers :: META | Modifiers :: SHIFT ) , Code :: KeyX ) ;
69+ let shortcut_translate =
70+ Shortcut :: new ( Some ( Modifiers :: META | Modifiers :: SHIFT ) , Code :: KeyT ) ;
71+ let shortcut_summarize =
72+ Shortcut :: new ( Some ( Modifiers :: META | Modifiers :: SHIFT ) , Code :: KeyS ) ;
73+ let shortcut_explain =
74+ Shortcut :: new ( Some ( Modifiers :: META | Modifiers :: SHIFT ) , Code :: KeyE ) ;
5375
5476 let handle = app. handle ( ) . clone ( ) ;
77+ let sc_panel = shortcut_panel. clone ( ) ;
78+ let sc_spotlight = shortcut_spotlight. clone ( ) ;
79+ let sc_translate = shortcut_translate. clone ( ) ;
80+ let sc_summarize = shortcut_summarize. clone ( ) ;
81+
5582 app. handle ( ) . plugin (
5683 tauri_plugin_global_shortcut:: Builder :: new ( )
57- . with_handler ( move |_app, _shortcut , event| {
84+ . with_handler ( move |_app, shortcut , event| {
5885 if event. state ( ) == ShortcutState :: Pressed {
59- let _ = commands:: toggle_panel_internal ( & handle) ;
86+ if * shortcut == sc_panel {
87+ let _ = commands:: toggle_panel_internal ( & handle) ;
88+ } else if * shortcut == sc_spotlight {
89+ let _ = commands:: toggle_spotlight_internal ( & handle) ;
90+ } else if * shortcut == sc_translate {
91+ let _ = commands:: clipboard_action_sync ( & handle, "translate" ) ;
92+ } else if * shortcut == sc_summarize {
93+ let _ = commands:: clipboard_action_sync ( & handle, "summarize" ) ;
94+ } else {
95+ let _ = commands:: clipboard_action_sync ( & handle, "explain" ) ;
96+ }
6097 }
6198 } )
6299 . build ( ) ,
63100 ) ?;
64- app. global_shortcut ( ) . register ( shortcut) ?;
101+ app. global_shortcut ( ) . register ( shortcut_panel) ?;
102+ app. global_shortcut ( ) . register ( shortcut_spotlight) ?;
103+ app. global_shortcut ( ) . register ( shortcut_translate) ?;
104+ app. global_shortcut ( ) . register ( shortcut_summarize) ?;
105+ app. global_shortcut ( ) . register ( shortcut_explain) ?;
65106 }
66107
67108 Ok ( ( ) )
@@ -73,6 +114,10 @@ pub fn run() {
73114 commands:: copy_to_clipboard,
74115 commands:: show_notification,
75116 commands:: toggle_panel,
117+ commands:: toggle_spotlight,
118+ commands:: open_chat,
119+ commands:: read_clipboard,
120+ commands:: clipboard_action,
76121 commands:: spawn_gateway,
77122 commands:: stop_gateway,
78123 commands:: is_gateway_running,
0 commit comments