diff options
author | Zandr Martin <[email protected]> | 2017-03-09 14:56:15 -0500 |
---|---|---|
committer | Zandr Martin <[email protected]> | 2017-03-09 14:56:15 -0500 |
commit | 18450dd16a3909d0ea581f5f9cad4128751870cc (patch) | |
tree | 6d4a99dcb568e73f514e0fde42fe3ae7d64a30ca /sway/commands/default_floating_border.c | |
parent | dc33c2cc1dc0761dcdb2270bd2de0b52000874fe (diff) |
deprecate new_window and new_float commands
Diffstat (limited to 'sway/commands/default_floating_border.c')
-rw-r--r-- | sway/commands/default_floating_border.c | 44 |
1 files changed, 44 insertions, 0 deletions
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 @@ +#include <errno.h> +#include <string.h> +#include "sway/commands.h" +#include "sway/container.h" + +struct cmd_results *cmd_default_floating_border(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "default_floating_border", EXPECTED_AT_LEAST, 1))) { + return error; + } + + if (argc > 2) { + return cmd_results_new(CMD_INVALID, "default_floating_border", + "Expected 'default_floating_border <normal|none|pixel> [<n>]"); + } + + enum swayc_border_types border = config->floating_border; + int thickness = config->floating_border_thickness; + + if (strcasecmp(argv[0], "none") == 0) { + border = B_NONE; + } else if (strcasecmp(argv[0], "normal") == 0) { + border = B_NORMAL; + } else if (strcasecmp(argv[0], "pixel") == 0) { + border = B_PIXEL; + } else { + return cmd_results_new(CMD_INVALID, "default_floating_border", + "Expected 'default_floating_border <normal|none|pixel> [<n>]"); + } + + if (argc == 2 && (border == B_NORMAL || border == B_PIXEL)) { + thickness = (int)strtol(argv[1], NULL, 10); + if (errno == ERANGE || thickness < 0) { + errno = 0; + return cmd_results_new(CMD_INVALID, "default_floating_border", + "Number is out out of range."); + } + } + + config->floating_border = border; + config->floating_border_thickness = thickness; + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} |