diff options
-rw-r--r-- | include/config.h | 1 | ||||
-rw-r--r-- | sway.5.txt | 5 | ||||
-rw-r--r-- | sway/commands.c | 17 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/layout.c | 20 |
5 files changed, 42 insertions, 2 deletions
diff --git a/include/config.h b/include/config.h index 56fba691..636d3ec0 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -57,6 +57,7 @@ struct sway_config { | |||
57 | bool auto_back_and_forth; | 57 | bool auto_back_and_forth; |
58 | bool seamless_mouse; | 58 | bool seamless_mouse; |
59 | 59 | ||
60 | bool edge_gaps; | ||
60 | int gaps_inner; | 61 | int gaps_inner; |
61 | int gaps_outer; | 62 | int gaps_outer; |
62 | }; | 63 | }; |
@@ -68,6 +68,11 @@ Commands | |||
68 | **fullscreen**:: | 68 | **fullscreen**:: |
69 | Toggles fullscreen status for the focused view. | 69 | Toggles fullscreen status for the focused view. |
70 | 70 | ||
71 | **gaps** edge_gaps <on|off|toggle>:: | ||
72 | Whether or not to add gaps between views and workspace edges if amount of | ||
73 | inner gap is not zero. When _no_, no gap is added where the view is aligned to | ||
74 | the workspace edge, effectively creating gaps only between views. | ||
75 | |||
71 | **gaps** <amount>:: | 76 | **gaps** <amount>:: |
72 | Sets default _amount_ pixels as the gap between each view, and around each | 77 | Sets default _amount_ pixels as the gap between each view, and around each |
73 | workspace. | 78 | workspace. |
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) { |
diff --git a/sway/config.c b/sway/config.c index 7e0b22f9..20e4919d 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -105,6 +105,7 @@ static void config_defaults(struct sway_config *config) { | |||
105 | config->seamless_mouse = true; | 105 | config->seamless_mouse = true; |
106 | config->reading = false; | 106 | config->reading = false; |
107 | 107 | ||
108 | config->edge_gaps = false; | ||
108 | config->gaps_inner = 0; | 109 | config->gaps_inner = 0; |
109 | config->gaps_outer = 0; | 110 | config->gaps_outer = 0; |
110 | } | 111 | } |
diff --git a/sway/layout.c b/sway/layout.c index c6a05107..3bc297a6 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -367,9 +367,27 @@ void update_geometry(swayc_t *container) { | |||
367 | if (op->focused == ws) { | 367 | if (op->focused == ws) { |
368 | wlc_view_bring_to_front(container->handle); | 368 | wlc_view_bring_to_front(container->handle); |
369 | } | 369 | } |
370 | } else if (!config->edge_gaps && gap > 0) { | ||
371 | // Remove gap against the workspace edges. Because a pixel is not | ||
372 | // divisable, depending on gap size and the number of siblings our view | ||
373 | // might be at the workspace edge without being exactly so (thus test | ||
374 | // with gap, and align correctly). | ||
375 | if (container->x - gap <= ws->x) { | ||
376 | geometry.origin.x = ws->x; | ||
377 | geometry.size.w = container->width - gap/2; | ||
378 | } | ||
379 | if (container->y - gap <= ws->y) { | ||
380 | geometry.origin.y = ws->y; | ||
381 | geometry.size.h = container->height - gap/2; | ||
382 | } | ||
383 | if (container->x + container->width + gap >= ws->x + ws->width) { | ||
384 | geometry.size.w = ws->width - geometry.origin.x; | ||
385 | } | ||
386 | if (container->y + container->height + gap >= ws->y + ws->height) { | ||
387 | geometry.size.h = ws->height - geometry.origin.y; | ||
388 | } | ||
370 | } | 389 | } |
371 | wlc_view_set_geometry(container->handle, 0, &geometry); | 390 | wlc_view_set_geometry(container->handle, 0, &geometry); |
372 | return; | ||
373 | } | 391 | } |
374 | 392 | ||
375 | static void arrange_windows_r(swayc_t *container, double width, double height) { | 393 | static void arrange_windows_r(swayc_t *container, double width, double height) { |