feat(grabandmove): snap windows to screen edges and corners while dragging - #50245
feat(grabandmove): snap windows to screen edges and corners while dragging#50245James Martin (jjamesmartiin) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
✅ PR intakeAll automated intake checks now pass. Thanks for the updates! Automated PR intake; PowerToys maintainers make final decisions. |
|
@microsoft-github-policy-service agree |
699a952 to
d835ec5
Compare
|
Hi! I've put together a short (~30 second) screen recording that walks through the snapping behavior end-to-end: the new Settings toggle, snapping to a half at the left/right edge, snapping to a quarter at the corners, and maximizing at the top edge. Please let me know if there's anything else you'd like me to include or if you have any feedback on the behavior or the settings wording — happy to make changes. Thanks for taking a look! power-toys-grab-and-move-snapping-demo-10mb.mp4 |
…gging Add release-to-edge-snap to GrabAndMove: - Arm edge-snap when dragging near the left/right/top work-area edge or a screen corner - Reuse the existing overlay to preview the target half/quarter/maximize region - On release: position the window directly into the half/quarter region (accounting for DWM frame bounds), or maximize at the top edge - Add snapToEdges setting (default on) with Settings UI toggle + localization
d835ec5 to
309202e
Compare
|
Quick note: I ran clang-format against |




Summary of the Pull Request
Adds release-to-edge window snapping to the GrabAndMove utility. When dragging windows using the modifier key (Alt/Win + Left Click), dragging near the left or right work-area edge previews and snaps the window to that screen half using direct window positioning. Dragging to a screen corner previews and snaps the window to that quarter, and dragging to the top work-area edge previews and maximizes the window.
PR Checklist
GrabAndMove_SnapToEdges.HeaderandGrabAndMove_SnapToEdges.DescriptiontoResources.resw.PowerToys.GrabAndMove.exe).Detailed Description of the Pull Request / Additional comments
Technical Implementation Details:
src/modules/GrabAndMove/GrabAndMove/main.cpp):ComputeSnapTarget()to calculate work-area boundaries (GetWorkAreaForPoint) and determine if the cursor is withinSNAP_EDGE_THRESHOLD(24px) of an edge or corner. Corners are checked first so quadrants take priority over the half-screen/maximize edge zones.RepositionOverlay) expands to preview the half-screen, quarter-screen, or full-screen target region with zeroed margins.SetWindowPos()so its visible frame (DWM extended frame bounds) matches the previewed half/quarter region, accounting for the invisible resize borders.ShowWindow(g_dragTarget, SW_MAXIMIZE).SnapToEdges(snapToEdgesbool property, defaulttrue) toGrabAndMoveProperties.cs.GrabAndMoveViewModel.csand UI toggle switch inGrabAndMovePage.xaml.Resources.resw(en-us).Validation Steps Performed
PowerToys.GrabAndMove.exewith explorer PID runner parameter.Alt+ left-click drag on target windows (e.g. Notepad, Edge, Command Prompt).Alt + Right-Clickwindow resize operations function normally without interference.Video Demonstration
power-toys-grab-and-move-snapping-demo-10mb.mp4