Merge pull request #53 from cjpais/fix-check-updates-window
make sure to focus window when clicking 'check for updates'
This commit is contained in:
commit
836ba0f7ae
1 changed files with 24 additions and 21 deletions
|
|
@ -26,6 +26,28 @@ struct ShortcutToggleStates {
|
||||||
|
|
||||||
type ManagedToggleState = Mutex<ShortcutToggleStates>;
|
type ManagedToggleState = Mutex<ShortcutToggleStates>;
|
||||||
|
|
||||||
|
fn show_main_window(app: &AppHandle) {
|
||||||
|
if let Some(main_window) = app.get_webview_window("main") {
|
||||||
|
// First, ensure the window is visible
|
||||||
|
if let Err(e) = main_window.show() {
|
||||||
|
eprintln!("Failed to show window: {}", e);
|
||||||
|
}
|
||||||
|
// Then, bring it to the front and give it focus
|
||||||
|
if let Err(e) = main_window.set_focus() {
|
||||||
|
eprintln!("Failed to focus window: {}", e);
|
||||||
|
}
|
||||||
|
// Optional: On macOS, ensure the app becomes active if it was an accessory
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
if let Err(e) = app.set_activation_policy(tauri::ActivationPolicy::Regular) {
|
||||||
|
eprintln!("Failed to set activation policy to Regular: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
eprintln!("Main window not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn trigger_update_check(app: AppHandle) -> Result<(), String> {
|
fn trigger_update_check(app: AppHandle) -> Result<(), String> {
|
||||||
app.emit("check-for-updates", ())
|
app.emit("check-for-updates", ())
|
||||||
|
|
@ -98,29 +120,10 @@ pub fn run() {
|
||||||
.icon_as_template(true)
|
.icon_as_template(true)
|
||||||
.on_menu_event(|app, event| match event.id.as_ref() {
|
.on_menu_event(|app, event| match event.id.as_ref() {
|
||||||
"settings" => {
|
"settings" => {
|
||||||
if let Some(settings_window) = app.get_webview_window("main") {
|
show_main_window(app);
|
||||||
// First, ensure the window is visible
|
|
||||||
if let Err(e) = settings_window.show() {
|
|
||||||
eprintln!("Failed to show window: {}", e);
|
|
||||||
}
|
|
||||||
// Then, bring it to the front and give it focus
|
|
||||||
if let Err(e) = settings_window.set_focus() {
|
|
||||||
eprintln!("Failed to focus window: {}", e);
|
|
||||||
}
|
|
||||||
// Optional: On macOS, ensure the app becomes active if it was an accessory
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
{
|
|
||||||
if let Err(e) =
|
|
||||||
app.set_activation_policy(tauri::ActivationPolicy::Regular)
|
|
||||||
{
|
|
||||||
eprintln!("Failed to set activation policy to Regular: {}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
eprintln!("Main window not found");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"check_updates" => {
|
"check_updates" => {
|
||||||
|
show_main_window(app);
|
||||||
let _ = app.emit("check-for-updates", ());
|
let _ = app.emit("check-for-updates", ());
|
||||||
}
|
}
|
||||||
"quit" => {
|
"quit" => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue