mirror of
https://github.com/librekeys/picoforge.git
synced 2026-07-28 08:01:19 -07:00
fix: getCurrentWindow() frezzing the application on macos
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||
<img src="static/in.suyogtandel.picoforge.svg" width="512" height="512" alt="PicoForge Logo">
|
||||
|
||||
**An open source commissioning tool for Pico FIDO security keys**
|
||||
|
||||
|
||||
+29
-1
@@ -29,6 +29,30 @@ pub fn setup_window_state_listener(window: &WebviewWindow) {
|
||||
});
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn minimize_window(window: WebviewWindow) {
|
||||
let _ = window.minimize();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn toggle_maximize_window(window: WebviewWindow) {
|
||||
if window.is_maximized().unwrap_or(false) {
|
||||
let _ = window.unmaximize();
|
||||
} else {
|
||||
let _ = window.maximize();
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn close_window(window: WebviewWindow) {
|
||||
let _ = window.close();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_window_maximized(window: WebviewWindow) -> bool {
|
||||
window.is_maximized().unwrap_or(false)
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
logging::logger_init();
|
||||
@@ -53,7 +77,11 @@ pub fn run() {
|
||||
io::delete_credential,
|
||||
io::set_min_pin_length,
|
||||
io::enable_secure_boot,
|
||||
io::reboot
|
||||
io::reboot,
|
||||
minimize_window,
|
||||
toggle_maximize_window,
|
||||
close_window,
|
||||
get_window_maximized
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
|
||||
import { Home, Info, KeyRound, Maximize, Minimize, Minus, RefreshCw, ScrollText, Settings, ShieldCheck, X } from "@lucide/svelte";
|
||||
@@ -25,7 +25,7 @@
|
||||
let isMaximized = $state(false);
|
||||
let unlistenWindowState: (() => void) | undefined;
|
||||
|
||||
const appWindow = getCurrentWindow();
|
||||
// const appWindow = getCurrentWindow();
|
||||
|
||||
const menuItems: Array<{ view: View; icon: Component; label: string }> = [
|
||||
{ view: "home", icon: Home, label: "Home" },
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
onMount(() => {
|
||||
const setupWindow = async () => {
|
||||
isMaximized = await appWindow.isMaximized();
|
||||
isMaximized = await invoke("get_window_maximized");
|
||||
|
||||
unlistenWindowState = await listen<{ isMaximized: boolean }>("window-state-changed", (event) => {
|
||||
isMaximized = event.payload.isMaximized;
|
||||
@@ -119,11 +119,11 @@
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<Button variant="ghost" size="icon" class="h-8 w-8 hover:bg-muted" onclick={() => appWindow.minimize()}>
|
||||
<Button variant="ghost" size="icon" class="h-8 w-8 hover:bg-muted" onclick={() => invoke("minimize_window")}>
|
||||
<Minus class="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
<Button variant="ghost" size="icon" class="h-8 w-8 hover:bg-muted" onclick={() => appWindow.toggleMaximize()}>
|
||||
<Button variant="ghost" size="icon" class="h-8 w-8 hover:bg-muted" onclick={() => invoke("toggle_maximize_window")}>
|
||||
{#if isMaximized}
|
||||
<Minimize class="h-3.5 w-3.5 rotate-180" />
|
||||
{:else}
|
||||
@@ -135,7 +135,7 @@
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
class="h-8 w-8 hover:bg-red-500 hover:text-white transition-colors"
|
||||
onclick={() => appWindow.close()}
|
||||
onclick={() => invoke("close_window")}
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user