Skip to content
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

Introduce GestureController #2258

Merged
merged 4 commits into from
Mar 2, 2025
Merged

Introduce GestureController #2258

merged 4 commits into from
Mar 2, 2025

Conversation

leolost2605
Copy link
Member

@leolost2605 leolost2605 commented Jan 28, 2025

This is ready for review now. It's a pretty big PR which is unfortunately necessary because it changes how the whole gesture propagation works. For an easier review you can go with the separate commits. Use rebase to merge.

An overview of the changes:
We go from a gesturetracker that only know about the current gesture and not "where we currently are", and which sends signals to gesturepropertytransitions which are created new for every gesture, to a gesturecontroller that keeps a persistent double progress which represents the state of the UI, that is affected by the gesture action that this gesturecontroller has. E.g. 0 for multitaskingview closed, 1 for it opened. 0 for first workspace, -1 for second, -2 for third etc. It hereby snaps to full integer values and can be bounded by upper and lower limits.
We also go from sending signals to propagating gesture events via a hierarchy of GestureTargets with the root being given to the controller.
Currently there are PropertyTargets that manipulate a property of a clutter actor, and ActorTargets that propagate the gesture events to direct descendants that are also actortargets. ActorTargets can also take other gesturetargets (e.g. PropertyTargets) and automatically propagate gesture events to them.
Since gesture targets can receive events from multiple controllers, events are connected to a string id (this will be required for #1733).
The advantages from this PR:

  • We have proper deceleration when a gesture ends (like in adwaita)
  • We got a big negative diff in the widgets (in theory also in general but not right now because gesturetracker and gesturepropertytransition can only be removed once everything uses gesturecontroller (will be pretty straight forward to do that but this PR is big enough as is))
  • We support interrupting gestures for opening the multitasking view
  • The widgets have already support for Switching workspaces in parallel to opening the multitasking view #1733 which is plug and play once a backend supports it. This support can already be seen when you switch workspaces in the multitaskingview via gestures pause somewhere and then use keybinds to close the multitaskingview)
  • The system is much more flexible and future proof (e.g. use the distance for finger tracking touchscreen gestures)
  • it already prepares for a deduplicated version of Introduce a DesktopWorkspaceSwitcher #2225
  • The cancel behavior is much more predictable now. We round to the integer and if we have enough speed we go to the next one in the direction we were going.

Follow up:

Fixes #2279

@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch from dd8f1c7 to f61800f Compare January 29, 2025 14:40
@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch 8 times, most recently from 8c012c3 to 85574e7 Compare February 10, 2025 21:30
@leolost2605 leolost2605 marked this pull request as ready for review February 10, 2025 21:48
@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch 2 times, most recently from b676115 to e1d561a Compare February 10, 2025 21:55
@leolost2605 leolost2605 requested a review from a team February 10, 2025 21:56
@leolost2605
Copy link
Member Author

Btw there are quite a few constants we can play with here.
For the animation that finishes the gesture we can change the spring params. What the values do is described here https://valadoc.org/libadwaita-1/Adw.SpringParams.html
There are also some velocity constants that can still be adjusted.

@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch 3 times, most recently from 5fe19be to 434b79a Compare February 16, 2025 13:31
@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch 2 times, most recently from 5938f46 to a054bd9 Compare February 16, 2025 14:43
@lenemter

This comment was marked as resolved.

@lenemter

This comment was marked as resolved.

@leolost2605

This comment was marked as resolved.

@leolost2605
Copy link
Member Author

Also a new bug I noticed:

@lenemter the visual bug is now fixed. I can reproduce the same crash in main and it's fixed by #2281.

So this should be ready again :)

@leolost2605 leolost2605 requested a review from lenemter February 24, 2025 19:27
@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch from c7cf495 to c2199ce Compare February 27, 2025 21:14
@lenemter

This comment was marked as resolved.

@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch from c2199ce to 0e2b17e Compare February 28, 2025 18:17
@leolost2605

This comment was marked as resolved.

Copy link
Member

@lenemter lenemter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. This feels fantastic, looking forward great stuff it allows us to do 🎉

@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch from 5f14483 to 60302fc Compare March 2, 2025 21:40
@leolost2605 leolost2605 merged commit 49ea47a into main Mar 2, 2025
5 checks passed
@leolost2605 leolost2605 deleted the leolost/gesture-target branch March 2, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't reveal dock when animations are disabled
2 participants