AltSnap icon indicating copy to clipboard operation
AltSnap copied to clipboard

Add swap window actions

Open gzaugg opened this issue 1 year ago • 5 comments

This adds window actions that allow swapping the current window's position and size with the window to the left, top, right, or bottom. You can configure keyboard shortcuts to activate these actions.

The actions are named SwapL, SwapT, SwapR, and SwapB for left, top, right, and bottom, respectively.

gzaugg avatar Oct 05 '24 15:10 gzaugg

Nice addition, thanks for taking the time to develop it.

RamonUnch avatar Oct 06 '24 07:10 RamonUnch

After using it for a while, I found it occasionally confusing. To improve clarity, I added a simple animation to make it easier to see what is happening. The animation can be controlled through two new configuration values in the advanced section (not exposed via the UI, as it's probably not worth the effort):

SwapAnimationSteps=10
; Specifies the number of animation steps when swapping windows (SwapL, SwapR,
; SwapT, SwapB). Set to 0 to disable the swap animation entirely.

SwapAnimationDelay=5
; Specifies the delay (in milliseconds) between each step of the swap animation.

gzaugg avatar Oct 07 '24 22:10 gzaugg

Sorry for another change to this. After using this feature on an older notebook, I realized how poor the performance can be when animating window resizing during swapping. I added an option to disable the resizing part of the animation (disabled by default). This results in a much smoother experience.

The updated settings are (acvanced section):

SwapAnimationSteps=10
; Specifies the number of animation steps when swapping windows (SwapL, SwapR,
; SwapT, SwapB). Set to 0 to disable the swap animation entirely.

SwapAnimationDelay=5
; Specifies the delay (in milliseconds) between each step of the swap animation.

SwapAnimateResize=0
; Specifies whether window resizing should be animated during window swapping.
; Note that, depending on the hardware and the application being swapped,
; this can result in poor performance. Set to 1 to enable, 0 to disable.

gzaugg avatar Oct 16 '24 07:10 gzaugg

Just a detail, I do not like much to use floating points for this kind of calculations. In the whole project there is zero floating point, I do not trust the arithmetic will always be pixel prefect. and I do not like to rely on fpu in general when not needed.

Could you modify your code so that it no longer relies on fpu?

RamonUnch avatar Dec 13 '24 06:12 RamonUnch

Otherwise I can do it myself, no problems

RamonUnch avatar Dec 13 '24 06:12 RamonUnch