aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/seat
diff options
context:
space:
mode:
authorM Stoeckl <code@mstoeckl.com>2019-01-10 18:27:21 -0500
committerM Stoeckl <code@mstoeckl.com>2019-01-14 08:05:29 -0500
commit2a684cad5fc8e12a8e47a7fd00e2b7c66b43afb0 (patch)
tree56332b9c150459beb5aef94605372ef179ec8854 /sway/commands/seat
parent6d392150a72ecc3b69fcfb48865f625e2c7b79d6 (diff)
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.
Diffstat (limited to 'sway/commands/seat')
-rw-r--r--sway/commands/seat/attach.c6
-rw-r--r--sway/commands/seat/cursor.c30
-rw-r--r--sway/commands/seat/fallback.c4
-rw-r--r--sway/commands/seat/hide_cursor.c7
4 files changed, 22 insertions, 25 deletions
diff --git a/sway/commands/seat/attach.c b/sway/commands/seat/attach.c
index 0fb17f1d..1e509a58 100644
--- a/sway/commands/seat/attach.c
+++ b/sway/commands/seat/attach.c
@@ -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);
}
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c
index 8d9e426a..4f805b22 100644
--- a/sway/commands/seat/cursor.c
+++ b/sway/commands/seat/cursor.c
@@ -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);
}
diff --git a/sway/commands/seat/fallback.c b/sway/commands/seat/fallback.c
index 8f1ab12c..0330c353 100644
--- a/sway/commands/seat/fallback.c
+++ b/sway/commands/seat/fallback.c
@@ -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);
}
diff --git a/sway/commands/seat/hide_cursor.c b/sway/commands/seat/hide_cursor.c
index 343573b5..3bfce697 100644
--- a/sway/commands/seat/hide_cursor.c
+++ b/sway/commands/seat/hide_cursor.c
@@ -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);
}