swayfx icon indicating copy to clipboard operation
swayfx copied to clipboard

Workspace movement with touchpad gestures

Open ErikReider opened this issue 1 year ago • 11 comments

Switch between workspaces with touchpad gestures

https://github.com/WillPower3309/swayfx/assets/35975961/667d1420-be25-404c-a61e-2aa7db7c0178

TODO:

  • [x] Workspace logic
    • [x] Switch between fullscreen/non-fullscreen views
    • [x] Clip floating views to the output while switching
    • [x] Clip the floating views to the workspace bounds while switching
  • [x] Touchpad gestures
    • [x] Snap to the nearest workspace on release (without animations for now)
  • [x] Horizontal support
  • [x] Vertical support
  • [ ] ~Animations?~ (We should wait until animations have landed in master)
  • [x] Bounce back feedback (spring effect when trying to go past the last workspace)
  • [x] Bounce back ease-out
  • [x] Small but fast swipes should switch workspace
  • [ ] Configurables
    • [x] Threshold
    • [ ] Speed. The default probably needs some refinement as well
    • [ ] Needed speed
    • [x] wrap around workspaces
    • [x] Bounce back size in px (scaled)

To test:

bindworkspacegesture 4:horizontal
# bindworkspacegesture --inverted 4:horizontal
# bindworkspacegesture 4:vertical
# bindworkspacegesture --inverted 4:vertical

ErikReider avatar Jan 21 '24 13:01 ErikReider

Will respond to the implementation notes today when I take a deeper look! Great stuff Erik! I can probably get this working as an animation in an evening once it's in

WillPower3309 avatar Jan 25 '24 16:01 WillPower3309

Mind linking this PR to the issue for touchpad gestures? This should fix #142

WillPower3309 avatar Jan 25 '24 16:01 WillPower3309

Just to mention, nix build seems to be broken:

error: builder for '/nix/store/9sg0wwdj4wdkxskw6wjp2qh0mvcjrydn-sway-unwrapped-1.8.1.drv' failed with exit code 1;
       last 10 log lines:
       > [137/344] Compiling C object sway/sway.p/commands_blur_contrast.c.o
       > [138/344] Compiling C object sway/sway.p/commands_blur_radius.c.o
       > [139/344] Compiling C object sway/sway.p/commands_blur_saturation.c.o
       > [140/344] Compiling C object sway/sway.p/commands_border.c.o
       > [141/344] Compiling C object sway/sway.p/commands_blur_noise.c.o
       > [142/344] Compiling C object sway/sway.p/config_output.c.o
       > [143/344] Compiling C object sway/sway.p/commands_corner_radius.c.o
       > [144/344] Compiling C object sway/sway.p/commands_bind.c.o
       > [145/344] Compiling C object sway/sway.p/commands_client.c.o
       > ninja: build stopped: subcommand failed.
       For full logs, run 'nix log /nix/store/9sg0wwdj4wdkxskw6wjp2qh0mvcjrydn-sway-unwrapped-1.8.1.drv'.

ozwaldorf avatar Jan 26 '24 19:01 ozwaldorf

Just to mention, nix build seems to be broken:

error: builder for '/nix/store/9sg0wwdj4wdkxskw6wjp2qh0mvcjrydn-sway-unwrapped-1.8.1.drv' failed with exit code 1;
       last 10 log lines:
       > [137/344] Compiling C object sway/sway.p/commands_blur_contrast.c.o
       > [138/344] Compiling C object sway/sway.p/commands_blur_radius.c.o
       > [139/344] Compiling C object sway/sway.p/commands_blur_saturation.c.o
       > [140/344] Compiling C object sway/sway.p/commands_border.c.o
       > [141/344] Compiling C object sway/sway.p/commands_blur_noise.c.o
       > [142/344] Compiling C object sway/sway.p/config_output.c.o
       > [143/344] Compiling C object sway/sway.p/commands_corner_radius.c.o
       > [144/344] Compiling C object sway/sway.p/commands_bind.c.o
       > [145/344] Compiling C object sway/sway.p/commands_client.c.o
       > ninja: build stopped: subcommand failed.
       For full logs, run 'nix log /nix/store/9sg0wwdj4wdkxskw6wjp2qh0mvcjrydn-sway-unwrapped-1.8.1.drv'.

The errors here are:

p/desktop_render.c.o -c ../sway/desktop/render.c
../sway/desktop/render.c: In function 'adjust_box_to_workspace_offset':
../sway/desktop/render.c:102:9: error: 'box_coord' may be used uninitialized [-Werror=maybe-uninitialized]
  102 |         *box_coord -= ws_dimen * scroll_percent;
      |         ^~~~~~~~~~
../sway/desktop/render.c:88:14: note: 'box_coord' was declared here
   88 |         int *box_coord;
      |              ^~~~~~~~~
../sway/desktop/render.c:102:32: error: 'ws_dimen' may be used uninitialized [-Werror=maybe-uninitialized]
  102 |         *box_coord -= ws_dimen * scroll_percent;
      |                       ~~~~~~~~~^~~~~~~~~~~~~~~~
../sway/desktop/render.c:87:13: note: 'ws_dimen' was declared here
   87 |         int ws_dimen;
      |             ^~~~~~~~
In function 'adjust_damage_to_workspace_bounds',
    inlined from 'render_fullscreen_con' at ../sway/desktop/render.c:1985:3:
../sway/desktop/render.c:135:16: error: 'coord' may be used uninitialized [-Werror=maybe-uninitialized]
  135 |         *coord = round(-ws_dimen * scroll_percent);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../sway/desktop/render.c: In function 'render_fullscreen_con':
../sway/desktop/render.c:121:14: note: 'coord' was declared here
  121 |         int *coord;
      |              ^~~~~
In function 'adjust_damage_to_workspace_bounds',
    inlined from 'render_fullscreen_con' at ../sway/desktop/render.c:1985:3:
../sway/desktop/render.c:138:32: error: 'ws_dimen' may be used uninitialized [-Werror=maybe-uninitialized]
  138 |                         *coord += ws_dimen;
      |                                ^~
../sway/desktop/render.c: In function 'render_fullscreen_con':
../sway/desktop/render.c:120:13: note: 'ws_dimen' was declared here
  120 |         int ws_dimen;
      |             ^~~~~~~~
cc1: all warnings being treated as errors

WillPower3309 avatar Jan 26 '24 22:01 WillPower3309

Might have an idea of how to improve the config command syntax. Converting to draft

ErikReider avatar Jan 27 '24 22:01 ErikReider

Might have an idea of how to improve the config command syntax. Converting to draft

Maybe something like this:

bindgesture --invert fluid_swipe:3:horizontal workspace_switch

ErikReider avatar Jan 27 '24 22:01 ErikReider

Might have an idea of how to improve the config command syntax. Converting to draft

Maybe something like this:

bindgesture --invert fluid_swipe:3:horizontal workspace_switch

Looks good to me!

WillPower3309 avatar Feb 19 '24 23:02 WillPower3309

I'll wait with refining this until the sway 1.9 rebase is merged :)

ErikReider avatar Feb 22 '24 20:02 ErikReider

the rebase has rebased (adding comment to see progress in future)

also commenting for the same reason.

swwwee avatar May 04 '24 17:05 swwwee

Y'all don't need to comment here to get notifications, just creates spam. The right side panel has a button for notifications :)

ErikReider avatar May 05 '24 12:05 ErikReider

Rebased from master

ErikReider avatar May 06 '24 19:05 ErikReider