Add border <none|normal|toggle|pixel> config
This commit is contained in:
parent
86ea79ea6d
commit
3b05f92f76
|
@ -203,6 +203,8 @@ struct sway_config {
|
||||||
list_t *config_chain;
|
list_t *config_chain;
|
||||||
const char *current_config;
|
const char *current_config;
|
||||||
|
|
||||||
|
enum swayc_border_types border;
|
||||||
|
int border_thickness;
|
||||||
enum edge_border_types hide_edge_borders;
|
enum edge_border_types hide_edge_borders;
|
||||||
|
|
||||||
// border colors
|
// border colors
|
||||||
|
|
|
@ -43,6 +43,7 @@ static sway_cmd cmd_assign;
|
||||||
static sway_cmd cmd_bar;
|
static sway_cmd cmd_bar;
|
||||||
static sway_cmd cmd_bindcode;
|
static sway_cmd cmd_bindcode;
|
||||||
static sway_cmd cmd_bindsym;
|
static sway_cmd cmd_bindsym;
|
||||||
|
static sway_cmd cmd_border;
|
||||||
static sway_cmd cmd_debuglog;
|
static sway_cmd cmd_debuglog;
|
||||||
static sway_cmd cmd_exec;
|
static sway_cmd cmd_exec;
|
||||||
static sway_cmd cmd_exec_always;
|
static sway_cmd cmd_exec_always;
|
||||||
|
@ -346,6 +347,55 @@ static struct cmd_results *cmd_bindcode(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct cmd_results *cmd_border(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "border", EXPECTED_AT_LEAST, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 2) {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "border",
|
||||||
|
"Expected 'border <normal|pixel|none|toggle> [<n>]");
|
||||||
|
}
|
||||||
|
|
||||||
|
enum swayc_border_types border = config->border;
|
||||||
|
|
||||||
|
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 if (strcasecmp(argv[0], "toggle") == 0) {
|
||||||
|
switch (config->border) {
|
||||||
|
case B_NONE:
|
||||||
|
border = B_PIXEL;
|
||||||
|
break;
|
||||||
|
case B_NORMAL:
|
||||||
|
border = B_NONE;
|
||||||
|
break;
|
||||||
|
case B_PIXEL:
|
||||||
|
border = B_NORMAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_FAILURE, "border",
|
||||||
|
"Expected 'border <normal|pixel|none|toggle>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc == 2 && (border == B_NORMAL || border == B_PIXEL)) {
|
||||||
|
int thickness = (int)strtol(argv[1], NULL, 10);
|
||||||
|
if (errno == ERANGE || thickness < 0) {
|
||||||
|
errno = 0;
|
||||||
|
return cmd_results_new(CMD_INVALID, "border", "Number is out out of range.");
|
||||||
|
}
|
||||||
|
config->border_thickness = thickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
config->border = border;
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
static struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL);
|
if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL);
|
||||||
|
@ -2074,6 +2124,7 @@ static struct cmd_handler handlers[] = {
|
||||||
{ "bar", cmd_bar },
|
{ "bar", cmd_bar },
|
||||||
{ "bindcode", cmd_bindcode },
|
{ "bindcode", cmd_bindcode },
|
||||||
{ "bindsym", cmd_bindsym },
|
{ "bindsym", cmd_bindsym },
|
||||||
|
{ "border", cmd_border },
|
||||||
{ "debuglog", cmd_debuglog },
|
{ "debuglog", cmd_debuglog },
|
||||||
{ "default_orientation", cmd_orientation },
|
{ "default_orientation", cmd_orientation },
|
||||||
{ "exec", cmd_exec },
|
{ "exec", cmd_exec },
|
||||||
|
|
|
@ -182,6 +182,9 @@ static void config_defaults(struct sway_config *config) {
|
||||||
config->config_chain = create_list();
|
config->config_chain = create_list();
|
||||||
config->current_config = NULL;
|
config->current_config = NULL;
|
||||||
|
|
||||||
|
// borders
|
||||||
|
config->border = B_NORMAL;
|
||||||
|
config->border_thickness = 2;
|
||||||
config->hide_edge_borders = E_NONE;
|
config->hide_edge_borders = E_NONE;
|
||||||
|
|
||||||
// border colors
|
// border colors
|
||||||
|
|
|
@ -43,6 +43,15 @@ The following commands may only be used in the configuration file.
|
||||||
The following commands cannot be used directly in the configuration file.
|
The following commands cannot be used directly in the configuration file.
|
||||||
They are expected to be used with **bindsym** or at runtime through **swaymsg**(1).
|
They are expected to be used with **bindsym** or at runtime through **swaymsg**(1).
|
||||||
|
|
||||||
|
**border** <normal|pixel> [<n>]::
|
||||||
|
Set border style for windows. _normal_ includes a border of thickness _n_ and
|
||||||
|
a title bar. _pixel_ is just the border without title bar. Default is _normal_
|
||||||
|
with border thickness 2.
|
||||||
|
|
||||||
|
**border** <none|toggle>::
|
||||||
|
Set border style to _none_ or _toggle_ between the available border styles:
|
||||||
|
_normal_, _pixel_, _none_.
|
||||||
|
|
||||||
**exit**::
|
**exit**::
|
||||||
Exit sway and end your Wayland session.
|
Exit sway and end your Wayland session.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue