-
Notifications
You must be signed in to change notification settings - Fork 593
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
Possibly identified the cause of window moving/sizing issues (seems due to animation timing and using move/size independently) #3731
Comments
Bueller? Bueller? |
Do you have an example of the issues you mention? Or perhaps can you share the code you're using? I use hs as my primary/only window manager and don't experience any issues, so curious. Perhaps there's something I can help spot? |
Can you try my above code without the delay and see if it moves as you expect? You need to make sure the window moves a long distance or else it will appear to work correctly. For instance, if you have a 4K screen, place the window off the lower-right of your screen, basically as far from the upper-left corner as you can get it. Then use the move and size calls to move it to the upper left corner, maybe 1/8th the screen width and height. (It's even easier if you have multiple monitors.) The point is it has to move a long-enough distance to make sure the animations from the first call are not yet completed when the second call starts. That's the issue, and why the pause 'fixes' it. Lemme know if you can repro it that way. |
@minusfive, did you give it a try? |
@MarqueIV, no, sorry, I'm busy. But I did quickly record a video for you of things working fine for me with animation and without delay. I use a 5K screen (5125 x 2160): Screen.Recording.2025-01-16.at.01.44.49.movYou can peruse my custom WindowManager spoon here, in case it helps: https://github.com/minusfive/dotfiles/blob/main/.config/hammerspoon/Spoons/WindowManager.spoon/init.lua Top level I'd suggest trying |
Just watched your video. I can see that working fine because it's not doing the resizing which is what causes the actual problem. Your video looks like it's only doing moves. Can you change it so it's resizing from a quarter to a half or full screen to centered that kind of thing. I'll also try out your spoon when I'm back in front of my computer. |
It is resizing, I’m just doing it too quickly. |
@MarqueIV here's a new video: Screen.Recording.2025-01-16.at.10.00.35.mov |
@MarqueIV did that help? |
No, I'm still seeing the issue I mentioned. Not sure why/what's going on on my machine, but a few things... my animations aren't as fast as yours. Not sure if you tweaked your mac to reduce their times in user defaults. But secondly, again, when I call the move/resize via a keyboard shortcut and it has a long way to go, one of the two doesn't complete. I have to re-trigger it a second time. That is, unless I do what I said above... separate the move from the resize and put a delay between them long enough to account for the animation. Any thoughts on why I'm seeing this and you're not? I can make a video showing this if you think it'll help, although it'll only reveal what I already explained. |
Not sure if this makes a difference, but can you try toggling quickly between quarters, halves, thirds, etc.? i.e. top-left, then bottom half, then top-right-third, then bottom left, etc. I do see yours are resizing, but only in one dimension. Not sure if moving and resizing in two dimensions is part of it. Also, I have multiple monitors so my windows have a lot farther than yours do to get from one side to the other. (My desktop is 8960 wide by 4,124 high across them all.) Another thing is HammerSpoon isn't respecting its own animation settings so maybe something there too has changed. No idea. Again, trying to think of any other things here that could be the cause. Really frustrating, although the workaround... well... works! |
Won't be able to reply for a few days, but vertical movement/resizing isn't problematic in my experience either. Will try and record at some point when I have a chance. You can tweak the animation speed with https://www.hammerspoon.org/docs/hs.window.html#animationDuration |
There seems to be an issue with setFrame, the grid-related functions and anything else related to window moving/sizing, and I think I've identified the issue as being related to the new os animations.
Specifically, it seems if you attempt to move/size a window while there's an existing animation, that action gets interrupted with the new call, thus the window isn't moved/sized correctly.
The hack I've come up with to get around this is rather than this....
I now do this...
where 0.25 seconds is usually enough to ensure the move animation happens completely before the resize operation. (You can reverse the order and you'll have the same effect.)
I've also seen cases where moves requiring longer distances equally require a longer time to animate, but the above seems to work for my particular use-case.
I'm somewhat confident this is the issue as when I reduce the delay, say down to 0.1 seconds (any value less than the needed animation), windows don't end up where they're supposed to be. It's also incredibly subtle if you're right at the limit of the animation as it can seem the sizing is only a few pixels off, when in reality, the correct values were set, it was just interrupted right before it was completely animated into place/size.
As I said, I have this workaround, but I'm not crazy about it as now there are essentially two animations that happen when moving/sizing windows, but at least they end up where they're supposed to be.
The text was updated successfully, but these errors were encountered: