Repository navigation
fix: make mouse-triggered wheel actions follow the trigger window safely - #181
Merged
Merged
Conversation
- Switch foreground focus to mouse-hover target window safely before dispatching actions - Verify target window existence, visibility, foreground alignment, and real PID at queue consumption - Guarantee enqueued action snapshot immutability via cloning - Invalidate pending execution session on gesture cancellation, disposal, new trigger, and host pause - Isolate mouse wheel sessions from keyboard long-press trigger flows - Add mock-isolated automated test suite in scratch/test_wheel_focus covering 18 scenarios
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
本 PR 是对 PR #178(原作者提交)的安全修订与完整收口版本,旨在解决鼠标在后台窗口 B 上触发手势轮盘时,确保使用窗口 B 的配置,并将窗口动作安全定向至窗口 B;在动作执行前对目标窗口与前台焦点进行多层校验,若目标失效或焦点离开则安全取消,避免误发给此前的前台旧窗口 A。
本提交保留了原 PR 的核心交互意图,同时修复了原方案中暴露的竞态、会话漂移和焦点一致性缺陷。
核心变更与修复细节
会话目标快照与一次性解析贯穿:
TargetWindowInfo与WheelFocusSession);快速松手与 UI 排队竞态保护:
目标保护延伸至队列消费入口:
ActionExecutor消费动作时(执行前)核验执行上下文有效性;入队动作快照不可变性:
action.Clone()快照,用户或 UI 在队列等待期间修改动作或子动作不影响已提交执行内容。鼠标触发与键盘触发严格隔离:
宿主暂停与会话失效关联:
App.ApplyPauseStateTransition,在暂停时同步调用GestureController.OnHostPaused(),永久作废已排队会话;恢复后旧动作不复活,新合法动作正常执行。无副作用测试套件:
scratch/test_wheel_focus中提供 18 项行为场景自动化验证;SendInput、按键释放、音效与窗口激活,并加入--test-instance与独立临时LOCALAPPDATA守卫。影响范围与兼容性说明
1.8.0-beta.5,未篡改版本号。边界与实机验证注意
LockSetForegroundWindow)及窗口权限约束。本修订采用保守激活机制(不注入 Alt、不篡改 Topmost),在执行前核验目标有效性与前台焦点对齐状态;当系统拒绝激活、焦点发生变化或会话失效时安全取消并丢弃动作,不进行无限重试,亦不强行抢回焦点。预期变动文件 (Changed Files: 15)
CHANGELOG.mdWinPieGestures/ActionExecutor.csWinPieGestures/ActiveWindowHelper.csWinPieGestures/App.xaml.csWinPieGestures/GestureController.csWinPieGestures/MouseEventArgs.csWinPieGestures/MouseHook.csWinPieGestures/RawMouseEventArgs.csWinPieGestures/WheelFocusSwitcher.csWinPieGestures/WinPieGestures.csprojWinPieGestures/WindowTaskbarHelper.csscratch/Directory.Build.propsscratch/test_wheel_focus/Program.csscratch/test_wheel_focus/README.mdscratch/test_wheel_focus/test_wheel_focus.csproj