Skip to content

🐞 Maximize across displays may apply stale vertical constraints on first attempt #1148

Description

@joaquinveraro

Bug Description

When Use screen with cursor is enabled, applying Maximize to a window that is currently on one display while the cursor is on another display may require two attempts.

The first attempt moves the window to the target display but leaves it only partially maximized. A second Maximize immediately afterward works correctly.

This appears to be specific to cross-display resizes. If any other Loop action is performed after moving the window to the target display, then Maximize works correctly on the next attempt.

Steps To Reproduce

  1. Enable Use screen with cursor.
  2. Disable window resize animations.
  3. Put a resizable window on display A.
  4. Move the cursor to display B.
  5. Open Loop and choose Maximize once.
  6. Observe that the window moves to display B but is not fully maximized vertically.
  7. Choose Maximize again.
  8. Observe that the second attempt correctly fills display B.

Expected Behavior

A single Maximize action should move the window to the display under the cursor and apply the final maximized frame in that same operation.

Actual Behavior

The first cross-display Maximize moves the window to the new display but can leave it vertically constrained. A second Maximize is required.

Reproduction Data

Loop version: 🧪 1.4.3 (1763)

Relevant settings:

useScreenWithCursor = 1
useSystemWindowManagerWhenAvailable = 0
animateWindowResizes = 0
moveCursorWithWindow = 0

For one reproduction with ChatGPT:

Loop computed and requested this target frame:

(-1074.0, -370.0, 1068.0, 1878.0)

Loop log:

[ResizeContext] Computed target frame - raw: (-1074.0, -370.0, 1068.0, 1878.0), ... for action: WindowAction(direction: Maximize, name: Maximizar)
[WindowEngine] Resizing Window(id: 60994, app: 'ChatGPT', title: 'ChatGPT) to (-1074.0, -370.0, 1068.0, 1878.0)

Immediately after the first failed resize, Accessibility reported the actual window frame as:

x=-1074 y=-156 w=1068 h=1450

So the X position and width were correct, but the vertical geometry remained constrained. This suggests the target frame calculation is correct and the issue occurs while applying the frame during the display transition.

Possible Cause

In the current code path, cross-display resizes use:

await window.setFrame(targetFrame, sizeFirst: willChangeScreens, resolvedProperties: resolvedProperties)

and Window.setFrame(..., sizeFirst: true) applies size before position, then size again.

My suspicion is that the first size assignment is constrained by the old display, and the immediate second size assignment may occur before macOS has fully updated the window's display membership.

A potentially more robust approach may be to move the window to the destination display, wait until ScreenUtility.screenContaining(window) resolves to the destination screen, and then apply the final target frame.

Additional Context

This is reproducible specifically when moving between displays and maximizing in the same action. If the window is already on the destination display, Maximize works on the first attempt.

I can provide more logs or test a patch if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions