Removed workspace_offset command
This commit is contained in:
parent
0c6d69b7fe
commit
44f54b9933
|
@ -226,7 +226,6 @@ sway_cmd cmd_unbindsym;
|
|||
sway_cmd cmd_unmark;
|
||||
sway_cmd cmd_urgent;
|
||||
sway_cmd cmd_workspace;
|
||||
sway_cmd cmd_workspace_offset;
|
||||
sway_cmd cmd_workspace_layout;
|
||||
sway_cmd cmd_ws_auto_back_and_forth;
|
||||
sway_cmd cmd_xwayland;
|
||||
|
|
|
@ -120,7 +120,6 @@ static const struct cmd_handler handlers[] = {
|
|||
{ "unbindsym", cmd_unbindsym },
|
||||
{ "workspace", cmd_workspace },
|
||||
{ "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth },
|
||||
{ "workspace_offset", cmd_workspace_offset },
|
||||
};
|
||||
|
||||
/* Config-time only commands. Keep alphabetized */
|
||||
|
|
|
@ -241,64 +241,3 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
|
|||
}
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
||||
// TODO: Replace with actual touchpad gesture implementation instead of command
|
||||
struct cmd_results *cmd_workspace_offset(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "workspace_offset", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
|
||||
struct sway_seat *seat = input_manager_get_default_seat();
|
||||
struct sway_workspace *focused_ws = seat_get_focused_workspace(seat);
|
||||
struct sway_output *output = focused_ws->output;
|
||||
|
||||
int visible_index = list_find(output->workspaces, focused_ws);
|
||||
if (visible_index == -1) {
|
||||
return cmd_results_new(CMD_FAILURE, "Active workspace not found");
|
||||
}
|
||||
|
||||
char *err;
|
||||
int dir = strtol(argv[0], &err, 10);
|
||||
float offset = 0;
|
||||
if (dir == 1) {
|
||||
offset = 0.01;
|
||||
} else if (dir == -1) {
|
||||
offset = -0.01;
|
||||
} else {
|
||||
return cmd_results_new(CMD_FAILURE, "Not a valid direction");
|
||||
}
|
||||
|
||||
// Limit the percent depending on if the workspace is the first/last or in
|
||||
// the middle somewhere.
|
||||
int min = -1, max = 1;
|
||||
if (visible_index + 1 >= output->workspaces->length) {
|
||||
max = 0;
|
||||
}
|
||||
if (visible_index == 0) {
|
||||
min = 0;
|
||||
}
|
||||
output->workspace_scroll_percent = MIN(max, MAX(min, output->workspace_scroll_percent + offset));
|
||||
|
||||
// Damage all outputs
|
||||
struct sway_output *soutput;
|
||||
wl_list_for_each(soutput, &root->all_outputs, link) {
|
||||
output_damage_whole(soutput);
|
||||
}
|
||||
|
||||
// Switch to the new workspace when the swipe has reached the new workspace
|
||||
if (output->workspace_scroll_percent > -1 &&
|
||||
output->workspace_scroll_percent < 1) {
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
size_t ws_index = wrap(visible_index + dir, output->workspaces->length);
|
||||
struct sway_workspace *new_ws = output->workspaces->items[ws_index];
|
||||
printf("Switched to workspace: %s\n", new_ws->name);
|
||||
workspace_switch(new_ws);
|
||||
seat_consider_warp_to_focus(seat);
|
||||
|
||||
// Reset the state
|
||||
output->workspace_scroll_percent = 0;
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue