From e6048f5af8844811b1a9588fab763c505d4bc64e Mon Sep 17 00:00:00 2001 From: Ilya Bogdanov <34226834+skirkru@users.noreply.github.com> Date: Tue, 26 Aug 2025 09:18:12 +0300 Subject: [PATCH] fix(stage-tamagotchi): fix first time initialization blank and an overlook (#466) --- .../window-pass-through-on-hover.ts | 45 +++++++------------ .../stage-tamagotchi/src/composables/tauri.ts | 2 +- apps/stage-tamagotchi/src/pages/index.vue | 10 +++-- 3 files changed, 23 insertions(+), 34 deletions(-) diff --git a/apps/stage-tamagotchi/src/bindings/tauri-plugins/window-pass-through-on-hover.ts b/apps/stage-tamagotchi/src/bindings/tauri-plugins/window-pass-through-on-hover.ts index 23be10dec..924d33824 100644 --- a/apps/stage-tamagotchi/src/bindings/tauri-plugins/window-pass-through-on-hover.ts +++ b/apps/stage-tamagotchi/src/bindings/tauri-plugins/window-pass-through-on-hover.ts @@ -4,40 +4,25 @@ /** user-defined commands **/ -let passThroughEnabled = false; export const commands = { - async startPassThrough(): Promise> { - if (passThroughEnabled) { - return { status: 'ok', data: null }; - } +async startPassThrough() : Promise> { try { - passThroughEnabled = true; - return { status: 'ok', data: await TAURI_INVOKE('plugin:window-pass-through-on-hover|start_pass_through') }; - } - catch (e) { - passThroughEnabled = false; - if (e instanceof Error) - throw e; - else return { status: 'error', error: e as any }; - } - }, - async stopPassThrough(): Promise> { - if (!passThroughEnabled) { - return { status: 'ok', data: null }; - } + return { status: "ok", data: await TAURI_INVOKE("plugin:window-pass-through-on-hover|start_pass_through") }; +} catch (e) { + if(e instanceof Error) throw e; + else return { status: "error", error: e as any }; +} +}, +async stopPassThrough() : Promise> { try { - passThroughEnabled = false; - return { status: 'ok', data: await TAURI_INVOKE('plugin:window-pass-through-on-hover|stop_pass_through') }; - } - catch (e) { - passThroughEnabled = true; - if (e instanceof Error) - throw e; - else return { status: 'error', error: e as any }; - } - } -}; + return { status: "ok", data: await TAURI_INVOKE("plugin:window-pass-through-on-hover|stop_pass_through") }; +} catch (e) { + if(e instanceof Error) throw e; + else return { status: "error", error: e as any }; +} +} +} /** user-defined events **/ diff --git a/apps/stage-tamagotchi/src/composables/tauri.ts b/apps/stage-tamagotchi/src/composables/tauri.ts index 9df22d01f..6c7252600 100644 --- a/apps/stage-tamagotchi/src/composables/tauri.ts +++ b/apps/stage-tamagotchi/src/composables/tauri.ts @@ -36,7 +36,7 @@ export interface WindowFrame { interface Events { 'tauri://resize': unknown - 'tauri://move': { payload: { x: number, y: number } } + 'tauri://move': { x: number, y: number } 'tauri://close-requested': unknown 'tauri://destroyed': unknown 'tauri://focus': unknown diff --git a/apps/stage-tamagotchi/src/pages/index.vue b/apps/stage-tamagotchi/src/pages/index.vue index 772e78d08..5cef3d382 100644 --- a/apps/stage-tamagotchi/src/pages/index.vue +++ b/apps/stage-tamagotchi/src/pages/index.vue @@ -42,17 +42,21 @@ const windowY = ref(0) const isClickThrough = ref(false) const isPassingThrough = ref(false) const isOverUI = ref(false) +const isFirstTime = ref(true) watchThrottled([mouseX, mouseY], async ([x, y]) => { const canvas = widgetStageRef.value?.canvasElement() if (!canvas) return + isFirstTime.value = false + if (windowControlStore.controlMode === WindowControlMode.RESIZE || windowControlStore.controlMode === WindowControlMode.MOVE) { if (isPassingThrough.value) { passThroughCommands.stopPassThrough() isPassingThrough.value = false } + return } @@ -194,8 +198,8 @@ onMounted(async () => { windowY.value = pos.y } unListenFuncs.push(await listen('tauri://move', (event) => { - windowX.value = event.payload.payload.x - windowY.value = event.payload.payload.y + windowX.value = event.payload.x + windowY.value = event.payload.y })) await setupVADModel() @@ -234,7 +238,7 @@ if (import.meta.hot) { // For better DX