-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[WIP] Implement touch gestures using libtouch #3428
base: master
Are you sure you want to change the base?
Conversation
I am starting to come to the conclusion that I have no idea what I'm doing right now. Not sure I understand how the configuration parsing works, and I don't know how to extend it to support the syntax of #1904. I've done what i think looks correct-ish, but sway still says |
So implementing the syntax in #1904 is going to have some challenges with the current config parser. It predates the generic code blocks PR I'd propose the following instead:
Some thoughts for the above syntax:
(Also, note some commands in the example in #1904 like Hopefully, that helps iron out structure. As for (Side note: the |
Sorry about the chaos above. Tried to rebase my local branch to upstream master, but I messed it up big time. It's fixed now, anyway. It even compiles correctly when libtouch is installed. Somewhere hidden in these commits are my commits. Oops. Thanks @RedSoxFan for the help with the structure! Should the gestures be mode-specific? Should they be able to be both mode-specific and mode-agnostic? |
Depending on what your remotes are, you may need to alter the commands, but the following should fix the commit history
I think the gestures can be mode-agnostic. You can bind the same gesture to different commands in different modes though. |
I'm just going to leave this here as something to keep in mind when working on the PR: |
Now it's crashing with some xcb errors that I have no understanding of. Yet. The following config is parseable
}` Am I checking for complete gestures in the right place? In cursor.c, after updating the gestures? |
If you are getting that from the debug log, it's probably unrelated and harmless. You probably want
The location is fine. However, this current data structures do not take into account seats or modes. Each action of a gesture could occur on a different seat and the command will execute on the seat that performed the last action. With the current structure of libtouch, it's probably going to be really hard to account for either since there will have to be multiple engines and a gesture is tied to a single engine. Also, do not pass the focused container to
Although the final product should have well divided commits with good commit messages, WIP commits are fine for now. This will need some squashing/fix-ups later on anyway and you can reword the final commits then. |
Is it reasonable to attach the engine to the sway_seat struct, and simply deep-copy it from the config for each seat, or is that too lazy a solution? |
Take a look at how we track xkb state for inspiration. |
Re-emphasizing the importance of the style guide - also applies to the code in libtouch, if you want to upstream that. |
Rotation is still broken but regions, pinch, swipe and n-touches should work. Unless I've messed up git again. It works on my machine :) I've had a lot of more pressing matters to attend to, and that will probably continue to be the case at least until summer. Completing courses turns out to require participation; who would've thought? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review the style guide. There are several style issues including a lot of unneeded blank lines, lines that only have tabs, mixed tabs/spaces, removed/added lines that did not need to be touched, lines that are too long, missing whitespace around if/arguments/etc, and several others. I pointed out some, but there are too many to comment on all of them.
Unfortunately, I cannot comment on the functionality as I don't have the hardware to test with. Hopefully, someone else can help with that.
Also, please rebase against master instead of merging master into the branch for a cleaner commit history.
Oh and the commands will need to be documented
include/sway/config.h
Outdated
@@ -53,7 +53,6 @@ struct sway_binding { | |||
uint32_t modifiers; | |||
char *command; | |||
}; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you readd this blank line?
include/sway/config.h
Outdated
struct libtouch_target *target; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line
include/sway/config.h
Outdated
@@ -507,7 +521,8 @@ struct sway_config { | |||
list_t *command_policies; | |||
list_t *feature_policies; | |||
list_t *ipc_policies; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra tab on blank line
include/sway/input/cursor.h
Outdated
@@ -36,6 +36,8 @@ struct sway_cursor { | |||
struct wl_listener axis; | |||
struct wl_listener frame; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line
meson.build
Outdated
@@ -58,6 +59,7 @@ xcb = dependency('xcb', required: get_option('xwayland')) | |||
math = cc.find_library('m') | |||
rt = cc.find_library('rt') | |||
git = find_program('git', native: true, required: false) | |||
libtouch = dependency('libtouch') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency is duplicated
sway/input/cursor.c
Outdated
struct libtouch_gesture *complete; | ||
struct gesture_config *cfg; | ||
int idx; | ||
cfg = (struct gesture_config*) config->gesture_configs->items[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unused
sway/input/cursor.c
Outdated
|
||
static void handle_gestures(struct libtouch_progress_tracker *tracker, struct sway_seat *seat) { | ||
struct libtouch_gesture *complete; | ||
struct gesture_config *cfg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfg
and idx
can be moved inside the while
to where they are used
sway/input/cursor.c
Outdated
execute_command(cfg->command, seat, NULL); | ||
} | ||
} else { | ||
sway_log(SWAY_DEBUG, "Gesture unbound!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a SWAY_ERROR
as it should not occur
sway/input/cursor.c
Outdated
@@ -350,16 +381,22 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { | |||
seat->touch_x = lx; | |||
seat->touch_y = ly; | |||
|
|||
libtouch_progress_register_touch(cursor->gesture_tracker, event->time_msec, | |||
event->touch_id, LIBTOUCH_TOUCH_DOWN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: do not line up the arguments, just ident
@@ -507,7 +521,8 @@ struct sway_config { | |||
list_t *command_policies; | |||
list_t *feature_policies; | |||
list_t *ipc_policies; | |||
|
|||
|
|||
struct libtouch_engine *gesture_engine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing where this is free'd/deinitialized. Also, is the engine reusable between config reloads? If so, it should be moved to sway_server
. If not, it is fine here.
@grahnen Are you still working on this? I'm willing to help to get this ready for merging... |
@freswa Unfortunately not. I had to finish my studies, and got rid of my touchscreen PC. Feel free to take over! |
Implementing touch gesture recognition through libtouch, for now at https://github.com/grahnen/libtouch
I've begun doing what I think is correct, but I am not very well versed in the inner workings of sway, so feel free to correct me if I'm doing something wrong.