diff --git a/include/sway/commands.h b/include/sway/commands.h index 4f2f16a9..baa893ce 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -230,6 +230,7 @@ sway_cmd cmd_urgent; sway_cmd cmd_workspace; sway_cmd cmd_workspace_layout; sway_cmd cmd_ws_auto_back_and_forth; +sway_cmd cmd_ws_gesture_spring_size; sway_cmd cmd_xwayland; sway_cmd bar_cmd_bindcode; diff --git a/include/sway/config.h b/include/sway/config.h index a2d39353..bc329df6 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -507,6 +507,8 @@ struct sway_config { bool titlebar_separator; bool scratchpad_minimize; + int workspace_gesture_spring_size; + list_t *layer_criteria; char *swaynag_command; diff --git a/sway/commands.c b/sway/commands.c index 461a1e74..a968d4f0 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -122,6 +122,7 @@ static const struct cmd_handler handlers[] = { { "unbindworkspacegesture", cmd_unbindworkspacegesture }, { "workspace", cmd_workspace }, { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, + { "workspace_gesture_spring_size", cmd_ws_gesture_spring_size }, }; /* Config-time only commands. Keep alphabetized */ diff --git a/sway/commands/workspace_gesture.c b/sway/commands/workspace_gesture.c new file mode 100644 index 00000000..ec0bfcd8 --- /dev/null +++ b/sway/commands/workspace_gesture.c @@ -0,0 +1,20 @@ +#define _POSIX_C_SOURCE 200809L +#include "sway/commands.h" +#include "sway/config.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); +} diff --git a/sway/config.c b/sway/config.c index 0203080c..1f9f0f70 100644 --- a/sway/config.c +++ b/sway/config.c @@ -368,6 +368,8 @@ static void config_defaults(struct sway_config *config) { config->titlebar_separator = true; config->scratchpad_minimize = false; + config->workspace_gesture_spring_size = 50; + if (!(config->layer_criteria = create_list())) goto cleanup; // The keysym to keycode translation diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 5c04fdb4..4ed91f96 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -1136,7 +1136,8 @@ void update_workspace_scroll_percent(struct sway_seat *seat, int gesture_percent // TODO: Make configurable? // Visualized to the user that this is the last / first workspace by // allowing a small swipe, a "Spring effect" - float spring_limit = (float) 50 / output->width * output->wlr_output->scale; + float spring_limit = (float) config->workspace_gesture_spring_size / + output->width * output->wlr_output->scale; // Make sure that the limit is always smaller than the threshold spring_limit = MIN(THRESHOLD, spring_limit); // Limit the percent depending on if the workspace is the first/last or in diff --git a/sway/meson.build b/sway/meson.build index f0f26346..8ccdb20d 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -127,7 +127,7 @@ sway_sources = files( 'commands/set.c', 'commands/shadow_blur_radius.c', 'commands/shadow_color.c', - 'commands/shadow_offset.c', + 'commands/shadow_offset.c', 'commands/shadow_inactive_color.c', 'commands/shadows.c', 'commands/shadows_on_csd.c', @@ -149,6 +149,7 @@ sway_sources = files( 'commands/unmark.c', 'commands/urgent.c', 'commands/workspace.c', + 'commands/workspace_gesture.c', 'commands/workspace_layout.c', 'commands/ws_auto_back_and_forth.c', 'commands/xwayland.c', diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 24db1b38..7f448fec 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -588,6 +588,10 @@ runtime. ``` +*workspace_gesture_spring_size* + Adjusts the workspace gestures spring size. Can use values between + 0 (disabled) and 100 while 50 is the default value. + *client.background* This command is ignored and is only present for i3 compatibility.