mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
deprecate new_window and new_float commands
This commit is contained in:
parent
dc33c2cc1d
commit
18450dd16a
7 changed files with 112 additions and 87 deletions
|
@ -12,7 +12,7 @@ enum cmd_status {
|
|||
CMD_SUCCESS, /**< The command was successful */
|
||||
CMD_FAILURE, /**< The command resulted in an error */
|
||||
CMD_INVALID, /**< Unknown command or parser error */
|
||||
CMD_DEFER, /**< Command execution deferred */
|
||||
CMD_DEFER, /**< Command execution deferred */
|
||||
// Config Blocks
|
||||
CMD_BLOCK_END,
|
||||
CMD_BLOCK_MODE,
|
||||
|
@ -102,6 +102,8 @@ sway_cmd cmd_client_placeholder;
|
|||
sway_cmd cmd_client_background;
|
||||
sway_cmd cmd_commands;
|
||||
sway_cmd cmd_debuglog;
|
||||
sway_cmd cmd_default_border;
|
||||
sway_cmd cmd_default_floating_border;
|
||||
sway_cmd cmd_exec;
|
||||
sway_cmd cmd_exec_always;
|
||||
sway_cmd cmd_exit;
|
||||
|
|
|
@ -164,6 +164,8 @@ static struct cmd_handler handlers[] = {
|
|||
{ "client.urgent", cmd_client_urgent },
|
||||
{ "commands", cmd_commands },
|
||||
{ "debuglog", cmd_debuglog },
|
||||
{ "default_border", cmd_default_border },
|
||||
{ "default_floating_border", cmd_default_floating_border },
|
||||
{ "default_orientation", cmd_orientation },
|
||||
{ "exec", cmd_exec },
|
||||
{ "exec_always", cmd_exec_always },
|
||||
|
|
43
sway/commands/default_border.c
Normal file
43
sway/commands/default_border.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#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 <normal|none|pixel> [<n>]");
|
||||
}
|
||||
|
||||
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 <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_border", "Number is out out of range.");
|
||||
}
|
||||
}
|
||||
|
||||
config->border = border;
|
||||
config->border_thickness = thickness;
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
44
sway/commands/default_floating_border.c
Normal file
44
sway/commands/default_floating_border.c
Normal file
|
@ -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);
|
||||
}
|
|
@ -1,43 +1,8 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#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 <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, "new_float",
|
||||
"Expected 'border <normal|none|pixel>");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,43 +1,8 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#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 <normal|none|pixel> [<n>]");
|
||||
}
|
||||
|
||||
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 <normal|none|pixel>");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -227,6 +227,18 @@ The default colors are:
|
|||
Enables, disables or toggles debug logging. The toggle argument cannot be used
|
||||
in the configuration file.
|
||||
|
||||
**default_border** <normal|none|pixel> [<n>]::
|
||||
Set default border style for new windows. This command was previously called
|
||||
**new_window**. While **new_window** still works, it is considered deprecated
|
||||
and support for it will be removed in the future.
|
||||
|
||||
**default_floating_border** <normal|none|pixel> [<n>]::
|
||||
Set default border style for new floating windows. This only applies to
|
||||
windows that are spawned in floating mode, not windows that become floating
|
||||
after the fact. This command was previously called **new_float**. While
|
||||
**new_float** still works, it is considered deprecated and support for it will
|
||||
be removed in the future.
|
||||
|
||||
**exec** <shell command>::
|
||||
Executes _shell command_ with sh.
|
||||
|
||||
|
@ -313,14 +325,6 @@ The default colors are:
|
|||
When _output_: place mouse at center of newly focused window when changing
|
||||
output. When _none_: don't move mouse.
|
||||
|
||||
**new_window** <normal|none|pixel> [<n>]::
|
||||
Set default border style for new windows.
|
||||
|
||||
**new_float** <normal|none|pixel> [<n>]::
|
||||
Set default border style for new floating windows. This only applies to
|
||||
windows that are spawned in floating mode, not windows that become floating
|
||||
after the fact.
|
||||
|
||||
**output** <name> <resolution|res> <WIDTHxHEIGHT>::
|
||||
Configures the specified output to use the given resolution.
|
||||
+
|
||||
|
|
Loading…
Reference in a new issue