From 86ea79ea6de62c0958511d45e755a4a7767efcd0 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Tue, 29 Mar 2016 13:49:28 +0200 Subject: [PATCH] Implement parsing of hide_edge_borders --- include/config.h | 9 +++++++++ sway/commands.c | 25 +++++++++++++++++++++++++ sway/config.c | 2 ++ sway/sway.5.txt | 3 +++ 4 files changed, 39 insertions(+) diff --git a/include/config.h b/include/config.h index 5a58c07c..fe69e310 100644 --- a/include/config.h +++ b/include/config.h @@ -156,6 +156,13 @@ struct border_colors { uint32_t child_border; }; +enum edge_border_types { + E_NONE, /**< Don't hide edge borders */ + E_VERTICAL, /**< hide vertical edge borders */ + E_HORIZONTAL, /**< hide horizontal edge borders */ + E_BOTH /**< hide vertical and horizontal edge borders */ +}; + /** * The configuration struct. The result of loading a config file. */ @@ -196,6 +203,8 @@ struct sway_config { list_t *config_chain; const char *current_config; + enum edge_border_types hide_edge_borders; + // border colors struct { struct border_colors focused; diff --git a/sway/commands.c b/sway/commands.c index 333af1b4..4a3ebf9e 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -55,6 +55,7 @@ static sway_cmd cmd_font; static sway_cmd cmd_for_window; static sway_cmd cmd_fullscreen; static sway_cmd cmd_gaps; +static sway_cmd cmd_hide_edge_borders; static sway_cmd cmd_include; static sway_cmd cmd_input; static sway_cmd cmd_kill; @@ -1506,6 +1507,29 @@ static struct cmd_results *cmd_smart_gaps(int argc, char **argv) { return cmd_results_new(CMD_SUCCESS, NULL, NULL); } +static struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "hide_edge_borders", EXPECTED_EQUAL_TO, 1))) { + return error; + } + + if (strcasecmp(argv[0], "none") == 0) { + config->hide_edge_borders = E_NONE; + } else if (strcasecmp(argv[0], "vertical") == 0) { + config->hide_edge_borders = E_VERTICAL; + } else if (strcasecmp(argv[0], "horizontal") == 0) { + config->hide_edge_borders = E_HORIZONTAL; + } else if (strcasecmp(argv[0], "both") == 0) { + config->hide_edge_borders = E_BOTH; + } else { + return cmd_results_new(CMD_INVALID, "hide_edge_borders", + "Expected 'hide_edge_borders '"); + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + + static struct cmd_results *cmd_kill(int argc, char **argv) { if (config->reading) return cmd_results_new(CMD_FAILURE, "kill", "Can't be used in config file."); if (!config->active) return cmd_results_new(CMD_FAILURE, "kill", "Can only be used when sway is running."); @@ -2063,6 +2087,7 @@ static struct cmd_handler handlers[] = { { "for_window", cmd_for_window }, { "fullscreen", cmd_fullscreen }, { "gaps", cmd_gaps }, + { "hide_edge_borders", cmd_hide_edge_borders }, { "include", cmd_include }, { "input", cmd_input }, { "kill", cmd_kill }, diff --git a/sway/config.c b/sway/config.c index 4cb8cced..565acd05 100644 --- a/sway/config.c +++ b/sway/config.c @@ -182,6 +182,8 @@ static void config_defaults(struct sway_config *config) { config->config_chain = create_list(); config->current_config = NULL; + config->hide_edge_borders = E_NONE; + // border colors config->border_colors.focused.border = 0x4C7899FF; config->border_colors.focused.background = 0x285577FF; diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 1bb5cd3b..13d304bb 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -67,6 +67,9 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( **fullscreen**:: Toggles fullscreen status for the focused view. +**hide_edge_borders** :: + Hide window borders adjacent to the screen edges. Default is _none_. + **layout** :: Sets the layout mode of the focused container. _mode_ can be one of _splith_, _splitv_, or _toggle split_.