Fix window dragging allowing windows to disappear off right/bottom edges - #406
Merged
AllTerrainDeveloper merged 3 commits intoJul 23, 2026
Conversation
## Problem When dragging windows, the constraint logic only checked the window's top-left position (x, y) against the desktop boundaries, but did not account for the window's width and height. This allowed windows to be dragged almost completely off-screen to the right and bottom edges, with only a thin sliver remaining visible. The constraint checked: - x <= desktop.clientWidth - EDGE_MARGIN (doesn't account for window width) - y <= desktop.clientHeight - EDGE_MARGIN (doesn't account for window height) Since EDGE_MARGIN = 0, a window could be dragged to x = desktop.clientWidth, positioning its left edge at the desktop's right boundary, effectively hiding the entire window off-screen to the right. Same issue applied to the bottom edge. ## Solution Updated the drag constraint logic in src/window/pointer.ts (lines 235-236) to account for window dimensions, mirroring the resize constraint logic that was added in WordPress#399: Before: x = Math.max(EDGE_MARGIN, Math.min(x, desktop.clientWidth - EDGE_MARGIN)); y = Math.max(EDGE_MARGIN, Math.min(y, desktop.clientHeight - EDGE_MARGIN)); After: x = Math.max(EDGE_MARGIN, Math.min(x, desktop.clientWidth - win.element.offsetWidth - EDGE_MARGIN)); y = Math.max(EDGE_MARGIN, Math.min(y, desktop.clientHeight - win.element.offsetHeight - EDGE_MARGIN)); This ensures: - The window's right edge (x + width) cannot exceed desktop.clientWidth - The window's bottom edge (y + height) cannot exceed desktop.clientHeight - Windows remain fully visible and accessible during drag operations ## Context This is a follow-up fix to WordPress#399, which addressed the same issue for resize operations. The drag handler was using an older, simpler constraint that predated the resize fix and exhibited the same problem. The constraint now consistently prevents windows from disappearing during both drag and resize operations, while still allowing flush-edge positioning for snap gestures (since EDGE_MARGIN = 0). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Merged
AllTerrainDeveloper
pushed a commit
that referenced
this pull request
Jul 24, 2026
* Revert "Fix window dragging allowing windows to disappear off right/bottom edges (#406)" This reverts commit 3222c61. * fix(window): enforce drag boundaries and viewport reflow with grab margins - Define a 40px constant to ensure a clickable title bar area is always accessible. - Introduce utility to prevent windows from being dragged completely off-screen, allowing them to bleed off the left, right, and bottom edges while strictly locking the top edge. - Update to use for floating window movements within the desktop view. - Refactor in the window manager to smoothly recover and pull stranded off-screen windows back into bounds during browser viewport resizes. - Add robust unit test coverage in to verify clamping constraints and pointer move bounding logic.
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.
Follow up to issue #399 and PR: #402
Problem
When dragging windows, the constraint logic only checked the window's top-left position (x, y) against the desktop boundaries, but did not account for the window's width and height. This allowed windows to be dragged almost completely off-screen to the right and bottom edges, with only a thin sliver remaining visible.
The constraint checked:
Since EDGE_MARGIN = 0, a window could be dragged to x = desktop.clientWidth, positioning its left edge at the desktop's right boundary, effectively hiding the entire window off-screen to the right. Same issue applied to the bottom edge.
Solution
Updated the drag constraint logic in src/window/pointer.ts (lines 235-236) to account for window dimensions, mirroring the resize constraint logic that was added in #399:
Before:
Screen.Recording.2026-07-23.at.20.32.49.mov
x = Math.max(EDGE_MARGIN, Math.min(x, desktop.clientWidth - EDGE_MARGIN));
y = Math.max(EDGE_MARGIN, Math.min(y, desktop.clientHeight - EDGE_MARGIN));
After:
Screen.Recording.2026-07-23.at.20.29.45.mov
x = Math.max(EDGE_MARGIN, Math.min(x, desktop.clientWidth - win.element.offsetWidth - EDGE_MARGIN));
y = Math.max(EDGE_MARGIN, Math.min(y, desktop.clientHeight - win.element.offsetHeight - EDGE_MARGIN));
This ensures:
Context
This is a follow-up fix to #399, which addressed the same issue for resize operations. The drag handler was using an older, simpler constraint that predated the resize fix and exhibited the same problem.
The constraint now consistently prevents windows from disappearing during both drag and resize operations, while still allowing flush-edge positioning for snap gestures (since EDGE_MARGIN = 0).