mirror of
https://github.com/ByteAtATime/raycast-linux.git
synced 2025-08-31 03:07:23 +00:00
feat: Implement hide on escape and focus loss
This commit adds two ways that hides the main window. First, when the user presses escape in the command palette, the window hides; second, when the focus is lost (i.e. the user's cursor goes outside the window), it also hides itself.
This commit is contained in:
parent
9d73ac0a23
commit
58e48213bd
3 changed files with 28 additions and 11 deletions
|
@ -7,6 +7,7 @@
|
|||
],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-hide",
|
||||
"opener:default",
|
||||
"clipboard-manager:default",
|
||||
"clipboard-manager:allow-write-text",
|
||||
|
|
|
@ -274,16 +274,23 @@ pub fn run() {
|
|||
.build(tauri::generate_context!()).unwrap();
|
||||
|
||||
app.run(|app, event| {
|
||||
if let tauri::RunEvent::WindowEvent {
|
||||
event: tauri::WindowEvent::CloseRequested { api, .. },
|
||||
..
|
||||
} = event
|
||||
{
|
||||
api.prevent_close();
|
||||
app.get_webview_window("main")
|
||||
.unwrap()
|
||||
.hide()
|
||||
.expect("To hide the window");
|
||||
}
|
||||
if let tauri::RunEvent::WindowEvent { label, event, .. } = event {
|
||||
if label == "main" {
|
||||
match event {
|
||||
tauri::WindowEvent::CloseRequested { api, .. } => {
|
||||
api.prevent_close();
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.hide();
|
||||
}
|
||||
}
|
||||
tauri::WindowEvent::Focused(false) => {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.hide();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue