mirror of
https://github.com/project-gauntlet/gauntlet.git
synced 2025-12-23 10:35:53 +00:00
Fix sys tray open main and settings windows actions causing deadlock
This commit is contained in:
parent
a8287ede60
commit
08c5bb2c49
4 changed files with 28 additions and 9 deletions
|
|
@ -345,10 +345,10 @@ fn new(minimized: bool, #[allow(unused)] scenario_runner_data: Option<ScenarioRu
|
|||
(
|
||||
AppModel {
|
||||
// logic
|
||||
application_manager,
|
||||
application_manager: application_manager.clone(),
|
||||
global_hotkey_manager,
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
_tray_icon: sys_tray::create_tray(),
|
||||
_tray_icon: sys_tray::create_tray(application_manager.clone()),
|
||||
theme,
|
||||
window,
|
||||
|
||||
|
|
@ -1997,7 +1997,7 @@ impl AppModel {
|
|||
modifier_alt: false,
|
||||
modifier_meta: cfg!(target_os = "macos"),
|
||||
}) => {
|
||||
self.application_manager.handle_open_settings_window();
|
||||
self.application_manager.open_settings_window();
|
||||
|
||||
Task::none()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ pub fn handle_server_message(
|
|||
ServerGrpcApiRequestData::ShowSettingsWindow {} => {
|
||||
responder.respond(Ok(ServerGrpcApiResponseData::ShowSettingsWindow { data: () }));
|
||||
|
||||
state.application_manager.handle_open_settings_window();
|
||||
state.application_manager.open_settings_window();
|
||||
|
||||
Task::none()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
use image::ImageFormat;
|
||||
use tokio::runtime::Handle;
|
||||
use gauntlet_server::plugins::ApplicationManager;
|
||||
|
||||
pub fn create_tray() -> tray_icon::TrayIcon {
|
||||
pub fn create_tray(application_manager: Arc<ApplicationManager>) -> tray_icon::TrayIcon {
|
||||
use tray_icon::TrayIconBuilder;
|
||||
use tray_icon::menu::AboutMetadataBuilder;
|
||||
use tray_icon::menu::Menu;
|
||||
|
|
@ -11,10 +14,21 @@ pub fn create_tray() -> tray_icon::TrayIcon {
|
|||
use tray_icon::menu::accelerator::CMD_OR_CTRL;
|
||||
use tray_icon::menu::accelerator::Code;
|
||||
|
||||
MenuEvent::set_event_handler(Some(|event: MenuEvent| {
|
||||
let handle = Handle::current();
|
||||
|
||||
MenuEvent::set_event_handler(Some(move |event: MenuEvent| {
|
||||
match event.id().as_ref() {
|
||||
"GAUNTLET_OPEN_MAIN_WINDOW" => gauntlet_common::cli::open_window(),
|
||||
"GAUNTLET_OPEN_SETTING_WINDOW" => gauntlet_common::cli::open_settings_window(),
|
||||
"GAUNTLET_OPEN_MAIN_WINDOW" => {
|
||||
handle.spawn({
|
||||
let application_manager = application_manager.clone();
|
||||
async move {
|
||||
application_manager.open_window().await;
|
||||
}
|
||||
});
|
||||
},
|
||||
"GAUNTLET_OPEN_SETTING_WINDOW" => {
|
||||
application_manager.open_settings_window();
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -801,7 +801,12 @@ impl ApplicationManager {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn handle_open_settings_window(&self) {
|
||||
pub async fn open_window(&self) {
|
||||
self.frontend_api.toggle_window().await
|
||||
.expect("failed to toggle window");
|
||||
}
|
||||
|
||||
pub fn open_settings_window(&self) {
|
||||
let current_exe = std::env::current_exe().expect("unable to get current_exe");
|
||||
|
||||
std::process::Command::new(current_exe)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue