mirror of
https://github.com/swaywm/sway.git
synced 2026-04-06 07:15:44 -04:00
Remove now-unused "input" argument of cmd_results_new
Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))` applied to `cmd_results_new`. String usage constants have been converted from pointers to arrays when encountered. General handler format strings were sometimes modified to include the old input string, especially for unknown command errors.
This commit is contained in:
parent
6d392150a7
commit
2a684cad5f
131 changed files with 503 additions and 601 deletions
|
|
@ -10,16 +10,16 @@ struct cmd_results *seat_cmd_attach(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
if (!config->handler_context.seat_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "attach", "No seat defined");
|
||||
return cmd_results_new(CMD_FAILURE, "No seat defined");
|
||||
}
|
||||
|
||||
struct seat_attachment_config *attachment = seat_attachment_config_new();
|
||||
if (!attachment) {
|
||||
return cmd_results_new(CMD_FAILURE, "attach",
|
||||
return cmd_results_new(CMD_FAILURE,
|
||||
"Failed to allocate seat attachment config");
|
||||
}
|
||||
attachment->identifier = strdup(argv[0]);
|
||||
list_add(config->handler_context.seat_config->attachments, attachment);
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
static struct cmd_results *press_or_release(struct sway_cursor *cursor,
|
||||
char *action, char *button_str);
|
||||
|
||||
static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or "
|
||||
static const char expected_syntax[] = "Expected 'cursor <move> <x> <y>' or "
|
||||
"'cursor <set> <x> <y>' or "
|
||||
"'curor <press|release> <button[1-9]|event-name-or-code>'";
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
|
|||
int argc, char **argv) {
|
||||
if (strcasecmp(argv[0], "move") == 0) {
|
||||
if (argc < 3) {
|
||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||
return cmd_results_new(CMD_INVALID, expected_syntax);
|
||||
}
|
||||
int delta_x = strtol(argv[1], NULL, 10);
|
||||
int delta_y = strtol(argv[2], NULL, 10);
|
||||
|
|
@ -26,7 +26,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
|
|||
cursor_rebase(cursor);
|
||||
} else if (strcasecmp(argv[0], "set") == 0) {
|
||||
if (argc < 3) {
|
||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||
return cmd_results_new(CMD_INVALID, expected_syntax);
|
||||
}
|
||||
// map absolute coords (0..1,0..1) to root container coords
|
||||
float x = strtof(argv[1], NULL) / root->width;
|
||||
|
|
@ -35,7 +35,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
|
|||
cursor_rebase(cursor);
|
||||
} else {
|
||||
if (argc < 2) {
|
||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||
return cmd_results_new(CMD_INVALID, expected_syntax);
|
||||
}
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = press_or_release(cursor, argv[0], argv[1]))) {
|
||||
|
|
@ -43,7 +43,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor,
|
|||
}
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
||||
struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
||||
|
|
@ -53,18 +53,17 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
|||
}
|
||||
struct seat_config *sc = config->handler_context.seat_config;
|
||||
if (!sc) {
|
||||
return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
|
||||
return cmd_results_new(CMD_FAILURE, "No seat defined");
|
||||
}
|
||||
|
||||
if (config->reading || !config->active) {
|
||||
return cmd_results_new(CMD_DEFER, NULL, NULL);
|
||||
return cmd_results_new(CMD_DEFER, NULL);
|
||||
}
|
||||
|
||||
if (strcmp(sc->name, "*") != 0) {
|
||||
struct sway_seat *seat = input_manager_get_seat(sc->name);
|
||||
if (!seat) {
|
||||
return cmd_results_new(CMD_FAILURE, "cursor",
|
||||
"Failed to get seat");
|
||||
return cmd_results_new(CMD_FAILURE, "Failed to get seat");
|
||||
}
|
||||
error = handle_command(seat->cursor, argc, argv);
|
||||
} else {
|
||||
|
|
@ -77,7 +76,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
return error ? error : cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
||||
static struct cmd_results *press_or_release(struct sway_cursor *cursor,
|
||||
|
|
@ -89,14 +88,14 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
|
|||
} else if (strcasecmp(action, "release") == 0) {
|
||||
state = WLR_BUTTON_RELEASED;
|
||||
} else {
|
||||
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
|
||||
return cmd_results_new(CMD_INVALID, expected_syntax);
|
||||
}
|
||||
|
||||
char *message = NULL;
|
||||
button = get_mouse_button(button_str, &message);
|
||||
if (message) {
|
||||
struct cmd_results *error =
|
||||
cmd_results_new(CMD_INVALID, "cursor", message);
|
||||
cmd_results_new(CMD_INVALID, message);
|
||||
free(message);
|
||||
return error;
|
||||
} else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN
|
||||
|
|
@ -117,11 +116,10 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor,
|
|||
.delta_discrete = delta
|
||||
};
|
||||
dispatch_cursor_axis(cursor, &event);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
} else if (!button) {
|
||||
return cmd_results_new(CMD_INVALID, "curor",
|
||||
"Unknown button %s", button_str);
|
||||
return cmd_results_new(CMD_INVALID, "Unknown button %s", button_str);
|
||||
}
|
||||
dispatch_cursor_button(cursor, NULL, 0, button, state);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ struct cmd_results *seat_cmd_fallback(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
if (!config->handler_context.seat_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "fallback", "No seat defined");
|
||||
return cmd_results_new(CMD_FAILURE, "No seat defined");
|
||||
}
|
||||
|
||||
config->handler_context.seat_config->fallback =
|
||||
parse_boolean(argv[0], false);
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,19 +11,18 @@ struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) {
|
|||
return error;
|
||||
}
|
||||
if (!config->handler_context.seat_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "hide_cursor", "No seat defined");
|
||||
return cmd_results_new(CMD_FAILURE, "No seat defined");
|
||||
}
|
||||
|
||||
char *end;
|
||||
int timeout = strtol(argv[0], &end, 10);
|
||||
if (*end) {
|
||||
return cmd_results_new(CMD_INVALID, "hide_cursor",
|
||||
"Expected an integer timeout");
|
||||
return cmd_results_new(CMD_INVALID, "Expected an integer timeout");
|
||||
}
|
||||
if (timeout < 100 && timeout != 0) {
|
||||
timeout = 100;
|
||||
}
|
||||
config->handler_context.seat_config->hide_cursor_timeout = timeout;
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue