From 18450dd16a3909d0ea581f5f9cad4128751870cc Mon Sep 17 00:00:00 2001 From: Zandr Martin Date: Thu, 9 Mar 2017 14:56:15 -0500 Subject: deprecate new_window and new_float commands --- sway/commands/default_border.c | 43 ++++++++++++++++++++++++++++++++ sway/commands/default_floating_border.c | 44 +++++++++++++++++++++++++++++++++ sway/commands/new_float.c | 43 +++----------------------------- sway/commands/new_window.c | 43 +++----------------------------- 4 files changed, 95 insertions(+), 78 deletions(-) create mode 100644 sway/commands/default_border.c create mode 100644 sway/commands/default_floating_border.c (limited to 'sway/commands') 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 @@ +#include +#include +#include "sway/commands.h" +#include "sway/container.h" + +struct cmd_results *cmd_default_border(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "default_border", EXPECTED_AT_LEAST, 1))) { + return error; + } + + if (argc > 2) { + return cmd_results_new(CMD_INVALID, "default_border", + "Expected 'default_border []"); + } + + enum swayc_border_types border = config->border; + int thickness = config->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_border", + "Expected 'default_border []"); + } + + 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_border", "Number is out out of range."); + } + } + + config->border = border; + config->border_thickness = thickness; + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} 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 +#include +#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 []"); + } + + 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 []"); + } + + 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); +} 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 @@ -#include -#include +#include "log.h" #include "sway/commands.h" -#include "sway/container.h" struct cmd_results *cmd_new_float(int argc, char **argv) { - struct cmd_results *error = NULL; - if ((error = checkarg(argc, "new_float", EXPECTED_AT_LEAST, 1))) { - return error; - } - - if (argc > 2) { - return cmd_results_new(CMD_INVALID, "new_float", - "Expected 'new_float []"); - } - - 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, "new_float", - "Expected 'border "); - } - - 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, "new_float", "Number is out out of range."); - } - } - - config->floating_border = border; - config->floating_border_thickness = thickness; - - return cmd_results_new(CMD_SUCCESS, NULL, NULL); + sway_log(L_INFO, "`new_float` is deprecated and will be removed in the future. " + "Please use `default_floating_border` instead."); + return cmd_default_floating_border(argc, argv); } 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 @@ -#include -#include +#include "log.h" #include "sway/commands.h" -#include "sway/container.h" struct cmd_results *cmd_new_window(int argc, char **argv) { - struct cmd_results *error = NULL; - if ((error = checkarg(argc, "new_window", EXPECTED_AT_LEAST, 1))) { - return error; - } - - if (argc > 2) { - return cmd_results_new(CMD_INVALID, "new_window", - "Expected 'new_window []"); - } - - enum swayc_border_types border = config->border; - int thickness = config->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, "new_window", - "Expected 'border "); - } - - 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, "new_window", "Number is out out of range."); - } - } - - config->border = border; - config->border_thickness = thickness; - - return cmd_results_new(CMD_SUCCESS, NULL, NULL); + sway_log(L_INFO, "`new_window` is deprecated and will be removed in the future. " + "Please use `default_border` instead."); + return cmd_default_border(argc, argv); } -- cgit v1.2.3