Scroll windows when swiping on trackpad #63
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For each space, cache the virtual window x positions. That's the position the window would be if it were tiled infinitely in each direction (left and right) of the screen. These virtual positions can be negative. In reality, windows that extend past the visible screen are stashed in a one pixel wide margin.
Add a swipe.lua helper utility to detect touches on the trackpad, determine when a swipe gesture begins and ends, and calculate the average delta x and y position changes.
Note, we're unable to handle mouse scroll wheel movements because there is no begin or end event.
In a swipe handler, find the focused window and space and cache the screen geometry to use for future moved updates in the same swipe gesture. Calculate the new x position for each window in the space, bound them to not go past the screen margins, and use window:setTopLeft() to avoid the animation duration. Disable the window moved watcher while a swipe gesture is in progress, and windows are being scrolled.
When a swipe is done, if the focused window has been moved off screen, snap focus to the on screen window closest to the focused window. Then retile to ensure the focused window is completely on screen.