mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
Have commands return cmd_results on the stack
sway commands are implemented using functions that return an error code and (if the function was not successful) an error string. The two are bundled together by the type `struct cmd_results`. This patch alters the command handler prototype so that the cmd_results objects are returned by value (on the stack), instead of by a pointer to a heap allocated instance of a cmd_results. The latter method had the flaw that, if the heap allocation of the cmd_results object failed, the exact return code would be lost. Furthermore, for some command handlers (such as those in sway/commands/output), returning NULL signified success, so an allocation failure could lead to an ignored error. This change prevents both classes of errors.
This commit is contained in:
parent
aa8fe58421
commit
221a8b40de
150 changed files with 667 additions and 659 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
struct sway_container;
|
struct sway_container;
|
||||||
|
|
||||||
typedef struct cmd_results *sway_cmd(int argc, char **argv);
|
typedef struct cmd_results sway_cmd(int argc, char **argv);
|
||||||
|
|
||||||
struct cmd_handler {
|
struct cmd_handler {
|
||||||
char *command;
|
char *command;
|
||||||
|
|
@ -43,7 +43,7 @@ enum expected_args {
|
||||||
EXPECTED_EQUAL_TO
|
EXPECTED_EQUAL_TO
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_results *checkarg(int argc, const char *name,
|
bool checkarg(struct cmd_results *error, int argc, const char *name,
|
||||||
enum expected_args type, int val);
|
enum expected_args type, int val);
|
||||||
|
|
||||||
struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
|
struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
|
||||||
|
|
@ -63,24 +63,24 @@ list_t *execute_command(char *command, struct sway_seat *seat,
|
||||||
*
|
*
|
||||||
* Do not use this under normal conditions.
|
* Do not use this under normal conditions.
|
||||||
*/
|
*/
|
||||||
struct cmd_results *config_command(char *command, char **new_block);
|
struct cmd_results config_command(char *command, char **new_block);
|
||||||
/**
|
/**
|
||||||
* Parse and handle a sub command
|
* Parse and handle a sub command
|
||||||
*/
|
*/
|
||||||
struct cmd_results *config_subcommand(char **argv, int argc,
|
struct cmd_results config_subcommand(char **argv, int argc,
|
||||||
struct cmd_handler *handlers, size_t handlers_size);
|
struct cmd_handler *handlers, size_t handlers_size);
|
||||||
/*
|
/*
|
||||||
* Parses a command policy rule.
|
* Parses a command policy rule.
|
||||||
*/
|
*/
|
||||||
struct cmd_results *config_commands_command(char *exec);
|
struct cmd_results config_commands_command(char *exec);
|
||||||
/**
|
/**
|
||||||
* Allocates a cmd_results object.
|
* Fills in and returns a cmd_results object.
|
||||||
*/
|
*/
|
||||||
struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...);
|
struct cmd_results cmd_results_new(enum cmd_status status, const char *error, ...);
|
||||||
/**
|
/**
|
||||||
* Frees a cmd_results object.
|
* Frees the contents of a cmd_results object.
|
||||||
*/
|
*/
|
||||||
void free_cmd_results(struct cmd_results *results);
|
void free_cmd_results(struct cmd_results results);
|
||||||
/**
|
/**
|
||||||
* Serializes a list of cmd_results to a JSON string.
|
* Serializes a list of cmd_results to a JSON string.
|
||||||
*
|
*
|
||||||
|
|
@ -88,7 +88,7 @@ void free_cmd_results(struct cmd_results *results);
|
||||||
*/
|
*/
|
||||||
char *cmd_results_to_json(list_t *res_list);
|
char *cmd_results_to_json(list_t *res_list);
|
||||||
|
|
||||||
struct cmd_results *add_color(char *buffer, const char *color);
|
struct cmd_results add_color(char *buffer, const char *color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Move this function and its dependent functions to container.c.
|
* TODO: Move this function and its dependent functions to container.c.
|
||||||
|
|
|
||||||
105
sway/commands.c
105
sway/commands.c
|
|
@ -16,8 +16,9 @@
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
// Returns error object, or NULL if check succeeds.
|
// Returns true and sets error object, or false if check succeeds.
|
||||||
struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val) {
|
bool checkarg(struct cmd_results *error, int argc, const char *name,
|
||||||
|
enum expected_args type, int val) {
|
||||||
const char *error_name = NULL;
|
const char *error_name = NULL;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EXPECTED_AT_LEAST:
|
case EXPECTED_AT_LEAST:
|
||||||
|
|
@ -35,11 +36,13 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type
|
||||||
error_name = "";
|
error_name = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return error_name ?
|
if (error_name) {
|
||||||
cmd_results_new(CMD_INVALID, "Invalid %s command "
|
*error = cmd_results_new(CMD_INVALID, "Invalid %s command "
|
||||||
"(expected %s%d argument%s, got %d)",
|
"(expected %s%d argument%s, got %d)", name, error_name,
|
||||||
name, error_name, val, val != 1 ? "s" : "", argc)
|
val, val != 1 ? "s" : "", argc);
|
||||||
: NULL;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep alphabetized */
|
/* Keep alphabetized */
|
||||||
|
|
@ -230,8 +233,15 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
struct criteria *criteria = criteria_parse(head, &error);
|
struct criteria *criteria = criteria_parse(head, &error);
|
||||||
if (!criteria) {
|
if (!criteria) {
|
||||||
list_add(res_list,
|
struct cmd_results *res = malloc(sizeof(struct cmd_results));
|
||||||
cmd_results_new(CMD_INVALID, "%s", error));
|
if (!res) {
|
||||||
|
sway_log(SWAY_ERROR,
|
||||||
|
"Failed to allocate command results");
|
||||||
|
free(error);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
*res = cmd_results_new(CMD_INVALID, "%s", error);
|
||||||
|
list_add(res_list, res);
|
||||||
free(error);
|
free(error);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
@ -265,10 +275,18 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
struct cmd_results *res = malloc(sizeof(struct cmd_results));
|
||||||
|
if (!res) {
|
||||||
|
sway_log(SWAY_ERROR, "Failed to allocate command results");
|
||||||
|
free_argv(argc, argv);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
struct cmd_handler *handler = find_core_handler(argv[0]);
|
struct cmd_handler *handler = find_core_handler(argv[0]);
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
list_add(res_list, cmd_results_new(CMD_INVALID,
|
*res = cmd_results_new(CMD_INVALID,
|
||||||
"Unknown/invalid command '%s'", argv[0]));
|
"Unknown/invalid command '%s'", argv[0]);
|
||||||
|
list_add(res_list, res);
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
@ -283,38 +301,38 @@ list_t *execute_command(char *_exec, struct sway_seat *seat,
|
||||||
struct sway_node *node = con ? &con->node :
|
struct sway_node *node = con ? &con->node :
|
||||||
seat_get_focus_inactive(seat, &root->node);
|
seat_get_focus_inactive(seat, &root->node);
|
||||||
set_config_node(node);
|
set_config_node(node);
|
||||||
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
*res = handler->handle(argc-1, argv+1);
|
||||||
list_add(res_list, res);
|
list_add(res_list, res);
|
||||||
if (res->status == CMD_INVALID) {
|
if (res->status == CMD_INVALID) {
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else if (views->length == 0) {
|
} else if (views->length == 0) {
|
||||||
list_add(res_list,
|
*res = cmd_results_new(CMD_FAILURE, "No matching node.");
|
||||||
cmd_results_new(CMD_FAILURE, "No matching node."));
|
list_add(res_list, res);
|
||||||
} else {
|
} else {
|
||||||
struct cmd_results *fail_res = NULL;
|
struct cmd_results fail_res = cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
for (int i = 0; i < views->length; ++i) {
|
for (int i = 0; i < views->length; ++i) {
|
||||||
struct sway_view *view = views->items[i];
|
struct sway_view *view = views->items[i];
|
||||||
set_config_node(&view->container->node);
|
set_config_node(&view->container->node);
|
||||||
struct cmd_results *res = handler->handle(argc-1, argv+1);
|
struct cmd_results hres = handler->handle(argc-1, argv+1);
|
||||||
if (res->status == CMD_SUCCESS) {
|
if (hres.status == CMD_SUCCESS) {
|
||||||
free_cmd_results(res);
|
free_cmd_results(hres);
|
||||||
} else {
|
} else {
|
||||||
// last failure will take precedence
|
// last failure will take precedence
|
||||||
if (fail_res) {
|
free_cmd_results(fail_res);
|
||||||
free_cmd_results(fail_res);
|
fail_res = hres;
|
||||||
}
|
if (hres.status == CMD_INVALID) {
|
||||||
fail_res = res;
|
*res = fail_res;
|
||||||
if (res->status == CMD_INVALID) {
|
list_add(res_list, res);
|
||||||
list_add(res_list, fail_res);
|
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list_add(res_list,
|
|
||||||
fail_res ? fail_res : cmd_results_new(CMD_SUCCESS, NULL));
|
*res = fail_res;
|
||||||
|
list_add(res_list, res);
|
||||||
}
|
}
|
||||||
free_argv(argc, argv);
|
free_argv(argc, argv);
|
||||||
} while(head);
|
} while(head);
|
||||||
|
|
@ -331,8 +349,8 @@ cleanup:
|
||||||
// be chained together)
|
// be chained together)
|
||||||
// 4) execute_command handles all state internally while config_command has
|
// 4) execute_command handles all state internally while config_command has
|
||||||
// some state handled outside (notably the block mode, in read_config)
|
// some state handled outside (notably the block mode, in read_config)
|
||||||
struct cmd_results *config_command(char *exec, char **new_block) {
|
struct cmd_results config_command(char *exec, char **new_block) {
|
||||||
struct cmd_results *results = NULL;
|
struct cmd_results results;
|
||||||
int argc;
|
int argc;
|
||||||
char **argv = split_args(exec, &argc);
|
char **argv = split_args(exec, &argc);
|
||||||
|
|
||||||
|
|
@ -417,7 +435,7 @@ cleanup:
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *config_subcommand(char **argv, int argc,
|
struct cmd_results config_subcommand(char **argv, int argc,
|
||||||
struct cmd_handler *handlers, size_t handlers_size) {
|
struct cmd_handler *handlers, size_t handlers_size) {
|
||||||
char *command = join_args(argv, argc);
|
char *command = join_args(argv, argc);
|
||||||
sway_log(SWAY_DEBUG, "Subcommand: %s", command);
|
sway_log(SWAY_DEBUG, "Subcommand: %s", command);
|
||||||
|
|
@ -436,8 +454,8 @@ struct cmd_results *config_subcommand(char **argv, int argc,
|
||||||
"The command '%s' is shimmed, but unimplemented", argv[0]);
|
"The command '%s' is shimmed, but unimplemented", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *config_commands_command(char *exec) {
|
struct cmd_results config_commands_command(char *exec) {
|
||||||
struct cmd_results *results = NULL;
|
struct cmd_results results;
|
||||||
int argc;
|
int argc;
|
||||||
char **argv = split_args(exec, &argc);
|
char **argv = split_args(exec, &argc);
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
|
|
@ -517,14 +535,10 @@ cleanup:
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_results_new(enum cmd_status status,
|
struct cmd_results cmd_results_new(enum cmd_status status,
|
||||||
const char *format, ...) {
|
const char *format, ...) {
|
||||||
struct cmd_results *results = malloc(sizeof(struct cmd_results));
|
struct cmd_results results;
|
||||||
if (!results) {
|
results.status = status;
|
||||||
sway_log(SWAY_ERROR, "Unable to allocate command results");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
results->status = status;
|
|
||||||
if (format) {
|
if (format) {
|
||||||
char *error = malloc(256);
|
char *error = malloc(256);
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
@ -533,18 +547,15 @@ struct cmd_results *cmd_results_new(enum cmd_status status,
|
||||||
vsnprintf(error, 256, format, args);
|
vsnprintf(error, 256, format, args);
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
results->error = error;
|
results.error = error;
|
||||||
} else {
|
} else {
|
||||||
results->error = NULL;
|
results.error = NULL;
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_cmd_results(struct cmd_results *results) {
|
void free_cmd_results(struct cmd_results results) {
|
||||||
if (results->error) {
|
free(results.error);
|
||||||
free(results->error);
|
|
||||||
}
|
|
||||||
free(results);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *cmd_results_to_json(list_t *res_list) {
|
char *cmd_results_to_json(list_t *res_list) {
|
||||||
|
|
@ -573,7 +584,7 @@ char *cmd_results_to_json(list_t *res_list) {
|
||||||
*
|
*
|
||||||
* return error object, or NULL if color is valid.
|
* return error object, or NULL if color is valid.
|
||||||
*/
|
*/
|
||||||
struct cmd_results *add_color(char *buffer, const char *color) {
|
struct cmd_results add_color(char *buffer, const char *color) {
|
||||||
int len = strlen(color);
|
int len = strlen(color);
|
||||||
if (len != 7 && len != 9) {
|
if (len != 7 && len != 9) {
|
||||||
return cmd_results_new(CMD_INVALID,
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
|
@ -596,5 +607,5 @@ struct cmd_results *add_color(char *buffer, const char *color) {
|
||||||
buffer[8] = 'f';
|
buffer[8] = 'f';
|
||||||
}
|
}
|
||||||
buffer[9] = '\0';
|
buffer[9] = '\0';
|
||||||
return NULL;
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_assign(int argc, char **argv) {
|
struct cmd_results cmd_assign(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "assign", EXPECTED_AT_LEAST, 2))) {
|
if (checkarg(&error, argc, "assign", EXPECTED_AT_LEAST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,9 @@ static bool is_subcommand(char *name) {
|
||||||
find_handler(name, bar_config_handlers, sizeof(bar_config_handlers));
|
find_handler(name, bar_config_handlers, sizeof(bar_config_handlers));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_bar(int argc, char **argv) {
|
struct cmd_results cmd_bar(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "bar", EXPECTED_AT_LEAST, 2))) {
|
if (checkarg(&error, argc, "bar", EXPECTED_AT_LEAST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
|
||||||
config->current_bar->id = id;
|
config->current_bar->id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *res = NULL;
|
struct cmd_results res;
|
||||||
if (find_handler(argv[0], bar_config_handlers,
|
if (find_handler(argv[0], bar_config_handlers,
|
||||||
sizeof(bar_config_handlers))) {
|
sizeof(bar_config_handlers))) {
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
|
|
@ -112,7 +112,7 @@ struct cmd_results *cmd_bar(int argc, char **argv) {
|
||||||
res = config_subcommand(argv, argc, bar_handlers, sizeof(bar_handlers));
|
res = config_subcommand(argv, argc, bar_handlers, sizeof(bar_handlers));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res && res->status != CMD_SUCCESS) {
|
if (res.status != CMD_SUCCESS) {
|
||||||
if (id) {
|
if (id) {
|
||||||
free_bar_config(config->current_bar);
|
free_bar_config(config->current_bar);
|
||||||
id = NULL;
|
id = NULL;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
static struct cmd_results *binding_add(struct bar_binding *binding,
|
static struct cmd_results binding_add(struct bar_binding *binding,
|
||||||
list_t *mode_bindings) {
|
list_t *mode_bindings) {
|
||||||
const char *name = get_mouse_button_name(binding->button);
|
const char *name = get_mouse_button_name(binding->button);
|
||||||
bool overwritten = false;
|
bool overwritten = false;
|
||||||
|
|
@ -35,7 +35,7 @@ static struct cmd_results *binding_add(struct bar_binding *binding,
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *binding_remove(struct bar_binding *binding,
|
static struct cmd_results binding_remove(struct bar_binding *binding,
|
||||||
list_t *mode_bindings) {
|
list_t *mode_bindings) {
|
||||||
const char *name = get_mouse_button_name(binding->button);
|
const char *name = get_mouse_button_name(binding->button);
|
||||||
for (int i = 0; i < mode_bindings->length; i++) {
|
for (int i = 0; i < mode_bindings->length; i++) {
|
||||||
|
|
@ -52,7 +52,7 @@ static struct cmd_results *binding_remove(struct bar_binding *binding,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *error = cmd_results_new(CMD_FAILURE, "Could not "
|
struct cmd_results error = cmd_results_new(CMD_FAILURE, "Could not "
|
||||||
"find binding for [bar %s]" " Button %u (%s)%s",
|
"find binding for [bar %s]" " Button %u (%s)%s",
|
||||||
config->current_bar->id, binding->button, name,
|
config->current_bar->id, binding->button, name,
|
||||||
binding->release ? " - release" : "");
|
binding->release ? " - release" : "");
|
||||||
|
|
@ -60,7 +60,7 @@ static struct cmd_results *binding_remove(struct bar_binding *binding,
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code,
|
static struct cmd_results bar_cmd_bind(int argc, char **argv, bool code,
|
||||||
bool unbind) {
|
bool unbind) {
|
||||||
int minargs = 2;
|
int minargs = 2;
|
||||||
const char *command;
|
const char *command;
|
||||||
|
|
@ -71,8 +71,8 @@ static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code,
|
||||||
command = code ? "bar bindcode" : "bar bindsym";
|
command = code ? "bar bindcode" : "bar bindsym";
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, command, EXPECTED_AT_LEAST, minargs))) {
|
if (checkarg(&error, argc, command, EXPECTED_AT_LEAST, minargs)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,18 +112,18 @@ static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code,
|
||||||
return binding_add(binding, bindings);
|
return binding_add(binding, bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_bindcode(int argc, char **argv) {
|
struct cmd_results bar_cmd_bindcode(int argc, char **argv) {
|
||||||
return bar_cmd_bind(argc, argv, true, false);
|
return bar_cmd_bind(argc, argv, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
|
struct cmd_results bar_cmd_bindsym(int argc, char **argv) {
|
||||||
return bar_cmd_bind(argc, argv, false, false);
|
return bar_cmd_bind(argc, argv, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_unbindcode(int argc, char **argv) {
|
struct cmd_results bar_cmd_unbindcode(int argc, char **argv) {
|
||||||
return bar_cmd_bind(argc, argv, true, true);
|
return bar_cmd_bind(argc, argv, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_unbindsym(int argc, char **argv) {
|
struct cmd_results bar_cmd_unbindsym(int argc, char **argv) {
|
||||||
return bar_cmd_bind(argc, argv, false, true);
|
return bar_cmd_bind(argc, argv, false, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
|
struct cmd_results bar_cmd_binding_mode_indicator(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc,
|
if (checkarg(&error, argc,
|
||||||
"binding_mode_indicator", EXPECTED_EQUAL_TO, 1))) {
|
"binding_mode_indicator", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
config->current_bar->binding_mode_indicator =
|
config->current_bar->binding_mode_indicator =
|
||||||
|
|
|
||||||
|
|
@ -16,47 +16,43 @@ static struct cmd_handler bar_colors_handlers[] = {
|
||||||
{ "urgent_workspace", bar_colors_cmd_urgent_workspace },
|
{ "urgent_workspace", bar_colors_cmd_urgent_workspace },
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct cmd_results *parse_single_color(char **color,
|
static struct cmd_results parse_single_color(char **color,
|
||||||
const char *cmd_name, int argc, char **argv) {
|
const char *cmd_name, int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, cmd_name, EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (!*color && !(*color = malloc(10))) {
|
if (!*color && !(*color = malloc(10))) {
|
||||||
return NULL;
|
return cmd_results_new(CMD_FAILURE, "Allocation failure");
|
||||||
}
|
}
|
||||||
error = add_color(*color, argv[0]);
|
return add_color(*color, argv[0]);
|
||||||
if (error) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *parse_three_colors(char ***colors,
|
static struct cmd_results parse_three_colors(char ***colors,
|
||||||
const char *cmd_name, int argc, char **argv) {
|
const char *cmd_name, int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
return cmd_results_new(CMD_INVALID,
|
return cmd_results_new(CMD_INVALID,
|
||||||
"Command '%s' requires exactly three color values", cmd_name);
|
"Command '%s' requires exactly three color values", cmd_name);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < 3; i++) {
|
for (size_t i = 0; i < 3; i++) {
|
||||||
if (!*colors[i] && !(*(colors[i]) = malloc(10))) {
|
if (!*colors[i] && !(*(colors[i]) = malloc(10))) {
|
||||||
return NULL;
|
return cmd_results_new(CMD_FAILURE, "Allocation failure");
|
||||||
}
|
}
|
||||||
error = add_color(*(colors[i]), argv[i]);
|
error = add_color(*(colors[i]), argv[i]);
|
||||||
if (error) {
|
if (error.status != CMD_SUCCESS) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_colors(int argc, char **argv) {
|
struct cmd_results bar_cmd_colors(int argc, char **argv) {
|
||||||
return config_subcommand(argv, argc, bar_colors_handlers,
|
return config_subcommand(argv, argc, bar_colors_handlers,
|
||||||
sizeof(bar_colors_handlers));
|
sizeof(bar_colors_handlers));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_active_workspace(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_active_workspace(int argc, char **argv) {
|
||||||
char **colors[3] = {
|
char **colors[3] = {
|
||||||
&(config->current_bar->colors.active_workspace_border),
|
&(config->current_bar->colors.active_workspace_border),
|
||||||
&(config->current_bar->colors.active_workspace_bg),
|
&(config->current_bar->colors.active_workspace_bg),
|
||||||
|
|
@ -65,17 +61,17 @@ struct cmd_results *bar_colors_cmd_active_workspace(int argc, char **argv) {
|
||||||
return parse_three_colors(colors, "active_workspace", argc, argv);
|
return parse_three_colors(colors, "active_workspace", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_background(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_background(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.background),
|
return parse_single_color(&(config->current_bar->colors.background),
|
||||||
"background", argc, argv);
|
"background", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_focused_background(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_focused_background(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.focused_background),
|
return parse_single_color(&(config->current_bar->colors.focused_background),
|
||||||
"focused_background", argc, argv);
|
"focused_background", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_binding_mode(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_binding_mode(int argc, char **argv) {
|
||||||
char **colors[3] = {
|
char **colors[3] = {
|
||||||
&(config->current_bar->colors.binding_mode_border),
|
&(config->current_bar->colors.binding_mode_border),
|
||||||
&(config->current_bar->colors.binding_mode_bg),
|
&(config->current_bar->colors.binding_mode_bg),
|
||||||
|
|
@ -84,7 +80,7 @@ struct cmd_results *bar_colors_cmd_binding_mode(int argc, char **argv) {
|
||||||
return parse_three_colors(colors, "binding_mode", argc, argv);
|
return parse_three_colors(colors, "binding_mode", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_focused_workspace(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_focused_workspace(int argc, char **argv) {
|
||||||
char **colors[3] = {
|
char **colors[3] = {
|
||||||
&(config->current_bar->colors.focused_workspace_border),
|
&(config->current_bar->colors.focused_workspace_border),
|
||||||
&(config->current_bar->colors.focused_workspace_bg),
|
&(config->current_bar->colors.focused_workspace_bg),
|
||||||
|
|
@ -93,7 +89,7 @@ struct cmd_results *bar_colors_cmd_focused_workspace(int argc, char **argv) {
|
||||||
return parse_three_colors(colors, "focused_workspace", argc, argv);
|
return parse_three_colors(colors, "focused_workspace", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_inactive_workspace(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_inactive_workspace(int argc, char **argv) {
|
||||||
char **colors[3] = {
|
char **colors[3] = {
|
||||||
&(config->current_bar->colors.inactive_workspace_border),
|
&(config->current_bar->colors.inactive_workspace_border),
|
||||||
&(config->current_bar->colors.inactive_workspace_bg),
|
&(config->current_bar->colors.inactive_workspace_bg),
|
||||||
|
|
@ -102,27 +98,27 @@ struct cmd_results *bar_colors_cmd_inactive_workspace(int argc, char **argv) {
|
||||||
return parse_three_colors(colors, "inactive_workspace", argc, argv);
|
return parse_three_colors(colors, "inactive_workspace", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_separator(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_separator(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.separator),
|
return parse_single_color(&(config->current_bar->colors.separator),
|
||||||
"separator", argc, argv);
|
"separator", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_focused_separator(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_focused_separator(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.focused_separator),
|
return parse_single_color(&(config->current_bar->colors.focused_separator),
|
||||||
"focused_separator", argc, argv);
|
"focused_separator", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_statusline(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_statusline(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.statusline),
|
return parse_single_color(&(config->current_bar->colors.statusline),
|
||||||
"statusline", argc, argv);
|
"statusline", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_focused_statusline(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_focused_statusline(int argc, char **argv) {
|
||||||
return parse_single_color(&(config->current_bar->colors.focused_statusline),
|
return parse_single_color(&(config->current_bar->colors.focused_statusline),
|
||||||
"focused_statusline", argc, argv);
|
"focused_statusline", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv) {
|
struct cmd_results bar_colors_cmd_urgent_workspace(int argc, char **argv) {
|
||||||
char **colors[3] = {
|
char **colors[3] = {
|
||||||
&(config->current_bar->colors.urgent_workspace_border),
|
&(config->current_bar->colors.urgent_workspace_border),
|
||||||
&(config->current_bar->colors.urgent_workspace_bg),
|
&(config->current_bar->colors.urgent_workspace_bg),
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_font(int argc, char **argv) {
|
struct cmd_results bar_cmd_font(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "font", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
char *font = join_args(argv, argc);
|
char *font = join_args(argv, argc);
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
#include "sway/ipc-server.h"
|
#include "sway/ipc-server.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_gaps(int argc, char **argv) {
|
struct cmd_results bar_cmd_gaps(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "gaps", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if ((error = checkarg(argc, "gaps", EXPECTED_AT_MOST, 4))) {
|
if (checkarg(&error, argc, "gaps", EXPECTED_AT_MOST, 4)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_height(int argc, char **argv) {
|
struct cmd_results bar_cmd_height(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "height", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
int height = atoi(argv[0]);
|
int height = atoi(argv[0]);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "sway/ipc-server.h"
|
#include "sway/ipc-server.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static struct cmd_results *bar_set_hidden_state(struct bar_config *bar,
|
static struct cmd_results bar_set_hidden_state(struct bar_config *bar,
|
||||||
const char *hidden_state) {
|
const char *hidden_state) {
|
||||||
char *old_state = bar->hidden_state;
|
char *old_state = bar->hidden_state;
|
||||||
if (strcasecmp("toggle", hidden_state) == 0 && !config->reading) {
|
if (strcasecmp("toggle", hidden_state) == 0 && !config->reading) {
|
||||||
|
|
@ -31,15 +31,15 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar,
|
||||||
}
|
}
|
||||||
// free old mode
|
// free old mode
|
||||||
free(old_state);
|
free(old_state);
|
||||||
return NULL;
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
|
struct cmd_results bar_cmd_hidden_state(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "hidden_state", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "hidden_state", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if ((error = checkarg(argc, "hidden_state", EXPECTED_AT_MOST, 2))) {
|
if (checkarg(&error, argc, "hidden_state", EXPECTED_AT_MOST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (config->reading && argc > 1) {
|
if (config->reading && argc > 1) {
|
||||||
|
|
@ -55,20 +55,22 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
|
||||||
|
|
||||||
const char *state = argv[0];
|
const char *state = argv[0];
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
error = bar_set_hidden_state(config->current_bar, state);
|
return bar_set_hidden_state(config->current_bar, state);
|
||||||
} else {
|
} else {
|
||||||
const char *id = argc == 2 ? argv[1] : NULL;
|
const char *id = argc == 2 ? argv[1] : NULL;
|
||||||
for (int i = 0; i < config->bars->length; ++i) {
|
for (int i = 0; i < config->bars->length; ++i) {
|
||||||
struct bar_config *bar = config->bars->items[i];
|
struct bar_config *bar = config->bars->items[i];
|
||||||
if (id) {
|
if (id) {
|
||||||
if (strcmp(id, bar->id) == 0) {
|
if (strcmp(id, bar->id) == 0) {
|
||||||
error = bar_set_hidden_state(bar, state);
|
return bar_set_hidden_state(bar, state);
|
||||||
break;
|
}
|
||||||
|
} else {
|
||||||
|
error = bar_set_hidden_state(bar, state);
|
||||||
|
if (error.status != CMD_SUCCESS) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
} else if ((error = bar_set_hidden_state(bar, state))) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
return error ? error : cmd_results_new(CMD_SUCCESS, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_icon_theme(int argc, char **argv) {
|
struct cmd_results bar_cmd_icon_theme(int argc, char **argv) {
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "icon_theme", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "icon_theme", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
struct cmd_results bar_cmd_id(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "id", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "id", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "sway/ipc-server.h"
|
#include "sway/ipc-server.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static struct cmd_results *bar_set_mode(struct bar_config *bar, const char *mode) {
|
static struct cmd_results bar_set_mode(struct bar_config *bar, const char *mode) {
|
||||||
char *old_mode = bar->mode;
|
char *old_mode = bar->mode;
|
||||||
if (strcasecmp("toggle", mode) == 0 && !config->reading) {
|
if (strcasecmp("toggle", mode) == 0 && !config->reading) {
|
||||||
if (strcasecmp("dock", bar->mode) == 0) {
|
if (strcasecmp("dock", bar->mode) == 0) {
|
||||||
|
|
@ -35,15 +35,15 @@ static struct cmd_results *bar_set_mode(struct bar_config *bar, const char *mode
|
||||||
|
|
||||||
// free old mode
|
// free old mode
|
||||||
free(old_mode);
|
free(old_mode);
|
||||||
return NULL;
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_mode(int argc, char **argv) {
|
struct cmd_results bar_cmd_mode(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "mode", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "mode", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if ((error = checkarg(argc, "mode", EXPECTED_AT_MOST, 2))) {
|
if (checkarg(&error, argc, "mode", EXPECTED_AT_MOST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (config->reading && argc > 1) {
|
if (config->reading && argc > 1) {
|
||||||
|
|
@ -59,20 +59,22 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) {
|
||||||
|
|
||||||
const char *mode = argv[0];
|
const char *mode = argv[0];
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
error = bar_set_mode(config->current_bar, mode);
|
return bar_set_mode(config->current_bar, mode);
|
||||||
} else {
|
} else {
|
||||||
const char *id = argc == 2 ? argv[1] : NULL;
|
const char *id = argc == 2 ? argv[1] : NULL;
|
||||||
for (int i = 0; i < config->bars->length; ++i) {
|
for (int i = 0; i < config->bars->length; ++i) {
|
||||||
struct bar_config *bar = config->bars->items[i];
|
struct bar_config *bar = config->bars->items[i];
|
||||||
if (id) {
|
if (id) {
|
||||||
if (strcmp(id, bar->id) == 0) {
|
if (strcmp(id, bar->id) == 0) {
|
||||||
error = bar_set_mode(bar, mode);
|
return bar_set_mode(bar, mode);
|
||||||
break;
|
}
|
||||||
|
} else {
|
||||||
|
error = bar_set_mode(bar, mode);
|
||||||
|
if (error.status != CMD_SUCCESS) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
} else if ((error = bar_set_mode(bar, mode))) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
return error ? error : cmd_results_new(CMD_SUCCESS, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
|
struct cmd_results bar_cmd_modifier(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "modifier", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "modifier", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_output(int argc, char **argv) {
|
struct cmd_results bar_cmd_output(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "output", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "output", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) {
|
struct cmd_results bar_cmd_pango_markup(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "pango_markup", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "pango_markup", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
config->current_bar->pango_markup =
|
config->current_bar->pango_markup =
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_position(int argc, char **argv) {
|
struct cmd_results bar_cmd_position(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "position", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
char *valid[] = { "top", "bottom" };
|
char *valid[] = { "top", "bottom" };
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_separator_symbol(int argc, char **argv) {
|
struct cmd_results bar_cmd_separator_symbol(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "separator_symbol", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "separator_symbol", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
free(config->current_bar->separator_symbol);
|
free(config->current_bar->separator_symbol);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
|
struct cmd_results bar_cmd_status_command(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "status_command", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
free(config->current_bar->status_command);
|
free(config->current_bar->status_command);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_status_edge_padding(int argc, char **argv) {
|
struct cmd_results bar_cmd_status_edge_padding(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "status_edge_padding", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "status_edge_padding", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
char *end;
|
char *end;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_status_padding(int argc, char **argv) {
|
struct cmd_results bar_cmd_status_padding(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "status_padding", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "status_padding", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
char *end;
|
char *end;
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_strip_workspace_name(int argc, char **argv) {
|
struct cmd_results bar_cmd_strip_workspace_name(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc,
|
if (checkarg(&error, argc,
|
||||||
"strip_workspace_name", EXPECTED_EQUAL_TO, 1))) {
|
"strip_workspace_name", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) {
|
struct cmd_results bar_cmd_strip_workspace_numbers(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc,
|
if (checkarg(&error, argc,
|
||||||
"strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) {
|
"strip_workspace_numbers", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) {
|
struct cmd_results bar_cmd_swaybar_command(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "swaybar_command", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "swaybar_command", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
free(config->current_bar->swaybar_command);
|
free(config->current_bar->swaybar_command);
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
#include "sway/input/cursor.h"
|
#include "sway/input/cursor.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static struct cmd_results *tray_bind(int argc, char **argv, bool code) {
|
static struct cmd_results tray_bind(int argc, char **argv, bool code) {
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
const char *command = code ? "bar tray_bindcode" : "bar tray_bindsym";
|
const char *command = code ? "bar tray_bindcode" : "bar tray_bindsym";
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, command, EXPECTED_EQUAL_TO, 2))) {
|
if (checkarg(&error, argc, command, EXPECTED_EQUAL_TO, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,10 +86,10 @@ static struct cmd_results *tray_bind(int argc, char **argv, bool code) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_tray_bindcode(int argc, char **argv) {
|
struct cmd_results bar_cmd_tray_bindcode(int argc, char **argv) {
|
||||||
return tray_bind(argc, argv, true);
|
return tray_bind(argc, argv, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_tray_bindsym(int argc, char **argv) {
|
struct cmd_results bar_cmd_tray_bindsym(int argc, char **argv) {
|
||||||
return tray_bind(argc, argv, false);
|
return tray_bind(argc, argv, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_tray_output(int argc, char **argv) {
|
struct cmd_results bar_cmd_tray_output(int argc, char **argv) {
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "tray_output", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "tray_output", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) {
|
struct cmd_results bar_cmd_tray_padding(int argc, char **argv) {
|
||||||
#if HAVE_TRAY
|
#if HAVE_TRAY
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "tray_padding", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_MOST, 2))) {
|
if (checkarg(&error, argc, "tray_padding", EXPECTED_AT_MOST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
|
struct cmd_results bar_cmd_workspace_buttons(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
config->current_bar->workspace_buttons =
|
config->current_bar->workspace_buttons =
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) {
|
struct cmd_results bar_cmd_wrap_scroll(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "wrap_scroll", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "wrap_scroll", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
config->current_bar->wrap_scroll =
|
config->current_bar->wrap_scroll =
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ static int key_qsort_cmp(const void *keyp_a, const void *keyp_b) {
|
||||||
* the value of *type if the initial type guess was incorrect and if this
|
* the value of *type if the initial type guess was incorrect and if this
|
||||||
* was the first identified key.
|
* was the first identified key.
|
||||||
*/
|
*/
|
||||||
static struct cmd_results *identify_key(const char* name, bool first_key,
|
static struct cmd_results identify_key(const char* name, bool first_key,
|
||||||
uint32_t* key_val, enum binding_input_type* type) {
|
uint32_t* key_val, enum binding_input_type* type) {
|
||||||
if (*type == BINDING_MOUSECODE) {
|
if (*type == BINDING_MOUSECODE) {
|
||||||
// check for mouse bindcodes
|
// check for mouse bindcodes
|
||||||
|
|
@ -124,7 +124,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
|
||||||
uint32_t button = get_mouse_bindcode(name, &message);
|
uint32_t button = get_mouse_bindcode(name, &message);
|
||||||
if (!button) {
|
if (!button) {
|
||||||
if (message) {
|
if (message) {
|
||||||
struct cmd_results *error =
|
struct cmd_results error =
|
||||||
cmd_results_new(CMD_INVALID, message);
|
cmd_results_new(CMD_INVALID, message);
|
||||||
free(message);
|
free(message);
|
||||||
return error;
|
return error;
|
||||||
|
|
@ -140,7 +140,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
|
||||||
uint32_t button = get_mouse_bindsym(name, &message);
|
uint32_t button = get_mouse_bindsym(name, &message);
|
||||||
if (!button) {
|
if (!button) {
|
||||||
if (message) {
|
if (message) {
|
||||||
struct cmd_results *error =
|
struct cmd_results error =
|
||||||
cmd_results_new(CMD_INVALID, message);
|
cmd_results_new(CMD_INVALID, message);
|
||||||
free(message);
|
free(message);
|
||||||
return error;
|
return error;
|
||||||
|
|
@ -158,7 +158,7 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
|
||||||
if (button) {
|
if (button) {
|
||||||
*type = BINDING_MOUSECODE;
|
*type = BINDING_MOUSECODE;
|
||||||
*key_val = button;
|
*key_val = button;
|
||||||
return NULL;
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,14 +179,14 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
|
||||||
char *message = NULL;
|
char *message = NULL;
|
||||||
uint32_t button = get_mouse_bindsym(name, &message);
|
uint32_t button = get_mouse_bindsym(name, &message);
|
||||||
if (message) {
|
if (message) {
|
||||||
struct cmd_results *error =
|
struct cmd_results error =
|
||||||
cmd_results_new(CMD_INVALID, message);
|
cmd_results_new(CMD_INVALID, message);
|
||||||
free(message);
|
free(message);
|
||||||
return error;
|
return error;
|
||||||
} else if (button) {
|
} else if (button) {
|
||||||
*type = BINDING_MOUSESYM;
|
*type = BINDING_MOUSESYM;
|
||||||
*key_val = button;
|
*key_val = button;
|
||||||
return NULL;
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,10 +202,10 @@ static struct cmd_results *identify_key(const char* name, bool first_key,
|
||||||
}
|
}
|
||||||
*key_val = keysym;
|
*key_val = keysym;
|
||||||
}
|
}
|
||||||
return NULL;
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *switch_binding_add(
|
static struct cmd_results switch_binding_add(
|
||||||
struct sway_switch_binding *binding, const char *bindtype,
|
struct sway_switch_binding *binding, const char *bindtype,
|
||||||
const char *switchcombo, bool warn) {
|
const char *switchcombo, bool warn) {
|
||||||
list_t *mode_bindings = config->current_mode->switch_bindings;
|
list_t *mode_bindings = config->current_mode->switch_bindings;
|
||||||
|
|
@ -237,7 +237,7 @@ static struct cmd_results *switch_binding_add(
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *switch_binding_remove(
|
static struct cmd_results switch_binding_remove(
|
||||||
struct sway_switch_binding *binding, const char *bindtype,
|
struct sway_switch_binding *binding, const char *bindtype,
|
||||||
const char *switchcombo) {
|
const char *switchcombo) {
|
||||||
list_t *mode_bindings = config->current_mode->switch_bindings;
|
list_t *mode_bindings = config->current_mode->switch_bindings;
|
||||||
|
|
@ -276,7 +276,7 @@ static struct sway_binding *binding_upsert(struct sway_binding *binding,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *binding_add(struct sway_binding *binding,
|
static struct cmd_results binding_add(struct sway_binding *binding,
|
||||||
list_t *mode_bindings, const char *bindtype,
|
list_t *mode_bindings, const char *bindtype,
|
||||||
const char *keycombo, bool warn) {
|
const char *keycombo, bool warn) {
|
||||||
struct sway_binding *config_binding = binding_upsert(binding, mode_bindings);
|
struct sway_binding *config_binding = binding_upsert(binding, mode_bindings);
|
||||||
|
|
@ -300,7 +300,7 @@ static struct cmd_results *binding_add(struct sway_binding *binding,
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *binding_remove(struct sway_binding *binding,
|
static struct cmd_results binding_remove(struct sway_binding *binding,
|
||||||
list_t *mode_bindings, const char *bindtype,
|
list_t *mode_bindings, const char *bindtype,
|
||||||
const char *keycombo) {
|
const char *keycombo) {
|
||||||
for (int i = 0; i < mode_bindings->length; ++i) {
|
for (int i = 0; i < mode_bindings->length; ++i) {
|
||||||
|
|
@ -319,7 +319,7 @@ static struct cmd_results *binding_remove(struct sway_binding *binding,
|
||||||
"for the given flags", keycombo);
|
"for the given flags", keycombo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
|
static struct cmd_results cmd_bindsym_or_bindcode(int argc, char **argv,
|
||||||
bool bindcode, bool unbind) {
|
bool bindcode, bool unbind) {
|
||||||
const char *bindtype;
|
const char *bindtype;
|
||||||
int minargs = 2;
|
int minargs = 2;
|
||||||
|
|
@ -330,8 +330,8 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
|
||||||
bindtype = bindcode ? "bindcode": "bindsym";
|
bindtype = bindcode ? "bindcode": "bindsym";
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, bindtype, EXPECTED_AT_LEAST, minargs))) {
|
if (checkarg(&error, argc, bindtype, EXPECTED_AT_LEAST, minargs)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,7 +431,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
|
||||||
uint32_t key_val = 0;
|
uint32_t key_val = 0;
|
||||||
error = identify_key(split->items[i], binding->keys->length == 0,
|
error = identify_key(split->items[i], binding->keys->length == 0,
|
||||||
&key_val, &binding->type);
|
&key_val, &binding->type);
|
||||||
if (error) {
|
if (error.status != CMD_SUCCESS) {
|
||||||
free_sway_binding(binding);
|
free_sway_binding(binding);
|
||||||
list_free(split);
|
list_free(split);
|
||||||
return error;
|
return error;
|
||||||
|
|
@ -485,7 +485,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
|
||||||
return binding_add(binding, mode_bindings, bindtype, argv[0], warn);
|
return binding_add(binding, mode_bindings, bindtype, argv[0], warn);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
|
struct cmd_results cmd_bind_or_unbind_switch(int argc, char **argv,
|
||||||
bool unbind) {
|
bool unbind) {
|
||||||
int minargs = 2;
|
int minargs = 2;
|
||||||
char *bindtype = "bindswitch";
|
char *bindtype = "bindswitch";
|
||||||
|
|
@ -494,8 +494,8 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
|
||||||
bindtype = "unbindswitch";
|
bindtype = "unbindswitch";
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, bindtype, EXPECTED_AT_LEAST, minargs))) {
|
if (checkarg(&error, argc, bindtype, EXPECTED_AT_LEAST, minargs)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct sway_switch_binding *binding = calloc(1, sizeof(struct sway_switch_binding));
|
struct sway_switch_binding *binding = calloc(1, sizeof(struct sway_switch_binding));
|
||||||
|
|
@ -566,27 +566,27 @@ struct cmd_results *cmd_bind_or_unbind_switch(int argc, char **argv,
|
||||||
return switch_binding_add(binding, bindtype, argv[0], warn);
|
return switch_binding_add(binding, bindtype, argv[0], warn);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_bindsym(int argc, char **argv) {
|
struct cmd_results cmd_bindsym(int argc, char **argv) {
|
||||||
return cmd_bindsym_or_bindcode(argc, argv, false, false);
|
return cmd_bindsym_or_bindcode(argc, argv, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
struct cmd_results cmd_bindcode(int argc, char **argv) {
|
||||||
return cmd_bindsym_or_bindcode(argc, argv, true, false);
|
return cmd_bindsym_or_bindcode(argc, argv, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_unbindsym(int argc, char **argv) {
|
struct cmd_results cmd_unbindsym(int argc, char **argv) {
|
||||||
return cmd_bindsym_or_bindcode(argc, argv, false, true);
|
return cmd_bindsym_or_bindcode(argc, argv, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_unbindcode(int argc, char **argv) {
|
struct cmd_results cmd_unbindcode(int argc, char **argv) {
|
||||||
return cmd_bindsym_or_bindcode(argc, argv, true, true);
|
return cmd_bindsym_or_bindcode(argc, argv, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_bindswitch(int argc, char **argv) {
|
struct cmd_results cmd_bindswitch(int argc, char **argv) {
|
||||||
return cmd_bind_or_unbind_switch(argc, argv, false);
|
return cmd_bind_or_unbind_switch(argc, argv, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_unbindswitch(int argc, char **argv) {
|
struct cmd_results cmd_unbindswitch(int argc, char **argv) {
|
||||||
return cmd_bind_or_unbind_switch(argc, argv, true);
|
return cmd_bind_or_unbind_switch(argc, argv, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -630,7 +630,8 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding)
|
||||||
binding->command, results->error);
|
binding->command, results->error);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
free_cmd_results(results);
|
free_cmd_results(*results);
|
||||||
|
free(results);
|
||||||
}
|
}
|
||||||
list_free(res_list);
|
list_free(res_list);
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,9 @@ static void border_toggle(struct sway_container *con) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_border(int argc, char **argv) {
|
struct cmd_results cmd_border(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "border", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "border", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,10 @@ static bool parse_color_float(char *hexstring, float dest[static 4]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *handle_command(int argc, char **argv,
|
static struct cmd_results handle_command(int argc, char **argv,
|
||||||
struct border_colors *class, char *cmd_name) {
|
struct border_colors *class, char *cmd_name) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 5))) {
|
if (checkarg(&error, argc, cmd_name, EXPECTED_EQUAL_TO, 5)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,23 +97,23 @@ static struct cmd_results *handle_command(int argc, char **argv,
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_client_focused(int argc, char **argv) {
|
struct cmd_results cmd_client_focused(int argc, char **argv) {
|
||||||
return handle_command(argc, argv, &config->border_colors.focused, "client.focused");
|
return handle_command(argc, argv, &config->border_colors.focused, "client.focused");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_client_focused_inactive(int argc, char **argv) {
|
struct cmd_results cmd_client_focused_inactive(int argc, char **argv) {
|
||||||
return handle_command(argc, argv, &config->border_colors.focused_inactive, "client.focused_inactive");
|
return handle_command(argc, argv, &config->border_colors.focused_inactive, "client.focused_inactive");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_client_unfocused(int argc, char **argv) {
|
struct cmd_results cmd_client_unfocused(int argc, char **argv) {
|
||||||
return handle_command(argc, argv, &config->border_colors.unfocused, "client.unfocused");
|
return handle_command(argc, argv, &config->border_colors.unfocused, "client.unfocused");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_client_urgent(int argc, char **argv) {
|
struct cmd_results cmd_client_urgent(int argc, char **argv) {
|
||||||
return handle_command(argc, argv, &config->border_colors.urgent, "client.urgent");
|
return handle_command(argc, argv, &config->border_colors.urgent, "client.urgent");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_client_noop(int argc, char **argv) {
|
struct cmd_results cmd_client_noop(int argc, char **argv) {
|
||||||
sway_log(SWAY_INFO, "Warning: %s is ignored by sway", argv[-1]);
|
sway_log(SWAY_INFO, "Warning: %s is ignored by sway", argv[-1]);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ static void create_output(struct wlr_backend *backend, void *data) {
|
||||||
/**
|
/**
|
||||||
* This command is intended for developer use only.
|
* This command is intended for developer use only.
|
||||||
*/
|
*/
|
||||||
struct cmd_results *cmd_create_output(int argc, char **argv) {
|
struct cmd_results cmd_create_output(int argc, char **argv) {
|
||||||
sway_assert(wlr_backend_is_multi(server.backend),
|
sway_assert(wlr_backend_is_multi(server.backend),
|
||||||
"Expected a multi backend");
|
"Expected a multi backend");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/tree/container.h"
|
#include "sway/tree/container.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_default_border(int argc, char **argv) {
|
struct cmd_results cmd_default_border(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "default_border", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "default_border", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/tree/container.h"
|
#include "sway/tree/container.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_default_floating_border(int argc, char **argv) {
|
struct cmd_results cmd_default_floating_border(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "default_floating_border",
|
if (checkarg(&error, argc, "default_floating_border",
|
||||||
EXPECTED_AT_LEAST, 1))) {
|
EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_default_orientation(int argc, char **argv) {
|
struct cmd_results cmd_default_orientation(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "default_orientation", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "default_orientation", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (strcasecmp(argv[0], "horizontal") == 0) {
|
if (strcasecmp(argv[0], "horizontal") == 0) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_exec(int argc, char **argv) {
|
struct cmd_results cmd_exec(int argc, char **argv) {
|
||||||
if (!config->active) return cmd_results_new(CMD_DEFER, NULL);
|
if (!config->active) return cmd_results_new(CMD_DEFER, NULL);
|
||||||
if (config->reloading) {
|
if (config->reloading) {
|
||||||
char *args = join_args(argv, argc);
|
char *args = join_args(argv, argc);
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
struct cmd_results cmd_exec_always(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if (!config->active || config->validating) {
|
if (!config->active || config->validating) {
|
||||||
return cmd_results_new(CMD_DEFER, NULL);
|
return cmd_results_new(CMD_DEFER, NULL);
|
||||||
}
|
}
|
||||||
if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, argv[-1], EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
||||||
if (strcmp(argv[0], "--no-startup-id") == 0) {
|
if (strcmp(argv[0], "--no-startup-id") == 0) {
|
||||||
sway_log(SWAY_INFO, "exec switch '--no-startup-id' not supported, ignored.");
|
sway_log(SWAY_INFO, "exec switch '--no-startup-id' not supported, ignored.");
|
||||||
--argc; ++argv;
|
--argc; ++argv;
|
||||||
if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, argv[-1], EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
void sway_terminate(int exit_code);
|
void sway_terminate(int exit_code);
|
||||||
|
|
||||||
struct cmd_results *cmd_exit(int argc, char **argv) {
|
struct cmd_results cmd_exit(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "exit", EXPECTED_EQUAL_TO, 0))) {
|
if (checkarg(&error, argc, "exit", EXPECTED_EQUAL_TO, 0)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
sway_terminate(0);
|
sway_terminate(0);
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_floating(int argc, char **argv) {
|
struct cmd_results cmd_floating(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "floating", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (!root->outputs->length) {
|
if (!root->outputs->length) {
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ static const char min_usage[] =
|
||||||
static const char max_usage[] =
|
static const char max_usage[] =
|
||||||
"Expected 'floating_maximum_size <width> x <height>'";
|
"Expected 'floating_maximum_size <width> x <height>'";
|
||||||
|
|
||||||
static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
|
static struct cmd_results handle_command(int argc, char **argv, char *cmd_name,
|
||||||
const char *usage, int *config_width, int *config_height) {
|
const char *usage, int *config_width, int *config_height) {
|
||||||
struct cmd_results *error;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 3))) {
|
if (checkarg(&error, argc, cmd_name, EXPECTED_EQUAL_TO, 3)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,12 +41,12 @@ static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name,
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) {
|
struct cmd_results cmd_floating_minimum_size(int argc, char **argv) {
|
||||||
return handle_command(argc, argv, "floating_minimum_size", min_usage,
|
return handle_command(argc, argv, "floating_minimum_size", min_usage,
|
||||||
&config->floating_minimum_width, &config->floating_minimum_height);
|
&config->floating_minimum_width, &config->floating_minimum_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_floating_maximum_size(int argc, char **argv) {
|
struct cmd_results cmd_floating_maximum_size(int argc, char **argv) {
|
||||||
return handle_command(argc, argv, "floating_maximum_size", max_usage,
|
return handle_command(argc, argv, "floating_maximum_size", max_usage,
|
||||||
&config->floating_maximum_width, &config->floating_maximum_height);
|
&config->floating_maximum_width, &config->floating_maximum_height);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/input/keyboard.h"
|
#include "sway/input/keyboard.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_floating_modifier(int argc, char **argv) {
|
struct cmd_results cmd_floating_modifier(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "floating_modifier", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ static struct sway_node *node_get_in_direction_floating(
|
||||||
return closest_con ? &closest_con->node : NULL;
|
return closest_con ? &closest_con->node : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *focus_mode(struct sway_workspace *ws,
|
static struct cmd_results focus_mode(struct sway_workspace *ws,
|
||||||
struct sway_seat *seat, bool floating) {
|
struct sway_seat *seat, bool floating) {
|
||||||
struct sway_container *new_focus = NULL;
|
struct sway_container *new_focus = NULL;
|
||||||
if (floating) {
|
if (floating) {
|
||||||
|
|
@ -277,7 +277,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws,
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *focus_output(struct sway_seat *seat,
|
static struct cmd_results focus_output(struct sway_seat *seat,
|
||||||
int argc, char **argv) {
|
int argc, char **argv) {
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
return cmd_results_new(CMD_INVALID,
|
return cmd_results_new(CMD_INVALID,
|
||||||
|
|
@ -322,7 +322,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *focus_parent(void) {
|
static struct cmd_results focus_parent(void) {
|
||||||
struct sway_seat *seat = config->handler_context.seat;
|
struct sway_seat *seat = config->handler_context.seat;
|
||||||
struct sway_container *con = config->handler_context.container;
|
struct sway_container *con = config->handler_context.container;
|
||||||
if (!con || con->fullscreen_mode) {
|
if (!con || con->fullscreen_mode) {
|
||||||
|
|
@ -336,7 +336,7 @@ static struct cmd_results *focus_parent(void) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *focus_child(void) {
|
static struct cmd_results focus_child(void) {
|
||||||
struct sway_seat *seat = config->handler_context.seat;
|
struct sway_seat *seat = config->handler_context.seat;
|
||||||
struct sway_node *node = config->handler_context.node;
|
struct sway_node *node = config->handler_context.node;
|
||||||
struct sway_node *focus = seat_get_active_tiling_child(seat, node);
|
struct sway_node *focus = seat_get_active_tiling_child(seat, node);
|
||||||
|
|
@ -347,7 +347,7 @@ static struct cmd_results *focus_child(void) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_focus(int argc, char **argv) {
|
struct cmd_results cmd_focus(int argc, char **argv) {
|
||||||
if (config->reading || !config->active) {
|
if (config->reading || !config->active) {
|
||||||
return cmd_results_new(CMD_DEFER, NULL);
|
return cmd_results_new(CMD_DEFER, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_focus_follows_mouse(int argc, char **argv) {
|
struct cmd_results cmd_focus_follows_mouse(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "focus_follows_mouse", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "focus_follows_mouse", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
} else if(strcmp(argv[0], "no") == 0) {
|
} else if(strcmp(argv[0], "no") == 0) {
|
||||||
config->focus_follows_mouse = FOLLOWS_NO;
|
config->focus_follows_mouse = FOLLOWS_NO;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_focus_on_window_activation(int argc, char **argv) {
|
struct cmd_results cmd_focus_on_window_activation(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "focus_on_window_activation",
|
if (checkarg(&error, argc, "focus_on_window_activation",
|
||||||
EXPECTED_EQUAL_TO, 1))) {
|
EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_focus_wrapping(int argc, char **argv) {
|
struct cmd_results cmd_focus_wrapping(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "focus_wrapping", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "focus_wrapping", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_font(int argc, char **argv) {
|
struct cmd_results cmd_font(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "font", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
char *font = join_args(argv, argc);
|
char *font = join_args(argv, argc);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_for_window(int argc, char **argv) {
|
struct cmd_results cmd_for_window(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "for_window", EXPECTED_AT_LEAST, 2))) {
|
if (checkarg(&error, argc, "for_window", EXPECTED_AT_LEAST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
|
struct cmd_results cmd_force_display_urgency_hint(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "force_display_urgency_hint",
|
if (checkarg(&error, argc, "force_display_urgency_hint",
|
||||||
EXPECTED_AT_LEAST, 1))) {
|
EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) {
|
struct cmd_results cmd_force_focus_wrapping(int argc, char **argv) {
|
||||||
sway_log(SWAY_INFO, "Warning: force_focus_wrapping is deprecated. "
|
sway_log(SWAY_INFO, "Warning: force_focus_wrapping is deprecated. "
|
||||||
"Use focus_wrapping instead.");
|
"Use focus_wrapping instead.");
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
|
|
@ -11,9 +11,8 @@ struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) {
|
||||||
"Use focus_wrapping instead.");
|
"Use focus_wrapping instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *error =
|
struct cmd_results error;
|
||||||
checkarg(argc, "force_focus_wrapping", EXPECTED_EQUAL_TO, 1);
|
if (checkarg(&error, argc, "force_focus_wrapping", EXPECTED_EQUAL_TO, 1)) {
|
||||||
if (error) {
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
// fullscreen [enable|disable|toggle] [global]
|
// fullscreen [enable|disable|toggle] [global]
|
||||||
struct cmd_results *cmd_fullscreen(int argc, char **argv) {
|
struct cmd_results cmd_fullscreen(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_MOST, 2))) {
|
if (checkarg(&error, argc, "fullscreen", EXPECTED_AT_MOST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (!root->outputs->length) {
|
if (!root->outputs->length) {
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ static void prevent_invalid_outer_gaps(void) {
|
||||||
// gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>
|
// gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>
|
||||||
static const char expected_defaults[] =
|
static const char expected_defaults[] =
|
||||||
"'gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>'";
|
"'gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>'";
|
||||||
static struct cmd_results *gaps_set_defaults(int argc, char **argv) {
|
static struct cmd_results gaps_set_defaults(int argc, char **argv) {
|
||||||
struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 2);
|
struct cmd_results error;
|
||||||
if (error) {
|
if (checkarg(&error, argc, "gaps", EXPECTED_EQUAL_TO, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,9 +136,9 @@ static void configure_gaps(struct sway_workspace *ws, void *_data) {
|
||||||
// set|plus|minus <px>
|
// set|plus|minus <px>
|
||||||
static const char expected_runtime[] = "'gaps inner|outer|horizontal|vertical|"
|
static const char expected_runtime[] = "'gaps inner|outer|horizontal|vertical|"
|
||||||
"top|right|bottom|left current|all set|plus|minus <px>'";
|
"top|right|bottom|left current|all set|plus|minus <px>'";
|
||||||
static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
|
static struct cmd_results gaps_set_runtime(int argc, char **argv) {
|
||||||
struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 4);
|
struct cmd_results error;
|
||||||
if (error) {
|
if (checkarg(&error, argc, "gaps", EXPECTED_EQUAL_TO, 4)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (!root->outputs->length) {
|
if (!root->outputs->length) {
|
||||||
|
|
@ -203,9 +203,9 @@ static struct cmd_results *gaps_set_runtime(int argc, char **argv) {
|
||||||
// gaps inner|outer|<dir>|<side> current|all set|plus|minus <px> - runtime only
|
// gaps inner|outer|<dir>|<side> current|all set|plus|minus <px> - runtime only
|
||||||
// <dir> = horizontal|vertical
|
// <dir> = horizontal|vertical
|
||||||
// <side> = top|right|bottom|left
|
// <side> = top|right|bottom|left
|
||||||
struct cmd_results *cmd_gaps(int argc, char **argv) {
|
struct cmd_results cmd_gaps(int argc, char **argv) {
|
||||||
struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 2);
|
struct cmd_results error;
|
||||||
if (error) {
|
if (checkarg(&error, argc, "gaps", EXPECTED_AT_LEAST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@
|
||||||
#include "sway/tree/arrange.h"
|
#include "sway/tree/arrange.h"
|
||||||
#include "sway/tree/view.h"
|
#include "sway/tree/view.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
|
struct cmd_results cmd_hide_edge_borders(int argc, char **argv) {
|
||||||
const char *expected_syntax = "Expected 'hide_edge_borders [--i3] "
|
const char *expected_syntax = "Expected 'hide_edge_borders [--i3] "
|
||||||
"none|vertical|horizontal|both|smart|smart_no_gaps";
|
"none|vertical|horizontal|both|smart|smart_no_gaps";
|
||||||
|
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "hide_edge_borders", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "hide_edge_borders", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_include(int argc, char **argv) {
|
struct cmd_results cmd_include(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "include", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "include", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/tree/container.h"
|
#include "sway/tree/container.h"
|
||||||
#include "sway/tree/view.h"
|
#include "sway/tree/view.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_inhibit_idle(int argc, char **argv) {
|
struct cmd_results cmd_inhibit_idle(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "inhibit_idle", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "inhibit_idle", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ static struct cmd_handler input_config_handlers[] = {
|
||||||
{ "xkb_numlock", input_cmd_xkb_numlock },
|
{ "xkb_numlock", input_cmd_xkb_numlock },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_results *cmd_input(int argc, char **argv) {
|
struct cmd_results cmd_input(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "input", EXPECTED_AT_LEAST, 2))) {
|
if (checkarg(&error, argc, "input", EXPECTED_AT_LEAST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_FAILURE, "Couldn't allocate config");
|
return cmd_results_new(CMD_FAILURE, "Couldn't allocate config");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *res;
|
struct cmd_results res;
|
||||||
|
|
||||||
if (find_handler(argv[1], input_config_handlers,
|
if (find_handler(argv[1], input_config_handlers,
|
||||||
sizeof(input_config_handlers))) {
|
sizeof(input_config_handlers))) {
|
||||||
|
|
@ -73,16 +73,14 @@ struct cmd_results *cmd_input(int argc, char **argv) {
|
||||||
input_handlers, sizeof(input_handlers));
|
input_handlers, sizeof(input_handlers));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!res || res->status == CMD_SUCCESS) &&
|
if (res.status == CMD_SUCCESS &&
|
||||||
strcmp(argv[1], "xkb_switch_layout") != 0) {
|
strcmp(argv[1], "xkb_switch_layout") != 0) {
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
struct input_config *ic =
|
struct input_config *ic =
|
||||||
store_input_config(config->handler_context.input_config, &error);
|
store_input_config(config->handler_context.input_config, &error);
|
||||||
if (!ic) {
|
if (!ic) {
|
||||||
free_input_config(config->handler_context.input_config);
|
free_input_config(config->handler_context.input_config);
|
||||||
if (res) {
|
free_cmd_results(res);
|
||||||
free_cmd_results(res);
|
|
||||||
}
|
|
||||||
res = cmd_results_new(CMD_FAILURE, "Failed to compile keymap: %s",
|
res = cmd_results_new(CMD_FAILURE, "Failed to compile keymap: %s",
|
||||||
error ? error : "(details unavailable)");
|
error ? error : "(details unavailable)");
|
||||||
free(error);
|
free(error);
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_accel_profile(int argc, char **argv) {
|
struct cmd_results input_cmd_accel_profile(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "accel_profile", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "accel_profile", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_calibration_matrix(int argc, char **argv) {
|
struct cmd_results input_cmd_calibration_matrix(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "calibration_matrix", EXPECTED_EQUAL_TO, 6))) {
|
if (checkarg(&error, argc, "calibration_matrix", EXPECTED_EQUAL_TO, 6)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_click_method(int argc, char **argv) {
|
struct cmd_results input_cmd_click_method(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "click_method", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_drag(int argc, char **argv) {
|
struct cmd_results input_cmd_drag(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "drag", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "drag", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
|
struct cmd_results input_cmd_drag_lock(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "drag_lock", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "drag_lock", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_dwt(int argc, char **argv) {
|
struct cmd_results input_cmd_dwt(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "dwt", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "dwt", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,9 @@ static void toggle_wildcard_send_events(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *input_cmd_events(int argc, char **argv) {
|
struct cmd_results input_cmd_events(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "events", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
|
struct cmd_results input_cmd_left_handed(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "left_handed", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "left_handed", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ static bool parse_coords(const char *str, double *x, double *y, bool *mm) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *input_cmd_map_from_region(int argc, char **argv) {
|
struct cmd_results input_cmd_map_from_region(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "map_from_region", EXPECTED_EQUAL_TO, 2))) {
|
if (checkarg(&error, argc, "map_from_region", EXPECTED_EQUAL_TO, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_map_to_output(int argc, char **argv) {
|
struct cmd_results input_cmd_map_to_output(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "map_to_output", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "map_to_output", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_map_to_region(int argc, char **argv) {
|
struct cmd_results input_cmd_map_to_region(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "map_to_region", EXPECTED_EQUAL_TO, 4))) {
|
if (checkarg(&error, argc, "map_to_region", EXPECTED_EQUAL_TO, 4)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
|
struct cmd_results input_cmd_middle_emulation(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "middle_emulation", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "middle_emulation", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
|
struct cmd_results input_cmd_natural_scroll(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "natural_scroll", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "natural_scroll", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) {
|
struct cmd_results input_cmd_pointer_accel(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "pointer_accel", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "pointer_accel", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_repeat_delay(int argc, char **argv) {
|
struct cmd_results input_cmd_repeat_delay(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "repeat_delay", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "repeat_delay", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_repeat_rate(int argc, char **argv) {
|
struct cmd_results input_cmd_repeat_rate(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "repeat_rate", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "repeat_rate", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/input/cursor.h"
|
#include "sway/input/cursor.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_scroll_button(int argc, char **argv) {
|
struct cmd_results input_cmd_scroll_button(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "scroll_button", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "scroll_button", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_scroll_factor(int argc, char **argv) {
|
struct cmd_results input_cmd_scroll_factor(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "scroll_factor", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "scroll_factor", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_scroll_method(int argc, char **argv) {
|
struct cmd_results input_cmd_scroll_method(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "scroll_method", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "scroll_method", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_tap(int argc, char **argv) {
|
struct cmd_results input_cmd_tap(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "tap", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "tap", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
|
struct cmd_results input_cmd_tap_button_map(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "tap_button_map", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "tap_button_map", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_capslock(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_capslock", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "xkb_capslock", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_file(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_file(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_file", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "xkb_file", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_layout(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_layout(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_layout", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "xkb_layout", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_model(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_model(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_model", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "xkb_model", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_numlock(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_numlock", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "xkb_numlock", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_options(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_options(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_options", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "xkb_options", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_rules(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_rules(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_rules", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "xkb_rules", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ static void switch_layout(struct wlr_keyboard *kbd, xkb_layout_index_t idx) {
|
||||||
kbd->modifiers.latched, kbd->modifiers.locked, idx);
|
kbd->modifiers.latched, kbd->modifiers.locked, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_switch_layout(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_switch_layout(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_switch_layout", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "xkb_switch_layout", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *input_cmd_xkb_variant(int argc, char **argv) {
|
struct cmd_results input_cmd_xkb_variant(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "xkb_variant", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "xkb_variant", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct input_config *ic = config->handler_context.input_config;
|
struct input_config *ic = config->handler_context.input_config;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ static void close_container_iterator(struct sway_container *con, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_kill(int argc, char **argv) {
|
struct cmd_results cmd_kill(int argc, char **argv) {
|
||||||
if (!root->outputs->length) {
|
if (!root->outputs->length) {
|
||||||
return cmd_results_new(CMD_INVALID,
|
return cmd_results_new(CMD_INVALID,
|
||||||
"Can't run this command while there's no outputs connected.");
|
"Can't run this command while there's no outputs connected.");
|
||||||
|
|
|
||||||
|
|
@ -114,9 +114,9 @@ static enum sway_container_layout get_layout(int argc, char **argv,
|
||||||
return L_NONE;
|
return L_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cmd_results *cmd_layout(int argc, char **argv) {
|
struct cmd_results cmd_layout(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "layout", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "layout", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (!root->outputs->length) {
|
if (!root->outputs->length) {
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
// mark --add --toggle foo Toggle current mark and persist other marks
|
// mark --add --toggle foo Toggle current mark and persist other marks
|
||||||
// mark --replace --toggle foo Toggle current mark and remove other marks
|
// mark --replace --toggle foo Toggle current mark and remove other marks
|
||||||
|
|
||||||
struct cmd_results *cmd_mark(int argc, char **argv) {
|
struct cmd_results cmd_mark(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "mark", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "mark", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
struct sway_container *container = config->handler_context.container;
|
struct sway_container *container = config->handler_context.container;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/tree/view.h"
|
#include "sway/tree/view.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_max_render_time(int argc, char **argv) {
|
struct cmd_results cmd_max_render_time(int argc, char **argv) {
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
return cmd_results_new(CMD_INVALID, "Missing max render time argument.");
|
return cmd_results_new(CMD_INVALID, "Missing max render time argument.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ static struct cmd_handler mode_handlers[] = {
|
||||||
{ "unbindsym", cmd_unbindsym },
|
{ "unbindsym", cmd_unbindsym },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_results *cmd_mode(int argc, char **argv) {
|
struct cmd_results cmd_mode(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "mode", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "mode", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ struct cmd_results *cmd_mode(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create binding
|
// Create binding
|
||||||
struct cmd_results *result = config_subcommand(argv + 1, argc - 1,
|
struct cmd_results result = config_subcommand(argv + 1, argc - 1,
|
||||||
mode_handlers, sizeof(mode_handlers));
|
mode_handlers, sizeof(mode_handlers));
|
||||||
config->current_mode = stored_mode;
|
config->current_mode = stored_mode;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_mouse_warping(int argc, char **argv) {
|
struct cmd_results cmd_mouse_warping(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "mouse_warping", EXPECTED_EQUAL_TO, 1))) {
|
if (checkarg(&error, argc, "mouse_warping", EXPECTED_EQUAL_TO, 1)) {
|
||||||
return error;
|
return error;
|
||||||
} else if (strcasecmp(argv[0], "container") == 0) {
|
} else if (strcasecmp(argv[0], "container") == 0) {
|
||||||
config->mouse_warping = WARP_CONTAINER;
|
config->mouse_warping = WARP_CONTAINER;
|
||||||
|
|
|
||||||
|
|
@ -388,13 +388,13 @@ static bool container_move_in_direction(struct sway_container *container,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *cmd_move_to_scratchpad(void);
|
static struct cmd_results cmd_move_to_scratchpad(void);
|
||||||
|
|
||||||
static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
|
static struct cmd_results cmd_move_container(bool no_auto_back_and_forth,
|
||||||
int argc, char **argv) {
|
int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "move container/window",
|
if (checkarg(&error, argc, "move container/window",
|
||||||
EXPECTED_AT_LEAST, 2))) {
|
EXPECTED_AT_LEAST, 2)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -629,9 +629,9 @@ static void workspace_move_to_output(struct sway_workspace *workspace,
|
||||||
ipc_event_workspace(NULL, workspace, "move");
|
ipc_event_workspace(NULL, workspace, "move");
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *cmd_move_workspace(int argc, char **argv) {
|
static struct cmd_results cmd_move_workspace(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "move workspace", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "move workspace", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -666,7 +666,7 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *cmd_move_in_direction(
|
static struct cmd_results cmd_move_in_direction(
|
||||||
enum wlr_direction direction, int argc, char **argv) {
|
enum wlr_direction direction, int argc, char **argv) {
|
||||||
int move_amt = 10;
|
int move_amt = 10;
|
||||||
if (argc) {
|
if (argc) {
|
||||||
|
|
@ -747,7 +747,7 @@ static const char expected_position_syntax[] =
|
||||||
"'move [absolute] position center' or "
|
"'move [absolute] position center' or "
|
||||||
"'move position cursor|mouse|pointer'";
|
"'move position cursor|mouse|pointer'";
|
||||||
|
|
||||||
static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
|
static struct cmd_results cmd_move_to_position(int argc, char **argv) {
|
||||||
struct sway_container *container = config->handler_context.container;
|
struct sway_container *container = config->handler_context.container;
|
||||||
if (!container || !container_is_floating(container)) {
|
if (!container || !container_is_floating(container)) {
|
||||||
return cmd_results_new(CMD_FAILURE, "Only floating containers "
|
return cmd_results_new(CMD_FAILURE, "Only floating containers "
|
||||||
|
|
@ -843,7 +843,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cmd_results *cmd_move_to_scratchpad(void) {
|
static struct cmd_results cmd_move_to_scratchpad(void) {
|
||||||
struct sway_node *node = config->handler_context.node;
|
struct sway_node *node = config->handler_context.node;
|
||||||
struct sway_container *con = config->handler_context.container;
|
struct sway_container *con = config->handler_context.container;
|
||||||
struct sway_workspace *ws = config->handler_context.workspace;
|
struct sway_workspace *ws = config->handler_context.workspace;
|
||||||
|
|
@ -885,9 +885,9 @@ static const char expected_full_syntax[] = "Expected "
|
||||||
" or 'move [window|container] [to] [absolute] position center'"
|
" or 'move [window|container] [to] [absolute] position center'"
|
||||||
" or 'move [window|container] [to] position mouse|cursor|pointer'";
|
" or 'move [window|container] [to] position mouse|cursor|pointer'";
|
||||||
|
|
||||||
struct cmd_results *cmd_move(int argc, char **argv) {
|
struct cmd_results cmd_move(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "move", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (!root->outputs->length) {
|
if (!root->outputs->length) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_new_float(int argc, char **argv) {
|
struct cmd_results cmd_new_float(int argc, char **argv) {
|
||||||
sway_log(SWAY_INFO, "Warning: new_float is deprecated. "
|
sway_log(SWAY_INFO, "Warning: new_float is deprecated. "
|
||||||
"Use default_floating_border instead.");
|
"Use default_floating_border instead.");
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_new_window(int argc, char **argv) {
|
struct cmd_results cmd_new_window(int argc, char **argv) {
|
||||||
sway_log(SWAY_INFO, "Warning: new_window is deprecated. "
|
sway_log(SWAY_INFO, "Warning: new_window is deprecated. "
|
||||||
"Use default_border instead.");
|
"Use default_border instead.");
|
||||||
if (config->reading) {
|
if (config->reading) {
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_no_focus(int argc, char **argv) {
|
struct cmd_results cmd_no_focus(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "no_focus", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "no_focus", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_nop(int argc, char **argv) {
|
struct cmd_results cmd_nop(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "sway/tree/view.h"
|
#include "sway/tree/view.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_opacity(int argc, char **argv) {
|
struct cmd_results cmd_opacity(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results error;
|
||||||
if ((error = checkarg(argc, "opacity", EXPECTED_AT_LEAST, 1))) {
|
if (checkarg(&error, argc, "opacity", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ static struct cmd_handler output_handlers[] = {
|
||||||
{ "transform", output_cmd_transform },
|
{ "transform", output_cmd_transform },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cmd_results *cmd_output(int argc, char **argv) {
|
struct cmd_results cmd_output(int argc, char **argv) {
|
||||||
struct cmd_results *error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1);
|
struct cmd_results error;
|
||||||
if (error != NULL) {
|
if (checkarg(&error, argc, "output", EXPECTED_AT_LEAST, 1)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (!output) {
|
if (!output) {
|
||||||
sway_log(SWAY_ERROR, "Failed to allocate output config");
|
sway_log(SWAY_ERROR, "Failed to allocate output config");
|
||||||
return NULL;
|
return cmd_results_new(CMD_FAILURE, "Failed to allocate output config");
|
||||||
}
|
}
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
"Invalid output subcommand: %s.", *argv);
|
"Invalid output subcommand: %s.", *argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error != NULL) {
|
if (error.status != CMD_SUCCESS) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue