diff --git a/apps/stage-tamagotchi/src/composables/window-shortcuts.ts b/apps/stage-tamagotchi/src/composables/window-shortcuts.ts index 8e063a71a..fb8df51fa 100644 --- a/apps/stage-tamagotchi/src/composables/window-shortcuts.ts +++ b/apps/stage-tamagotchi/src/composables/window-shortcuts.ts @@ -2,68 +2,17 @@ import type { ShortcutEvent } from '@tauri-apps/plugin-global-shortcut' import { register, unregisterAll } from '@tauri-apps/plugin-global-shortcut' import { storeToRefs } from 'pinia' -import { computed, watch } from 'vue' +import { watch } from 'vue' import { useShortcutsStore } from '../stores/shortcuts' -import { useWindowControlStore } from '../stores/window-controls' -import { WindowControlMode } from '../types/window-controls' -import { startClickThrough, stopClickThrough } from '../utils/windows' export function useWindowShortcuts() { - const windowStore = useWindowControlStore() - const { shortcuts } = storeToRefs(useShortcutsStore()) - const handlers = computed(() => [ - { - handle: async (event: ShortcutEvent) => { - if (event.state !== 'Pressed') { - return - } - windowStore.setMode(WindowControlMode.MOVE) - windowStore.toggleControl() - }, - shortcut: shortcuts.value.find(shortcut => shortcut.type === 'move')?.shortcut, - }, - { - handle: async (event: ShortcutEvent) => { - if (event.state !== 'Pressed') { - return - } - - windowStore.setMode(WindowControlMode.RESIZE) - windowStore.toggleControl() - }, - shortcut: shortcuts.value.find(shortcut => shortcut.type === 'resize')?.shortcut, - }, - { - handle: async (event: ShortcutEvent) => { - if (event.state !== 'Pressed') { - return - } - - windowStore.setMode(WindowControlMode.DEBUG) - windowStore.toggleControl() - }, - shortcut: shortcuts.value.find(shortcut => shortcut.type === 'debug')?.shortcut, - }, - { - handle: async (event: ShortcutEvent) => { - if (event.state === 'Pressed') { - stopClickThrough() - return - } - - startClickThrough() - }, - shortcut: shortcuts.value.find(shortcut => shortcut.type === 'ignore-mouse-event')?.shortcut, - }, - ]) - - watch(handlers, async () => { + watch(shortcuts, async () => { await unregisterAll() - for (const handler of handlers.value) { + for (const handler of shortcuts.value) { if (!handler.shortcut) { return } diff --git a/apps/stage-tamagotchi/src/pages/index.vue b/apps/stage-tamagotchi/src/pages/index.vue index 8ab964804..080d6c57d 100644 --- a/apps/stage-tamagotchi/src/pages/index.vue +++ b/apps/stage-tamagotchi/src/pages/index.vue @@ -52,6 +52,10 @@ function openChat() { invoke('open_chat_window') } +const shouldHideView = computed(() => { + return isCursorInside.value && !windowStore.isControlActive && windowStore.isIgnoringMouseEvent +}) + onMounted(async () => { // Listen for click-through state changes unlisten.push(await listen('tauri-app:window-click-through:is-inside', (event: { payload: boolean }) => { @@ -79,7 +83,7 @@ onUnmounted(() => {