forked from cinnyapp/cinny-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Does what title says. Lifts event handler logic from paste image support (cinnyapp#167). Includes some commented out logic for compatibility with systray (cinnyapp#166) when/if merged. Requires TRAY_LABEL be exposed as public, however.
- Loading branch information
Showing
3 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use tauri::{ GlobalShortcutManager, Manager }; | ||
|
||
//use crate::tray; | ||
|
||
pub fn ready_event_handler<R: tauri::Runtime>( | ||
app: &tauri::AppHandle<R> | ||
) { | ||
let manager = app.global_shortcut_manager(); | ||
manager.clone().register("CmdOrCtrl+w", hide_closure(app)).unwrap(); | ||
manager.clone().register("CmdOrCtrl+q", close_closure(app)).unwrap(); | ||
} | ||
|
||
fn hide_closure<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> impl Fn() { | ||
let window = app.get_window("main").unwrap(); | ||
//let app = app.clone(); | ||
return move || { | ||
window.hide().unwrap(); | ||
//tray::toggle_window_state(window.clone(), app.tray_handle_by_id(tray::TRAY_LABEL).unwrap()) | ||
} | ||
} | ||
|
||
fn close_closure<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> impl Fn() { | ||
let window = app.get_window("main").unwrap(); | ||
return move || window.close().unwrap(); | ||
} |