Unexpected behavior when moving a window with `moveToUnit`
cmpadden opened this issue · comments
System
Hammerspoon: 0.9.93
macOS Sonoma: 14.3
Problem
When a new window is created that extends past the screens edge, resizing to a rectangle will be truncated. For example, if a window is created and hangs n
pixels below the screen, it appears that the resulting window after calling moveToUnit
is n
pixels shorter than desired.
You can find a minimal example here, in which we subscribe to windowCreated
events and resize the window in the callback function.
hs.window.setFrameCorrectness = true
local window_filter_all = hs.window.filter.new()
window_filter_all:subscribe(hs.window.filter.windowCreated, function(window, app_name)
window:moveToUnit(RECT_CENTERED)
end)
This seems to primarily happen with Firefox.
See the included video demonstrating the behavior:
Screen.Recording.2024-04-06.at.10.45.51.PM.mov
As an aside, I've noticed that I sometimes have to call the move
method multiple times before the window is in the location and dimension that I desire. This Reddit user has described similar behavior:
https://www.reddit.com/r/hammerspoon/comments/xz3xvy/window_manipulation_functions_misbehaving/
This may be a similar issue - #2586 (comment)
Attempted to check and re-check the accessibility setting with no luck.
Also likely related to this - #2316 (comment). Will close this issue and follow this one instead.