fix(fancyzones): Prevent stuck drag state and key swallowing (#410)#7
fix(fancyzones): Prevent stuck drag state and key swallowing (#410)#7crutkas wants to merge 3 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
|
The One coverage question: are there code paths where the dragged window survives but the user-physical-drag context is lost? A few that I think still leave
If the destroy event doesn't fire in those, the LL hook will keep swallowing Shift-combos until the next drag completes. Probably out of scope here, but worth a follow-up issue. |
- Subscribe to EVENT_OBJECT_DESTROY to clean up when dragged window dies mid-drag (root cause of microsoft#410) - Only suppress bare Shift key during drag, not all Shift+key combos - Require Win+Ctrl+Alt for quickLayoutSwitch during drag - Tag SwallowKey SendInput with dwExtraInfo Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b65f53a to
3393637
Compare
|
Rebased onto Agreed that (Also swapped the placeholder window-message identifier for a real GUID to match the rest of |
The EVENT_OBJECT_DESTROY win-event was subscribed and mapped to WM_PRIV_WINDOWDESTROYED by the consumer, but FancyZonesApp's dispatch switch had no case for it, so the event was dropped at default: break and the stuck-drag fix never ran. Forward EVENT_OBJECT_DESTROY to the callback alongside the other window-lifecycle events. When the dragged window is destroyed mid-drag, the WM_PRIV_WINDOWDESTROYED handler called MoveSizeEnd(), which snaps the now-dead HWND into a zone and corrupts layout state. Abort the drag instead via a new WindowMouseSnap::Abort() that tears down overlays/highlights/transparency without snapping, then resets the snapper and disables dragging state. Drop the redundant 'shift &&' term from the bare-Shift swallow: in a WH_KEYBOARD_LL hook GetAsyncKeyState(VK_SHIFT) is not yet set on the initial Shift-down, so the first press leaked through to the app. The explicit VK_LSHIFT/VK_RSHIFT vkCode check already scopes this to the bare Shift key. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Superseded by the upstream PR against microsoft/PowerToys: microsoft#48569 (rebased onto current main, builds/tests verified). Closing this intra-fork review PR. |
Summary
Fix FancyZones stuck drag state that permanently steals keyboard input (Shift+key combos and number keys).
Root Cause
When a window is destroyed mid-drag (Alt+F4, task kill, app crash),
EVENT_SYSTEM_MOVESIZEENDnever fires. The drag state machine stays inm_dragging = truepermanently, causing:IsDragging()quickLayoutSwitchfires on bare digit presses during (stuck) drag with no modifier requirementGenericKeyHookandMouseButtonsHookremain active system-wideChanges
A1: Subscribe to
EVENT_OBJECT_DESTROYand clean up drag stateEVENT_OBJECT_DESTROYto the WinEvent subscription arrayWM_PRIV_WINDOWDESTROYEDmessage handlerGetDraggedWindow()), forceMoveSizeEnd()MoveSizeEnd()always disable dragging state even ifm_windowMouseSnapperis nullA2: Narrow Shift+key swallowing to bare VK_SHIFT only
IsDragging() && shiftto only suppressVK_LSHIFT/VK_RSHIFTthemselvesA3: Require Win+Ctrl+Alt for quickLayoutSwitch during drag
A4: Tag
SwallowKeySendInput withdwExtraInfoHow to Reproduce (before fix)
Hello 123How to Verify (after fix)
Related Issues
PR Checklist