summaryrefslogtreecommitdiffstats
path: root/sway/commands.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-11-27 10:20:16 -0700
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-11-27 10:20:16 -0700
commitb7702eb34c9d5485145b0483891e710fae12e967 (patch)
treef87d318d7701b572932687a1f388af2ec6458b15 /sway/commands.c
parentMerge pull request #265 from sce/better_logging (diff)
parentworkspace: Learn sticky. (diff)
downloadsway-b7702eb34c9d5485145b0483891e710fae12e967.tar.gz
sway-b7702eb34c9d5485145b0483891e710fae12e967.tar.zst
sway-b7702eb34c9d5485145b0483891e710fae12e967.zip
Merge pull request #266 from sce/sticky_floats_0
workspace: Learn sticky.
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c
index f1dbc09e..a46a0b89 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -33,7 +33,6 @@ struct cmd_handler {
33}; 33};
34 34
35static sway_cmd cmd_bindsym; 35static sway_cmd cmd_bindsym;
36static sway_cmd cmd_orientation;
37static sway_cmd cmd_debuglog; 36static sway_cmd cmd_debuglog;
38static sway_cmd cmd_exec; 37static sway_cmd cmd_exec;
39static sway_cmd cmd_exec_always; 38static sway_cmd cmd_exec_always;
@@ -51,6 +50,7 @@ static sway_cmd cmd_log_colors;
51static sway_cmd cmd_mode; 50static sway_cmd cmd_mode;
52static sway_cmd cmd_mouse_warping; 51static sway_cmd cmd_mouse_warping;
53static sway_cmd cmd_move; 52static sway_cmd cmd_move;
53static sway_cmd cmd_orientation;
54static sway_cmd cmd_output; 54static sway_cmd cmd_output;
55static sway_cmd cmd_reload; 55static sway_cmd cmd_reload;
56static sway_cmd cmd_resize; 56static sway_cmd cmd_resize;
@@ -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};