diff options
author | Zandr Martin <zandrmartin@gmail.com> | 2017-03-09 14:56:15 -0500 |
---|---|---|
committer | Zandr Martin <zandrmartin@gmail.com> | 2017-03-09 14:56:15 -0500 |
commit | 18450dd16a3909d0ea581f5f9cad4128751870cc (patch) | |
tree | 6d4a99dcb568e73f514e0fde42fe3ae7d64a30ca | |
parent | Merge pull request #1105 from zandrmartin/fix-workspace-output-assignment (diff) | |
download | sway-18450dd16a3909d0ea581f5f9cad4128751870cc.tar.gz sway-18450dd16a3909d0ea581f5f9cad4128751870cc.tar.zst sway-18450dd16a3909d0ea581f5f9cad4128751870cc.zip |
deprecate new_window and new_float commands
-rw-r--r-- | include/sway/commands.h | 4 | ||||
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/commands/default_border.c | 43 | ||||
-rw-r--r-- | sway/commands/default_floating_border.c | 44 | ||||
-rw-r--r-- | sway/commands/new_float.c | 43 | ||||
-rw-r--r-- | sway/commands/new_window.c | 43 | ||||
-rw-r--r-- | sway/sway.5.txt | 20 |
7 files changed, 112 insertions, 87 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 3ab8d5af..511bee4d 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -12,7 +12,7 @@ enum cmd_status { | |||
12 | CMD_SUCCESS, /**< The command was successful */ | 12 | CMD_SUCCESS, /**< The command was successful */ |
13 | CMD_FAILURE, /**< The command resulted in an error */ | 13 | CMD_FAILURE, /**< The command resulted in an error */ |
14 | CMD_INVALID, /**< Unknown command or parser error */ | 14 | CMD_INVALID, /**< Unknown command or parser error */ |
15 | CMD_DEFER, /**< Command execution deferred */ | 15 | CMD_DEFER, /**< Command execution deferred */ |
16 | // Config Blocks | 16 | // Config Blocks |
17 | CMD_BLOCK_END, | 17 | CMD_BLOCK_END, |
18 | CMD_BLOCK_MODE, | 18 | CMD_BLOCK_MODE, |
@@ -102,6 +102,8 @@ sway_cmd cmd_client_placeholder; | |||
102 | sway_cmd cmd_client_background; | 102 | sway_cmd cmd_client_background; |
103 | sway_cmd cmd_commands; | 103 | sway_cmd cmd_commands; |
104 | sway_cmd cmd_debuglog; | 104 | sway_cmd cmd_debuglog; |
105 | sway_cmd cmd_default_border; | ||
106 | sway_cmd cmd_default_floating_border; | ||
105 | sway_cmd cmd_exec; | 107 | sway_cmd cmd_exec; |
106 | sway_cmd cmd_exec_always; | 108 | sway_cmd cmd_exec_always; |
107 | sway_cmd cmd_exit; | 109 | sway_cmd cmd_exit; |
diff --git a/sway/commands.c b/sway/commands.c index 068e8866..58e7f655 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -164,6 +164,8 @@ static struct cmd_handler handlers[] = { | |||
164 | { "client.urgent", cmd_client_urgent }, | 164 | { "client.urgent", cmd_client_urgent }, |
165 | { "commands", cmd_commands }, | 165 | { "commands", cmd_commands }, |
166 | { "debuglog", cmd_debuglog }, | 166 | { "debuglog", cmd_debuglog }, |
167 | { "default_border", cmd_default_border }, | ||
168 | { "default_floating_border", cmd_default_floating_border }, | ||
167 | { "default_orientation", cmd_orientation }, | 169 | { "default_orientation", cmd_orientation }, |
168 | { "exec", cmd_exec }, | 170 | { "exec", cmd_exec }, |
169 | { "exec_always", cmd_exec_always }, | 171 | { "exec_always", cmd_exec_always }, |
diff --git a/sway/commands/default_border.c b/sway/commands/default_border.c new file mode 100644 index 00000000..f7710b03 --- /dev/null +++ b/sway/commands/default_border.c | |||
@@ -0,0 +1,43 @@ | |||
1 | #include <errno.h> | ||
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/container.h" | ||
5 | |||
6 | struct cmd_results *cmd_default_border(int argc, char **argv) { | ||
7 | struct cmd_results *error = NULL; | ||
8 | if ((error = checkarg(argc, "default_border", EXPECTED_AT_LEAST, 1))) { | ||
9 | return error; | ||
10 | } | ||
11 | |||
12 | if (argc > 2) { | ||
13 | return cmd_results_new(CMD_INVALID, "default_border", | ||
14 | "Expected 'default_border <normal|none|pixel> [<n>]"); | ||
15 | } | ||
16 | |||
17 | enum swayc_border_types border = config->border; | ||
18 | int thickness = config->border_thickness; | ||
19 | |||
20 | if (strcasecmp(argv[0], "none") == 0) { | ||
21 | border = B_NONE; | ||
22 | } else if (strcasecmp(argv[0], "normal") == 0) { | ||
23 | border = B_NORMAL; | ||
24 | } else if (strcasecmp(argv[0], "pixel") == 0) { | ||
25 | border = B_PIXEL; | ||
26 | } else { | ||
27 | return cmd_results_new(CMD_INVALID, "default_border", | ||
28 | "Expected 'default_border <normal|none|pixel> [<n>]"); | ||
29 | } | ||
30 | |||
31 | if (argc == 2 && (border == B_NORMAL || border == B_PIXEL)) { | ||
32 | thickness = (int)strtol(argv[1], NULL, 10); | ||
33 | if (errno == ERANGE || thickness < 0) { | ||
34 | errno = 0; | ||
35 | return cmd_results_new(CMD_INVALID, "default_border", "Number is out out of range."); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | config->border = border; | ||
40 | config->border_thickness = thickness; | ||
41 | |||
42 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
43 | } | ||
diff --git a/sway/commands/default_floating_border.c b/sway/commands/default_floating_border.c new file mode 100644 index 00000000..bbd9b0e0 --- /dev/null +++ b/sway/commands/default_floating_border.c | |||
@@ -0,0 +1,44 @@ | |||
1 | #include <errno.h> | ||
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/container.h" | ||
5 | |||
6 | struct cmd_results *cmd_default_floating_border(int argc, char **argv) { | ||
7 | struct cmd_results *error = NULL; | ||
8 | if ((error = checkarg(argc, "default_floating_border", EXPECTED_AT_LEAST, 1))) { | ||
9 | return error; | ||
10 | } | ||
11 | |||
12 | if (argc > 2) { | ||
13 | return cmd_results_new(CMD_INVALID, "default_floating_border", | ||
14 | "Expected 'default_floating_border <normal|none|pixel> [<n>]"); | ||
15 | } | ||
16 | |||
17 | enum swayc_border_types border = config->floating_border; | ||
18 | int thickness = config->floating_border_thickness; | ||
19 | |||
20 | if (strcasecmp(argv[0], "none") == 0) { | ||
21 | border = B_NONE; | ||
22 | } else if (strcasecmp(argv[0], "normal") == 0) { | ||
23 | border = B_NORMAL; | ||
24 | } else if (strcasecmp(argv[0], "pixel") == 0) { | ||
25 | border = B_PIXEL; | ||
26 | } else { | ||
27 | return cmd_results_new(CMD_INVALID, "default_floating_border", | ||
28 | "Expected 'default_floating_border <normal|none|pixel> [<n>]"); | ||
29 | } | ||
30 | |||
31 | if (argc == 2 && (border == B_NORMAL || border == B_PIXEL)) { | ||
32 | thickness = (int)strtol(argv[1], NULL, 10); | ||
33 | if (errno == ERANGE || thickness < 0) { | ||
34 | errno = 0; | ||
35 | return cmd_results_new(CMD_INVALID, "default_floating_border", | ||
36 | "Number is out out of range."); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | config->floating_border = border; | ||
41 | config->floating_border_thickness = thickness; | ||
42 | |||
43 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
44 | } | ||
diff --git a/sway/commands/new_float.c b/sway/commands/new_float.c index 8e4e354f..d0f96093 100644 --- a/sway/commands/new_float.c +++ b/sway/commands/new_float.c | |||
@@ -1,43 +1,8 @@ | |||
1 | #include <errno.h> | 1 | #include "log.h" |
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
4 | #include "sway/container.h" | ||
5 | 3 | ||
6 | struct cmd_results *cmd_new_float(int argc, char **argv) { | 4 | struct cmd_results *cmd_new_float(int argc, char **argv) { |
7 | struct cmd_results *error = NULL; | 5 | sway_log(L_INFO, "`new_float` is deprecated and will be removed in the future. " |
8 | if ((error = checkarg(argc, "new_float", EXPECTED_AT_LEAST, 1))) { | 6 | "Please use `default_floating_border` instead."); |
9 | return error; | 7 | return cmd_default_floating_border(argc, argv); |
10 | } | ||
11 | |||
12 | if (argc > 2) { | ||
13 | return cmd_results_new(CMD_INVALID, "new_float", | ||
14 | "Expected 'new_float <normal|none|pixel> [<n>]"); | ||
15 | } | ||
16 | |||
17 | enum swayc_border_types border = config->floating_border; | ||
18 | int thickness = config->floating_border_thickness; | ||
19 | |||
20 | if (strcasecmp(argv[0], "none") == 0) { | ||
21 | border = B_NONE; | ||
22 | } else if (strcasecmp(argv[0], "normal") == 0) { | ||
23 | border = B_NORMAL; | ||
24 | } else if (strcasecmp(argv[0], "pixel") == 0) { | ||
25 | border = B_PIXEL; | ||
26 | } else { | ||
27 | return cmd_results_new(CMD_INVALID, "new_float", | ||
28 | "Expected 'border <normal|none|pixel>"); | ||
29 | } | ||
30 | |||
31 | if (argc == 2 && (border == B_NORMAL || border == B_PIXEL)) { | ||
32 | thickness = (int)strtol(argv[1], NULL, 10); | ||
33 | if (errno == ERANGE || thickness < 0) { | ||
34 | errno = 0; | ||
35 | return cmd_results_new(CMD_INVALID, "new_float", "Number is out out of range."); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | config->floating_border = border; | ||
40 | config->floating_border_thickness = thickness; | ||
41 | |||
42 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
43 | } | 8 | } |
diff --git a/sway/commands/new_window.c b/sway/commands/new_window.c index 423b5af0..574a4527 100644 --- a/sway/commands/new_window.c +++ b/sway/commands/new_window.c | |||
@@ -1,43 +1,8 @@ | |||
1 | #include <errno.h> | 1 | #include "log.h" |
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
4 | #include "sway/container.h" | ||
5 | 3 | ||
6 | struct cmd_results *cmd_new_window(int argc, char **argv) { | 4 | struct cmd_results *cmd_new_window(int argc, char **argv) { |
7 | struct cmd_results *error = NULL; | 5 | sway_log(L_INFO, "`new_window` is deprecated and will be removed in the future. " |
8 | if ((error = checkarg(argc, "new_window", EXPECTED_AT_LEAST, 1))) { | 6 | "Please use `default_border` instead."); |
9 | return error; | 7 | return cmd_default_border(argc, argv); |
10 | } | ||
11 | |||
12 | if (argc > 2) { | ||
13 | return cmd_results_new(CMD_INVALID, "new_window", | ||
14 | "Expected 'new_window <normal|none|pixel> [<n>]"); | ||
15 | } | ||
16 | |||
17 | enum swayc_border_types border = config->border; | ||
18 | int thickness = config->border_thickness; | ||
19 | |||
20 | if (strcasecmp(argv[0], "none") == 0) { | ||
21 | border = B_NONE; | ||
22 | } else if (strcasecmp(argv[0], "normal") == 0) { | ||
23 | border = B_NORMAL; | ||
24 | } else if (strcasecmp(argv[0], "pixel") == 0) { | ||
25 | border = B_PIXEL; | ||
26 | } else { | ||
27 | return cmd_results_new(CMD_INVALID, "new_window", | ||
28 | "Expected 'border <normal|none|pixel>"); | ||
29 | } | ||
30 | |||
31 | if (argc == 2 && (border == B_NORMAL || border == B_PIXEL)) { | ||
32 | thickness = (int)strtol(argv[1], NULL, 10); | ||
33 | if (errno == ERANGE || thickness < 0) { | ||
34 | errno = 0; | ||
35 | return cmd_results_new(CMD_INVALID, "new_window", "Number is out out of range."); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | config->border = border; | ||
40 | config->border_thickness = thickness; | ||
41 | |||
42 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
43 | } | 8 | } |
diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 8e3f64ab..474f6790 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt | |||
@@ -227,6 +227,18 @@ The default colors are: | |||
227 | Enables, disables or toggles debug logging. The toggle argument cannot be used | 227 | Enables, disables or toggles debug logging. The toggle argument cannot be used |
228 | in the configuration file. | 228 | in the configuration file. |
229 | 229 | ||
230 | **default_border** <normal|none|pixel> [<n>]:: | ||
231 | Set default border style for new windows. This command was previously called | ||
232 | **new_window**. While **new_window** still works, it is considered deprecated | ||
233 | and support for it will be removed in the future. | ||
234 | |||
235 | **default_floating_border** <normal|none|pixel> [<n>]:: | ||
236 | Set default border style for new floating windows. This only applies to | ||
237 | windows that are spawned in floating mode, not windows that become floating | ||
238 | after the fact. This command was previously called **new_float**. While | ||
239 | **new_float** still works, it is considered deprecated and support for it will | ||
240 | be removed in the future. | ||
241 | |||
230 | **exec** <shell command>:: | 242 | **exec** <shell command>:: |
231 | Executes _shell command_ with sh. | 243 | Executes _shell command_ with sh. |
232 | 244 | ||
@@ -313,14 +325,6 @@ The default colors are: | |||
313 | When _output_: place mouse at center of newly focused window when changing | 325 | When _output_: place mouse at center of newly focused window when changing |
314 | output. When _none_: don't move mouse. | 326 | output. When _none_: don't move mouse. |
315 | 327 | ||
316 | **new_window** <normal|none|pixel> [<n>]:: | ||
317 | Set default border style for new windows. | ||
318 | |||
319 | **new_float** <normal|none|pixel> [<n>]:: | ||
320 | Set default border style for new floating windows. This only applies to | ||
321 | windows that are spawned in floating mode, not windows that become floating | ||
322 | after the fact. | ||
323 | |||
324 | **output** <name> <resolution|res> <WIDTHxHEIGHT>:: | 328 | **output** <name> <resolution|res> <WIDTHxHEIGHT>:: |
325 | Configures the specified output to use the given resolution. | 329 | Configures the specified output to use the given resolution. |
326 | + | 330 | + |