Skip to content

Commit

Permalink
Scroll windows when swiping on trackpad
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mogenson committed Jan 12, 2025
1 parent 68765b8 commit 1700ec5
Show file tree
Hide file tree
Showing 2 changed files with 361 additions and 46 deletions.
Loading

0 comments on commit 1700ec5

Please sign in to comment.