From abc5fbfaec5159de7e3f6043e61c00b81787a9f2 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 4 Nov 2015 02:55:38 +0100 Subject: Learn "gaps edge_gaps ". When yes, the old behaviour of adding half the inner gap around each view is used. When no, don't add any gap when an edge of the view aligns with the workspace. The result is inner gap only between views, not against the workspace edge. The algorithm is not perfect because it means the extra space is distributed amongst edge-aligned views only, but it's simple, looks good and it works. --- sway/commands.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 19b8e1a9..2cfda07c 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -761,7 +761,8 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { return error; } const char* expected_syntax = - "Expected 'gaps '"; + "Expected 'gaps edge_gaps ' or " + "'gaps '"; const char *amount_str = argv[0]; // gaps amount if (argc >= 1 && isdigit(*amount_str)) { @@ -789,6 +790,20 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { } arrange_windows(&root_container, -1, -1); return cmd_results_new(CMD_SUCCESS, NULL, NULL); + } else if (argc == 2 && strcasecmp(argv[0], "edge_gaps") == 0) { + // gaps edge_gaps + if (strcasecmp(argv[1], "toggle") == 0) { + if (config->reading) { + return cmd_results_new(CMD_FAILURE, "gaps edge_gaps toggle", + "Can't be used in config file."); + } + config->edge_gaps = !config->edge_gaps; + } else { + config->edge_gaps = + (strcasecmp(argv[1], "yes") == 0 || strcasecmp(argv[1], "on") == 0); + } + arrange_windows(&root_container, -1, -1); + return cmd_results_new(CMD_SUCCESS, NULL, NULL); } // gaps inner|outer current|all set|plus|minus n if (argc < 4 || config->reading) { -- cgit v1.2.3