From 0e662198769e8bef8fe0478a0a581e68fcfc3cff Mon Sep 17 00:00:00 2001 From: Feargin Date: Sun, 25 Oct 2026 20:57:14 +0300 Subject: [PATCH] fix: the tour and the hotkey hint show on the first launch On a manual launch Rust shows the window and emits overlay:show before the interface has subscribed to it, so the event was lost: a fresh install never got the first-run tour, and a taken global hotkey was not reported at startup. get_settings now says whether the canvas is already visible, and the interface runs the same show handler itself. A hidden start (autostart) still waits for the event. Checked in the real app: a 22.04 AppImage built from this commit, on a clean system with no settings file, opens with the tour. Co-Authored-By: Claude Opus 5.5 --- src-tauri/src/lib.rs | 7 +++++++ src/main.js | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 62408f3..bb598c2 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -53,6 +53,9 @@ struct AppInfo { onboarded: bool, /// Работают ли удержание и двойной тап на этой системе (опрос клавиш). hold_supported: bool, + /// Холст уже показан: при ручном запуске окно появляется раньше, чем интерфейс + /// подписался на `overlay:show`, — и интерфейс встречает показ сам. + visible: bool, } #[tauri::command] @@ -81,6 +84,10 @@ fn get_settings(app: AppHandle, store: State, hotkeys: State { selectTool('select'); state.sel = shape.id initKeyboard(); initPointer(tools); addEventListener('resize', resize); -api.on('overlay:show', () => { +function onShow() { setMode('draw'); // Глобальный хоткей занят другой программой — без подсказки не понять, почему он не работает. if (!info.hotkeyOk) showToast(`${formatKeys(info.hotkey)} — ${t('settings.hotkey.taken')}`); // Первый показ после установки — обучение. if (!info.onboarded) startTour(); -}); +} +api.on('overlay:show', onShow); api.on('overlay:toggle', () => { cancelScreenshot(); // В сквозном режиме карточка обучения не кликается — закрываем, покажется в следующий раз. @@ -54,5 +55,8 @@ api.on('overlay:toggle', () => { }); // Зажат Alt: мышь уходит окнам под холстом, рисунок полупрозрачный. api.on('overlay:peek', (held) => document.body.classList.toggle('peek', held)); -// Окно стартует спрятанным; режим рисования включится событием overlay:show при первом показе. resize(); +// При ручном запуске Rust показывает окно раньше, чем интерфейс подписался на overlay:show, — +// то событие теряется. Поэтому уже видимый холст встречаем сами (иначе нет обучения при первом +// запуске и подсказки о занятом хоткее). Спрятанный (автозапуск) дождётся события. +if (info.visible) onShow();