加入滑鼠事件紀錄與鎖定/解鎖處理,追查解鎖後點不到寵物
根本原因: 使用者回報登出/鎖定螢幕再回來後就不能拖曳、不能右鍵。現場量測顯示 OS 這一層正常(點穿位元會切、WindowFromPoint 打到寵物視窗),但事件紀錄裡 完全沒有拖曳或選單的痕跡,代表問題在 renderer 有沒有收到滑鼠事件這一層, 而這一層目前沒有任何可觀測資料,無法判斷。 影響: 解鎖後偶發點不到寵物,且發生時查不出卡在哪裡。 修法: 1. renderer 把 mousedown/mouseup(含按鍵與座標、當時的 pressed/drag)與 hover 進出寫進事件紀錄;pet:state 帶 rendererMouse(pressed/drag/hovered /overlay),/state 可直接查。 2. 主程序監聽 powerMonitor 的 lock-screen/unlock-screen/suspend/resume: 記錄到事件紀錄與 /state.mouse.sessionEvents,解鎖或喚醒後重新套用目前的 點穿狀態、showInactive 並重宣告置頂。 版號 2.0.12。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+12
-1
@@ -518,7 +518,11 @@ function handleTest(p) {
|
||||
|
||||
function report() {
|
||||
const base = baseState();
|
||||
const snapshot = JSON.stringify({ anim: player.anim, base, sessions: sessions.size, pet: petInfo?.id || null });
|
||||
const snapshot = JSON.stringify({
|
||||
anim: player.anim, base, sessions: sessions.size, pet: petInfo?.id || null,
|
||||
// renderer 這邊的滑鼠狀態也露到 /state,查「點不到寵物」時才看得出是不是卡在這裡
|
||||
rendererMouse: { pressed: !!pressed, drag: !!drag, hovered, overlay: overlay?.anim || null },
|
||||
});
|
||||
if (snapshot !== lastReported) {
|
||||
lastReported = snapshot;
|
||||
window.pet.send("pet:state", JSON.parse(snapshot));
|
||||
@@ -650,6 +654,8 @@ function overPetArea(x, y) {
|
||||
function setHovered(on) {
|
||||
if (on === hovered) return;
|
||||
hovered = on;
|
||||
log(`hover ${on ? "enter" : "leave"} pressed=${!!pressed} drag=${!!drag} overlay=${overlay?.anim || "-"}`);
|
||||
report();
|
||||
if (on) {
|
||||
// 只在「進入」時觸發一次;一次性動作或拖曳進行中不打斷
|
||||
if (!overlay && !drag) {
|
||||
@@ -689,15 +695,19 @@ document.addEventListener("mouseout", (e) => {
|
||||
setHovered(false);
|
||||
});
|
||||
|
||||
// 滑鼠按下/放開都寫進事件紀錄:這是「有沒有收到滑鼠事件」唯一的直接證據
|
||||
window.addEventListener("mousedown", (e) => {
|
||||
log(`mousedown b=${e.button} at ${e.clientX},${e.clientY} pressed=${!!pressed} drag=${!!drag}`);
|
||||
if (e.button === 0) {
|
||||
pressed = { x: e.clientX, y: e.clientY, sx: e.screenX, sy: e.screenY, moved: false };
|
||||
} else if (e.button === 2) {
|
||||
window.pet.send("pet:context-menu");
|
||||
}
|
||||
report();
|
||||
});
|
||||
|
||||
window.addEventListener("mouseup", (e) => {
|
||||
log(`mouseup b=${e.button} at ${e.clientX},${e.clientY} pressed=${!!pressed} moved=${!!pressed?.moved}`);
|
||||
if (e.button !== 0 || !pressed) return;
|
||||
const wasDrag = pressed.moved;
|
||||
pressed = null;
|
||||
@@ -728,6 +738,7 @@ window.pet.on("pet:drag-ended", () => {
|
||||
pressed = null;
|
||||
drag = null;
|
||||
canvas.classList.remove("grabbing");
|
||||
report();
|
||||
});
|
||||
|
||||
// 主程序切了點穿狀態:只負責換游標樣式
|
||||
|
||||
Reference in New Issue
Block a user