Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency with moveOneScreenEast/West #3739

Open
justin-pierce opened this issue Jan 17, 2025 · 1 comment
Open

Inconsistency with moveOneScreenEast/West #3739

justin-pierce opened this issue Jan 17, 2025 · 1 comment

Comments

@justin-pierce
Copy link

justin-pierce commented Jan 17, 2025

Image

This is my monitor layout -- the right one is an odd shaped vertical monitor, but I'm pretty sure I had similar issues with regular vertical monitors in the past (no longer have them to test with).

-- move focused window to next monitor
hs.hotkey.bind({"ctrl"}, "Right", function()
    local win = hs.window.focusedWindow()
    win:moveOneScreenEast(false, true, 0)
end)

-- move focused window to previous monitor
hs.hotkey.bind({"ctrl"}, "Left", function()
    local win = hs.window.focusedWindow()
    win:moveOneScreenWest(false, true, 0)
end)

(to use these bindings, you'll need to unbind launch pad shortcuts, so you might want to instead test with different bindings)

When moving a maximized window to the vertical monitor, it will not properly adjust to maximize on the vertical monitor -- it leaves a gap at the bottom. If I move the window back to the horizontal monitor, it retains the gap proportionally (expected).

Image

If I change the layout to align the tops of both monitors, it makes the gap more pronounced (gap size seems to be correlated with how much the vertical monitor extends below the horizontal monitor).

Image

If I change the layout so that the bottoms align, it seems to fix it for maximized windows -- no gap. Not really a solution to the problem though.

Additionally, regardless of layout, windows that are not maximized get slightly shorter each time they move over. If you do it repeatedly you can see the gap getting larger.

Setting ensureInScreenBounds to false doesn't seem to help any.

This is on Hammerspoon 1.0.0 macOS 15.2, though I'm pretty sure this behavior happened, at least sometimes, on older versions of both Hammerspoon and macOS.

@justin-pierce
Copy link
Author

justin-pierce commented Jan 18, 2025

After looking at code and doing some testing, it does affect moveToScreen as well

My best guess is that it's related to the note in geometry.toUnitRect

--- Notes:
---  * The resulting unit rect is always clipped within `frame`'s bounds (via `hs.geometry:intersect()`); if `frame`
---    does not encompass this rect *no error will be thrown*, but the resulting unit rect won't be a direct match with this rect
---    (i.e. calling `:fromUnitRect(frame)` on it will return a different rect)

I'm guessing t=geometry.intersect(frame,t) is clipping it?

t=geometry.intersect(frame,t)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant