summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-29 14:40:25 +0200
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-30 00:47:58 +0200
commit3b05f92f76c3bd9400320844e485eb06e94772cd (patch)
tree6bbd50ee74217527285e7296c841f59ab6e1fdc8
parentImplement parsing of hide_edge_borders (diff)
downloadsway-3b05f92f76c3bd9400320844e485eb06e94772cd.tar.gz
sway-3b05f92f76c3bd9400320844e485eb06e94772cd.tar.zst
sway-3b05f92f76c3bd9400320844e485eb06e94772cd.zip
Add border <none|normal|toggle|pixel> config
-rw-r--r--include/config.h2
-rw-r--r--include/container.h8
-rw-r--r--sway/commands.c51
-rw-r--r--sway/config.c3
-rw-r--r--sway/sway.5.txt9
5 files changed, 69 insertions, 4 deletions
diff --git a/include/config.h b/include/config.h
index fe69e310..a35cfd0a 100644
--- a/include/config.h
+++ b/include/config.h
@@ -203,6 +203,8 @@ struct sway_config {
203 list_t *config_chain; 203 list_t *config_chain;
204 const char *current_config; 204 const char *current_config;
205 205
206 enum swayc_border_types border;
207 int border_thickness;
206 enum edge_border_types hide_edge_borders; 208 enum edge_border_types hide_edge_borders;
207 209
208 // border colors 210 // border colors
diff --git a/include/container.h b/include/container.h
index 815898d7..07514c8a 100644
--- a/include/container.h
+++ b/include/container.h
@@ -8,7 +8,7 @@ typedef struct sway_container swayc_t;
8 8
9/** 9/**
10 * Different kinds of containers. 10 * Different kinds of containers.
11 * 11 *
12 * This enum is in order. A container will never be inside of a container below 12 * This enum is in order. A container will never be inside of a container below
13 * it on this list. 13 * it on this list.
14 */ 14 */
@@ -37,9 +37,9 @@ enum swayc_layouts {
37}; 37};
38 38
39enum swayc_border_types { 39enum swayc_border_types {
40 B_NONE, /**< No border */ 40 B_NONE, /**< No border */
41 B_PIXEL, /**< 1px border */ 41 B_PIXEL, /**< 1px border */
42 B_NORMAL /**< Normal border with title bar */ 42 B_NORMAL /**< Normal border with title bar */
43}; 43};
44 44
45/** 45/**
diff --git a/sway/commands.c b/sway/commands.c
index 4a3ebf9e..bc182cee 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -43,6 +43,7 @@ static sway_cmd cmd_assign;
43static sway_cmd cmd_bar; 43static sway_cmd cmd_bar;
44static sway_cmd cmd_bindcode; 44static sway_cmd cmd_bindcode;
45static sway_cmd cmd_bindsym; 45static sway_cmd cmd_bindsym;
46static sway_cmd cmd_border;
46static sway_cmd cmd_debuglog; 47static sway_cmd cmd_debuglog;
47static sway_cmd cmd_exec; 48static sway_cmd cmd_exec;
48static sway_cmd cmd_exec_always; 49static sway_cmd cmd_exec_always;
@@ -346,6 +347,55 @@ static struct cmd_results *cmd_bindcode(int argc, char **argv) {
346 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 347 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
347} 348}
348 349
350static struct cmd_results *cmd_border(int argc, char **argv) {
351 struct cmd_results *error = NULL;
352 if ((error = checkarg(argc, "border", EXPECTED_AT_LEAST, 1))) {
353 return error;
354 }
355
356 if (argc > 2) {
357 return cmd_results_new(CMD_FAILURE, "border",
358 "Expected 'border <normal|pixel|none|toggle> [<n>]");
359 }
360
361 enum swayc_border_types border = config->border;
362
363 if (strcasecmp(argv[0], "none") == 0) {
364 border = B_NONE;
365 } else if (strcasecmp(argv[0], "normal") == 0) {
366 border = B_NORMAL;
367 } else if (strcasecmp(argv[0], "pixel") == 0) {
368 border = B_PIXEL;
369 } else if (strcasecmp(argv[0], "toggle") == 0) {
370 switch (config->border) {
371 case B_NONE:
372 border = B_PIXEL;
373 break;
374 case B_NORMAL:
375 border = B_NONE;
376 break;
377 case B_PIXEL:
378 border = B_NORMAL;
379 break;
380 }
381 } else {
382 return cmd_results_new(CMD_FAILURE, "border",
383 "Expected 'border <normal|pixel|none|toggle>");
384 }
385
386 if (argc == 2 && (border == B_NORMAL || border == B_PIXEL)) {
387 int thickness = (int)strtol(argv[1], NULL, 10);
388 if (errno == ERANGE || thickness < 0) {
389 errno = 0;
390 return cmd_results_new(CMD_INVALID, "border", "Number is out out of range.");
391 }
392 config->border_thickness = thickness;
393 }
394
395 config->border = border;
396 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
397}
398
349static struct cmd_results *cmd_exec_always(int argc, char **argv) { 399static struct cmd_results *cmd_exec_always(int argc, char **argv) {
350 struct cmd_results *error = NULL; 400 struct cmd_results *error = NULL;
351 if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); 401 if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL);
@@ -2074,6 +2124,7 @@ static struct cmd_handler handlers[] = {
2074 { "bar", cmd_bar }, 2124 { "bar", cmd_bar },
2075 { "bindcode", cmd_bindcode }, 2125 { "bindcode", cmd_bindcode },
2076 { "bindsym", cmd_bindsym }, 2126 { "bindsym", cmd_bindsym },
2127 { "border", cmd_border },
2077 { "debuglog", cmd_debuglog }, 2128 { "debuglog", cmd_debuglog },
2078 { "default_orientation", cmd_orientation }, 2129 { "default_orientation", cmd_orientation },
2079 { "exec", cmd_exec }, 2130 { "exec", cmd_exec },
diff --git a/sway/config.c b/sway/config.c
index 565acd05..193cfad2 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -182,6 +182,9 @@ static void config_defaults(struct sway_config *config) {
182 config->config_chain = create_list(); 182 config->config_chain = create_list();
183 config->current_config = NULL; 183 config->current_config = NULL;
184 184
185 // borders
186 config->border = B_NORMAL;
187 config->border_thickness = 2;
185 config->hide_edge_borders = E_NONE; 188 config->hide_edge_borders = E_NONE;
186 189
187 // border colors 190 // border colors
diff --git a/sway/sway.5.txt b/sway/sway.5.txt
index 13d304bb..2eb0276c 100644
--- a/sway/sway.5.txt
+++ b/sway/sway.5.txt
@@ -43,6 +43,15 @@ The following commands may only be used in the configuration file.
43The following commands cannot be used directly in the configuration file. 43The following commands cannot be used directly in the configuration file.
44They are expected to be used with **bindsym** or at runtime through **swaymsg**(1). 44They are expected to be used with **bindsym** or at runtime through **swaymsg**(1).
45 45
46**border** <normal|pixel> [<n>]::
47 Set border style for windows. _normal_ includes a border of thickness _n_ and
48 a title bar. _pixel_ is just the border without title bar. Default is _normal_
49 with border thickness 2.
50
51**border** <none|toggle>::
52 Set border style to _none_ or _toggle_ between the available border styles:
53 _normal_, _pixel_, _none_.
54
46**exit**:: 55**exit**::
47 Exit sway and end your Wayland session. 56 Exit sway and end your Wayland session.
48 57