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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Introduce GestureController #2258

wants to merge 4 commits into from

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:

@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
Copy link
Member

Looks very good. Feels so smooth, and the animation when closing multitasking view while the workspaces are switching is unbelievable. Looking forward merging this

One issue I noticed is when I switch from the last workspace I get frame drops (??)

2025-02-17.17-54-57.mp4

@lenemter
Copy link
Member

Also a new bug I noticed:

2025-02-17.18-23-14.mp4

The video suddenly ends because gala crashed when I dropped calculator window on a last workspace. Here's a backtrace:

#0  0x000070afe4e1eeb7 in g_type_check_instance_cast () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#1  0x000070afe456f69e in meta_workspace_remove_window (workspace=0x628557eff790, window=0x6285575b93a0) at ../src/core/workspace.c:415
#2  0x000070afe4568c10 in set_workspace_state (window=0x6285575b93a0, on_all_workspaces=0, workspace=0x628557f08c80) at ../src/core/window.c:4808
#3  0x000070afe4568f61 in meta_window_change_workspace_without_transients (window=0x6285575b93a0, workspace=0x628557f08c80)
    at ../src/core/window.c:4916
#4  0x000070afe4568ff8 in meta_window_change_workspace (window=0x6285575b93a0, workspace=0x628557f08c80) at ../src/core/window.c:4933
#5  0x0000628532a3e61e in gala_window_clone_drag_end (self=0x628557f086a0, destination=0x62855728e400) at ../src/Widgets/WindowClone.vala:622
#6  0x0000628532a3fcc5 in _gala_window_clone_drag_end_gala_drag_drop_action_drag_end
    (_sender=0x628557f9a270, actor=0x62855728e400, self=0x628557f086a0) at ../src/Widgets/WindowClone.vala:127
#7  0x000070afe4df72fa in g_closure_invoke () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x000070afe4e2690c in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x000070afe4e17591 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#10 0x000070afe4e177c1 in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x000070afe4e17883 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x000070afe4ff68eb in gala_drag_drop_action_finish (self=0x628557f9a270) at ../lib/DragDropAction.vala:450
#13 0x000070afe4ff4f1c in gala_drag_drop_action_on_event (self=0x628557f9a270, event=0x628557f007b0) at ../lib/DragDropAction.vala:278
#14 0x000070afe4ff4827 in _gala_drag_drop_action_on_event_clutter_actor_event (_sender=0x628557f086a0, event=0x628557f007b0, self=0x628557f9a270)
    at /home/leo/Projects/gala/build/DragDropAction.c:578
#15 0x000070afe42efe65 in _clutter_marshal_BOOLEAN__BOXEDv
    (closure=0x628557f46dd0, return_value=0x7ffd7ceaf140, instance=0x628557f086a0, args=0x7ffd7ceaf230, marshal_data=0x0, n_params=1, param_types=0x628556480a90) at clutter/clutter/clutter-marshal.c:130
#16 0x000070afe4e176bd in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#17 0x000070afe4e177c1 in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#18 0x000070afe4e17883 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#19 0x000070afe430ec13 in clutter_actor_event (actor=0x628557f086a0, event=0x628557f007b0, capture=0) at ../clutter/clutter/clutter-actor.c:11720
#20 0x000070afe437a69b in emit_event (event=0x628557f007b0, event_emission_chain=0x6285563eaf90) at ../clutter/clutter/clutter-stage.c:3271
#21 0x000070afe437cd07 in clutter_stage_emit_event (self=0x6285564ba0a0, event=0x628557f007b0) at ../clutter/clutter/clutter-stage.c:4425
#22 0x000070afe435c9d3 in emit_event (stage=0x6285564ba0a0, event=0x628557f007b0) at ../clutter/clutter/clutter-main.c:430
#23 0x000070afe435cd76 in _clutter_process_event_details (stage=0x6285564ba0a0, context=0x628556341590, event=0x628557f007b0)
    at ../clutter/clutter/clutter-main.c:597
#24 0x000070afe435ce57 in clutter_stage_process_event (stage=0x6285564ba0a0, event=0x628557f007b0) at ../clutter/clutter/clutter-main.c:633
#25 0x000070afe43753b3 in _clutter_stage_process_queued_events (stage=0x6285564ba0a0) at ../clutter/clutter/clutter-stage.c:794
#26 0x000070afe437f5a5 in handle_frame_clock_before_frame (frame_clock=0x628556280800, frame=0x628557e5c0b0, user_data=0x6285562801d0)
    at ../clutter/clutter/clutter-stage-view.c:795
#27 0x000070afe433fb2d in clutter_frame_clock_dispatch (frame_clock=0x628556280800, time_us=2307640657)
    at ../clutter/clutter/clutter-frame-clock.c:973
#28 0x000070afe433fe50 in frame_clock_source_dispatch (source=0x62855628f4e0, callback=0x0, user_data=0x0)
    at ../clutter/clutter/clutter-frame-clock.c:1032
#29 0x000070afe4ea25b5 in ??? () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x000070afe4f01717 in ??? () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#31 0x000070afe4ea2f77 in g_main_loop_run () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#32 0x000070afe4545341 in meta_context_run_main_loop (context=0x628555fd6400, error=0x7ffd7ceaf930) at ../src/core/meta-context.c:554
#33 0x00006285329a2e6d in gala_main (args=0x7ffd7ceaff88, args_length1=1) at ../src/Main.vala:88
#34 0x00006285329a3058 in main (argc=1, argv=0x7ffd7ceaff88) at ../src/Main.vala:29

@leolost2605 leolost2605 force-pushed the leolost/gesture-target branch from a054bd9 to a2e64a4 Compare February 21, 2025 15:21
@leolost2605
Copy link
Member Author

One issue I noticed is when I switch from the last workspace I get frame drops (??)

I think this might be a touchegg bug. I can only reproduce it using the touchpad backend (i.e. three fingers or whatever you've configured) and not when using the native scroll backend (two fingers).

Also I did some testing and got a touchpad swipe event in clutter a full 2 seconds before receiving the gesture event from touchegg...

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.

2 participants