aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-05-12 08:59:25 -0400
committerDrew DeVault <sir@cmpwn.com>2018-05-12 08:59:25 -0400
commita2d7079b263290ccc7259a0d16749dbd0baae821 (patch)
tree88798745e165f6f9d9f01e66b3f0d6c817353c1b /sway/commands.c
parentda679a8051c854a1897f4701c64b5a2914be0bde (diff)
parent32a572cecfd0f6072a78ce0a381a2f8365f9010a (diff)
Merge branch 'master' into scdoc
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 811f6cfa..2e1cdc2c 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -12,7 +12,6 @@
#include "sway/security.h"
#include "sway/input/input-manager.h"
#include "sway/input/seat.h"
-#include "sway/tree/view.h"
#include "stringop.h"
#include "log.h"
@@ -284,7 +283,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
char *head = exec;
char *cmdlist;
char *cmd;
- list_t *views = NULL;
+ list_t *containers = NULL;
if (seat == NULL) {
// passing a NULL seat means we just pick the default seat
@@ -301,18 +300,31 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
// Extract criteria (valid for this command list only).
bool has_criteria = false;
if (*head == '[') {
- char *error = NULL;
- struct criteria *criteria = criteria_parse(head, &error);
- if (!criteria) {
- results = cmd_results_new(CMD_INVALID, head,
- "%s", error);
- free(error);
+ has_criteria = true;
+ ++head;
+ char *criteria_string = argsep(&head, "]");
+ if (head) {
+ ++head;
+ list_t *tokens = create_list();
+ char *error;
+
+ if ((error = extract_crit_tokens(tokens, criteria_string))) {
+ wlr_log(L_DEBUG, "criteria string parse error: %s", error);
+ results = cmd_results_new(CMD_INVALID, criteria_string,
+ "Can't parse criteria string: %s", error);
+ free(error);
+ free(tokens);
+ goto cleanup;
+ }
+ containers = container_for_crit_tokens(tokens);
+
+ free(tokens);
+ } else {
+ if (!results) {
+ results = cmd_results_new(CMD_INVALID, criteria_string, "Unmatched [");
+ }
goto cleanup;
}
- views = criteria_get_views(criteria);
- head += strlen(criteria->raw);
- criteria_destroy(criteria);
- has_criteria = true;
// Skip leading whitespace
head += strspn(head, whitespace);
}
@@ -369,9 +381,8 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
}
free_cmd_results(res);
} else {
- for (int i = 0; i < views->length; ++i) {
- struct sway_view *view = views->items[i];
- config->handler_context.current_container = view->swayc;
+ for (int i = 0; i < containers->length; ++i) {
+ config->handler_context.current_container = containers->items[i];
struct cmd_results *res = handler->handle(argc-1, argv+1);
if (res->status != CMD_SUCCESS) {
free_argv(argc, argv);
@@ -389,7 +400,6 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
} while(head);
cleanup:
free(exec);
- free(views);
if (!results) {
results = cmd_results_new(CMD_SUCCESS, NULL, NULL);
}