-
Notifications
You must be signed in to change notification settings - Fork 56
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
Workspace movement with touchpad gestures #269
Draft
ErikReider
wants to merge
38
commits into
master
Choose a base branch
from
workspace-movement
base: master
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.
Draft
Changes from 35 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
4e9e7c8
Initial implementation of workspace movement (without gestures)
ErikReider 0b86078
Fixed transition not compensating for workspace gaps
ErikReider 6552778
Fixed scroll not resetting to 0 when manually switching ws
ErikReider 0c6d69b
Added gesture support
ErikReider 44f54b9
Removed workspace_offset command
ErikReider 8440285
Only damage the focused output
ErikReider 8afad34
Render fullscreen containers over all layers
ErikReider 9e55168
Try switching workspace on gesture cancel instead of reset
ErikReider 8da7c50
Fixed popups not compensating for transition
ErikReider 3ad50f9
Clear transformed fullscreen damage
ErikReider 29c481d
Workspace code cleanup
ErikReider fdf764d
Added "Spring effect" when trying to swipe past limits
ErikReider 0676138
Added vertical gesture support
ErikReider 3480479
Moved to bindworkspacegesture instead of bindgesture
ErikReider 519bfc4
Added workspace_gesture_spring_size config option
ErikReider 0b521ab
Added workspace_gesture_wrap_around config option
ErikReider 1113e56
Added workspace_gesture_threshold config option
ErikReider 288b04d
Fixed gesture detecting every finger combination instead of the speci…
ErikReider 42fcd6c
Fixed fullscreen sometimes segfaulting
ErikReider 54daaa9
Updated swipe percentage calculation to also use avg_velocity
ErikReider 0a619a0
Use Ease-Out when swiping into the non-wrapped edges
ErikReider 83e0872
Fixed regular views rendering behind fullscreen ones + code cleanup
ErikReider bd3745c
Draw rect and shadow on "Spring effect" for fullscreen views
ErikReider 7214db9
Updated default threshold to 50%
ErikReider a12a8ea
Merged workspace_output_next and workspace_output_next_wrap
ErikReider 0da8221
Unset focus while swiping
ErikReider 1fedb1a
Reset swipe on other cursor rebase
ErikReider b491ac4
Code cleanuo: Simplified adjust_* functions
ErikReider 4f9ac2d
Fixed tracker value being updated even if percent isn't
ErikReider d7ca31c
Removed for-loop in render_workspace
ErikReider 5bb8877
Made fullscreen rendering a bit more clear
ErikReider 84c1b9c
Removed unneeded condition check in render_floating func
ErikReider 8193bb6
Fixed switch-statement nit
ErikReider dec948d
Moved easing functions into their own file
ErikReider 60ecc42
Added comment about workspace_gesture_parse reasoning
ErikReider 5ace6bb
Fixed compilation issues on Nix
ErikReider 358d649
Merge branch 'master' into workspace-movement
ErikReider 59c2b7a
Merge branch 'master' into workspace-movement
ErikReider 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 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 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 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 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 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,10 @@ | ||
#ifndef ANIMATION_UTILS_H | ||
#define ANIMATION_UTILS_H | ||
|
||
double lerp (double a, double b, double t); | ||
|
||
double ease_out_cubic (double t); | ||
|
||
// TODO: Add more easing functions in the future like ease_in and ease_in_out, etc... | ||
|
||
#endif |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -164,3 +164,76 @@ struct cmd_results *cmd_bindgesture(int argc, char **argv) { | |
struct cmd_results *cmd_unbindgesture(int argc, char **argv) { | ||
return cmd_bind_or_unbind_gesture(argc, argv, true); | ||
} | ||
|
||
/** | ||
* Parse and execute bindgesture or unbindgesture command. | ||
*/ | ||
static struct cmd_results *cmd_bind_or_unbind_workspacegesture(int argc, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a copy+paste of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as my other comment, why do we need a different file for this? |
||
char **argv, bool unbind) { | ||
int minargs = 1; | ||
char *bindtype = "bindgesture"; | ||
if (unbind) { | ||
bindtype = "unbindgesture"; | ||
} | ||
|
||
struct cmd_results *error = NULL; | ||
if ((error = checkarg(argc, bindtype, EXPECTED_AT_LEAST, minargs))) { | ||
return error; | ||
} | ||
struct sway_gesture_binding *binding = calloc(1, sizeof(struct sway_gesture_binding)); | ||
if (!binding) { | ||
return cmd_results_new(CMD_FAILURE, "Unable to allocate binding"); | ||
} | ||
binding->input = strdup("*"); | ||
|
||
bool warn = true; | ||
|
||
// Handle flags | ||
binding->flags |= BINDING_EXACT; | ||
while (argc > 0) { | ||
if (strcmp("--inverted", argv[0]) == 0) { | ||
binding->flags |= BINDING_INVERTED; | ||
} else if (strcmp("--no-warn", argv[0]) == 0) { | ||
warn = false; | ||
} else if (strncmp("--input-device=", argv[0], | ||
strlen("--input-device=")) == 0) { | ||
free(binding->input); | ||
binding->input = strdup(argv[0] + strlen("--input-device=")); | ||
} else { | ||
break; | ||
} | ||
argv++; | ||
argc--; | ||
} | ||
|
||
if (argc < minargs) { | ||
free(binding); | ||
return cmd_results_new(CMD_FAILURE, | ||
"Invalid %s command (expected at least %d " | ||
"non-option arguments, got %d)", bindtype, minargs, argc); | ||
} | ||
|
||
char* errmsg = NULL; | ||
if ((errmsg = workspace_gesture_parse(argv[0], &binding->gesture))) { | ||
free(binding); | ||
struct cmd_results *final = cmd_results_new(CMD_FAILURE, | ||
"Invalid %s command (%s)", | ||
bindtype, errmsg); | ||
free(errmsg); | ||
return final; | ||
} | ||
|
||
if (unbind) { | ||
return gesture_binding_remove(binding, argv[0]); | ||
} | ||
binding->command = NULL; | ||
return gesture_binding_add(binding, argv[0], warn); | ||
} | ||
|
||
struct cmd_results *cmd_bindworkspacegesture(int argc, char **argv) { | ||
return cmd_bind_or_unbind_workspacegesture(argc, argv, false); | ||
} | ||
|
||
struct cmd_results *cmd_unbindworkspacegesture(int argc, char **argv) { | ||
return cmd_bind_or_unbind_workspacegesture(argc, argv, true); | ||
} |
This file contains 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 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,49 @@ | ||
#define _POSIX_C_SOURCE 200809L | ||
#include "sway/commands.h" | ||
#include "sway/config.h" | ||
#include "util.h" | ||
|
||
struct cmd_results *cmd_ws_gesture_spring_size(int argc, char **argv) { | ||
struct cmd_results *error = NULL; | ||
if ((error = checkarg(argc, "workspace_gesture_spring_size", EXPECTED_EQUAL_TO, 1))) { | ||
return error; | ||
} | ||
|
||
char *inv; | ||
int value = strtol(argv[0], &inv, 10); | ||
if (*inv != '\0' || value < 0 || value > 250) { | ||
return cmd_results_new(CMD_FAILURE, "Invalid size specified"); | ||
} | ||
|
||
config->workspace_gesture_spring_size = value; | ||
|
||
return cmd_results_new(CMD_SUCCESS, NULL); | ||
} | ||
|
||
struct cmd_results *cmd_ws_gesture_wrap_around(int argc, char **argv) { | ||
struct cmd_results *error = NULL; | ||
if ((error = checkarg(argc, "workspace_gesture_wrap_around", EXPECTED_EQUAL_TO, 1))) { | ||
return error; | ||
} | ||
|
||
config->workspace_gesture_wrap_around = parse_boolean(argv[0], true); | ||
|
||
return cmd_results_new(CMD_SUCCESS, NULL); | ||
} | ||
|
||
struct cmd_results *cmd_ws_gesture_threshold(int argc, char **argv) { | ||
struct cmd_results *error = NULL; | ||
if ((error = checkarg(argc, "workspace_gesture_threshold", EXPECTED_EQUAL_TO, 1))) { | ||
return error; | ||
} | ||
|
||
char *err; | ||
float val = strtof(argv[0], &err); | ||
if (*err || val < 0.1f || val > 0.9f) { | ||
return cmd_results_new(CMD_INVALID, "workspace_gesture_threshold float invalid. " | ||
"Should be between 0.1 and 0.9"); | ||
} | ||
config->workspace_gesture_threshold = val; | ||
|
||
return cmd_results_new(CMD_SUCCESS, NULL); | ||
} |
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.
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.
Just a copy+paste of the
gesture_parse
functionThere 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.
why not just use
gesture_parse
? I see we add some gesture types but it doesn't look like they have any implications in thegesture_tracker_end
functionThere 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 couldn't find a good enough syntax for the new command that fit into the
bind_gesture
s parser so I needed to create a new one with fewer checks :/