summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 960244c0..a46a0b89 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -59,6 +59,7 @@ static sway_cmd cmd_set;
59static sway_cmd cmd_split; 59static sway_cmd cmd_split;
60static sway_cmd cmd_splith; 60static sway_cmd cmd_splith;
61static sway_cmd cmd_splitv; 61static sway_cmd cmd_splitv;
62static sway_cmd cmd_sticky;
62static sway_cmd cmd_workspace; 63static sway_cmd cmd_workspace;
63static sway_cmd cmd_ws_auto_back_and_forth; 64static sway_cmd cmd_ws_auto_back_and_forth;
64 65
@@ -1237,6 +1238,28 @@ static struct cmd_results *cmd_splith(int argc, char **argv) {
1237 return _do_split(argc, argv, L_HORIZ); 1238 return _do_split(argc, argv, L_HORIZ);
1238} 1239}
1239 1240
1241static struct cmd_results *cmd_sticky(int argc, char **argv) {
1242 struct cmd_results *error = NULL;
1243 if (config->reading) return cmd_results_new(CMD_FAILURE, "sticky", "Can't be used in config file.");
1244 if (!config->active) return cmd_results_new(CMD_FAILURE, "sticky", "Can only be used when sway is running.");
1245 if ((error = checkarg(argc, "sticky", EXPECTED_EQUAL_TO, 1))) {
1246 return error;
1247 }
1248 char *action = argv[0];
1249 swayc_t *cont = get_focused_view(&root_container);
1250 if (strcmp(action, "toggle") == 0) {
1251 cont->sticky = !cont->sticky;
1252 } else if (strcmp(action, "enable") == 0) {
1253 cont->sticky = true;
1254 } else if (strcmp(action, "disable") == 0) {
1255 cont->sticky = false;
1256 } else {
1257 return cmd_results_new(CMD_FAILURE, "sticky",
1258 "Expected 'sticky enable|disable|toggle'");
1259 }
1260 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
1261}
1262
1240static struct cmd_results *cmd_log_colors(int argc, char **argv) { 1263static struct cmd_results *cmd_log_colors(int argc, char **argv) {
1241 struct cmd_results *error = NULL; 1264 struct cmd_results *error = NULL;
1242 if (!config->reading) return cmd_results_new(CMD_FAILURE, "log_colors", "Can only be used in config file."); 1265 if (!config->reading) return cmd_results_new(CMD_FAILURE, "log_colors", "Can only be used in config file.");
@@ -1416,6 +1439,7 @@ static struct cmd_handler handlers[] = {
1416 { "split", cmd_split }, 1439 { "split", cmd_split },
1417 { "splith", cmd_splith }, 1440 { "splith", cmd_splith },
1418 { "splitv", cmd_splitv }, 1441 { "splitv", cmd_splitv },
1442 { "sticky", cmd_sticky },
1419 { "workspace", cmd_workspace }, 1443 { "workspace", cmd_workspace },
1420 { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, 1444 { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth },
1421}; 1445};