diff options
author | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-04 02:55:38 +0100 |
---|---|---|
committer | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-04 13:21:10 +0100 |
commit | abc5fbfaec5159de7e3f6043e61c00b81787a9f2 (patch) | |
tree | 325b45395cd3ccda48cb7400922fda5b4731b14b /sway/commands.c | |
parent | Merge pull request #215 from sce/gaps (diff) | |
download | sway-abc5fbfaec5159de7e3f6043e61c00b81787a9f2.tar.gz sway-abc5fbfaec5159de7e3f6043e61c00b81787a9f2.tar.zst sway-abc5fbfaec5159de7e3f6043e61c00b81787a9f2.zip |
Learn "gaps edge_gaps <on|off|toggle>".
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.
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 17 |
1 files changed, 16 insertions, 1 deletions
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) { | |||
761 | return error; | 761 | return error; |
762 | } | 762 | } |
763 | const char* expected_syntax = | 763 | const char* expected_syntax = |
764 | "Expected 'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'"; | 764 | "Expected 'gaps edge_gaps <on|off|toggle>' or " |
765 | "'gaps <inner|outer> <current|all|workspace> <set|plus|minus n>'"; | ||
765 | const char *amount_str = argv[0]; | 766 | const char *amount_str = argv[0]; |
766 | // gaps amount | 767 | // gaps amount |
767 | if (argc >= 1 && isdigit(*amount_str)) { | 768 | if (argc >= 1 && isdigit(*amount_str)) { |
@@ -789,6 +790,20 @@ static struct cmd_results *cmd_gaps(int argc, char **argv) { | |||
789 | } | 790 | } |
790 | arrange_windows(&root_container, -1, -1); | 791 | arrange_windows(&root_container, -1, -1); |
791 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 792 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
793 | } else if (argc == 2 && strcasecmp(argv[0], "edge_gaps") == 0) { | ||
794 | // gaps edge_gaps <on|off|toggle> | ||
795 | if (strcasecmp(argv[1], "toggle") == 0) { | ||
796 | if (config->reading) { | ||
797 | return cmd_results_new(CMD_FAILURE, "gaps edge_gaps toggle", | ||
798 | "Can't be used in config file."); | ||
799 | } | ||
800 | config->edge_gaps = !config->edge_gaps; | ||
801 | } else { | ||
802 | config->edge_gaps = | ||
803 | (strcasecmp(argv[1], "yes") == 0 || strcasecmp(argv[1], "on") == 0); | ||
804 | } | ||
805 | arrange_windows(&root_container, -1, -1); | ||
806 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
792 | } | 807 | } |
793 | // gaps inner|outer current|all set|plus|minus n | 808 | // gaps inner|outer current|all set|plus|minus n |
794 | if (argc < 4 || config->reading) { | 809 | if (argc < 4 || config->reading) { |