diff options
author | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-26 23:53:20 +0100 |
---|---|---|
committer | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-27 17:58:10 +0100 |
commit | 2d0f78c0d6fb67b38c056856608708be610b7096 (patch) | |
tree | f87d318d7701b572932687a1f388af2ec6458b15 /sway/commands.c | |
parent | commands: code formatting: Sort list of commands by alphabet. (diff) | |
download | sway-2d0f78c0d6fb67b38c056856608708be610b7096.tar.gz sway-2d0f78c0d6fb67b38c056856608708be610b7096.tar.zst sway-2d0f78c0d6fb67b38c056856608708be610b7096.zip |
workspace: Learn sticky.
A floating window that's sticky will move to the new active workspace
whenever the workspace on the same output changes.
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 24 |
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; | |||
59 | static sway_cmd cmd_split; | 59 | static sway_cmd cmd_split; |
60 | static sway_cmd cmd_splith; | 60 | static sway_cmd cmd_splith; |
61 | static sway_cmd cmd_splitv; | 61 | static sway_cmd cmd_splitv; |
62 | static sway_cmd cmd_sticky; | ||
62 | static sway_cmd cmd_workspace; | 63 | static sway_cmd cmd_workspace; |
63 | static sway_cmd cmd_ws_auto_back_and_forth; | 64 | static 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 | ||
1241 | static 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 | |||
1240 | static struct cmd_results *cmd_log_colors(int argc, char **argv) { | 1263 | static 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 | }; |