Repository navigation
Implement a touch screen backend #2949
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
Open
leolost2605
wants to merge
8
commits into
main
Choose a base branch
from
leolost/new-touchscreen-backend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+199
−46
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
58fb9d5
GestureBackend: Support different units
leolost2605 7e28394
Introduce RootTarget.get_distance
leolost2605 cfd702b
GestureController: Use new GestureTarget.get_distance
leolost2605 37699dc
GestureController: Map every backend to a single trigger
leolost2605 047fd14
Introduce TouchScreenSwipeBackend
leolost2605 42daadd
SwipeTrigger: Enable touch screen backend
leolost2605 43de8e9
GlobalTrigger: Use touch screen swipe backend
leolost2605 513f518
ToucheggBackend: Disable on mutter 49 for touchscreen swipe
leolost2605 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * Copyright 2025 elementary, Inc. (https://elementary.io) | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| * | ||
| * Authored by: Leonhard Kargl <leo.kargl@proton.me> | ||
| */ | ||
|
|
||
| #if HAS_MUTTER49 | ||
| private class Gala.TouchScreenSwipeBackend : Object, GestureBackend { | ||
| private const int DRAG_THRESHOLD_DISTANCE = 16; | ||
|
|
||
| public Clutter.Actor actor { get; construct; } | ||
|
|
||
| private Clutter.PanGesture gesture; | ||
| private Clutter.Orientation current_orientation; | ||
| private bool cancelled = false; | ||
|
|
||
| public TouchScreenSwipeBackend (Clutter.Actor actor) { | ||
| Object (actor: actor); | ||
| } | ||
|
|
||
| construct { | ||
| gesture = new Clutter.PanGesture (); | ||
| gesture.may_recognize.connect (on_may_recognize); | ||
| gesture.recognize.connect (on_pan_recognize); | ||
| gesture.pan_update.connect (on_pan_update); | ||
| gesture.end.connect (on_pan_end); | ||
| actor.add_action (gesture); | ||
| } | ||
|
|
||
| ~TouchScreenSwipeBackend () { | ||
| actor.remove_action (gesture); | ||
| } | ||
|
|
||
| public override void cancel_gesture () { | ||
| cancelled = true; | ||
| gesture.cancel (); | ||
| } | ||
|
|
||
| private bool on_may_recognize () { | ||
| var detected_gesture = new Gesture () { | ||
| type = TOUCHPAD_SWIPE, | ||
| direction = get_direction (), | ||
| fingers = (int) gesture.get_n_points (), | ||
| performed_on_device_type = TOUCHSCREEN_DEVICE | ||
| }; | ||
|
|
||
| return on_gesture_detected (detected_gesture, Clutter.get_current_event_time ()); | ||
| } | ||
|
|
||
| private GestureDirection get_direction () { | ||
| var delta = gesture.get_delta (); | ||
| current_orientation = delta.get_x ().abs () > delta.get_y ().abs () ? Clutter.Orientation.HORIZONTAL : Clutter.Orientation.VERTICAL; | ||
| switch (current_orientation) { | ||
| case HORIZONTAL: return RIGHT; | ||
| case VERTICAL: return DOWN; | ||
| default: return RIGHT; | ||
| } | ||
| } | ||
|
|
||
| private void on_pan_recognize () { | ||
| cancelled = false; | ||
|
|
||
| on_begin (PIXELS, get_used_distance (), Clutter.get_current_event_time ()); | ||
| } | ||
|
|
||
| private void on_pan_update () { | ||
| if (cancelled) { | ||
| return; | ||
| } | ||
|
|
||
| on_update (PIXELS, get_used_distance (), Clutter.get_current_event_time ()); | ||
| } | ||
|
|
||
| private void on_pan_end () { | ||
| if (cancelled) { | ||
| return; | ||
| } | ||
|
|
||
| on_end (PIXELS, get_used_distance (), Clutter.get_current_event_time ()); | ||
| } | ||
|
|
||
| private float get_used_distance () { | ||
| var distance = gesture.get_accumulated_delta (); | ||
| return current_orientation == HORIZONTAL ? distance.get_x () : distance.get_y (); | ||
| } | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.