summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-04-22 22:44:02 +0200
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-04-25 00:00:49 +0200
commit5492277f0c007eea632d242a6d7cbd9cee7cdcf6 (patch)
tree30b4e754dfc2b4a76b357a3a2f8b4833732a2bea
parentAdd support for nested tabbed/stacked containers (diff)
downloadsway-5492277f0c007eea632d242a6d7cbd9cee7cdcf6.tar.gz
sway-5492277f0c007eea632d242a6d7cbd9cee7cdcf6.tar.zst
sway-5492277f0c007eea632d242a6d7cbd9cee7cdcf6.zip
Disable inner gaps when in tabbed/stacked mode
-rw-r--r--sway/container.c3
-rw-r--r--sway/layout.c102
2 files changed, 68 insertions, 37 deletions
diff --git a/sway/container.c b/sway/container.c
index f4258c84..9db81012 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -218,6 +218,7 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
218 cont->y = child->y; 218 cont->y = child->y;
219 cont->visible = child->visible; 219 cont->visible = child->visible;
220 cont->cached_geometry = child->cached_geometry; 220 cont->cached_geometry = child->cached_geometry;
221 cont->gaps = child->gaps;
221 222
222 /* Container inherits all of workspaces children, layout and whatnot */ 223 /* Container inherits all of workspaces children, layout and whatnot */
223 if (child->type == C_WORKSPACE) { 224 if (child->type == C_WORKSPACE) {
@@ -680,7 +681,7 @@ bool swayc_is_child_of(swayc_t *child, swayc_t *parent) {
680} 681}
681 682
682int swayc_gap(swayc_t *container) { 683int swayc_gap(swayc_t *container) {
683 if (container->type == C_VIEW) { 684 if (container->type == C_VIEW || container->type == C_CONTAINER) {
684 return container->gaps >= 0 ? container->gaps : config->gaps_inner; 685 return container->gaps >= 0 ? container->gaps : config->gaps_inner;
685 } else if (container->type == C_WORKSPACE) { 686 } else if (container->type == C_WORKSPACE) {
686 int base = container->gaps >= 0 ? container->gaps : config->gaps_outer; 687 int base = container->gaps >= 0 ? container->gaps : config->gaps_outer;
diff --git a/sway/layout.c b/sway/layout.c
index 801f6f6b..f9ea5cdc 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -477,14 +477,9 @@ void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) {
477 } 477 }
478} 478}
479 479
480void update_geometry(swayc_t *container) { 480static int update_gap_geometry(swayc_t *container, struct wlc_geometry *g) {
481 if (container->type != C_VIEW && container->type != C_CONTAINER) {
482 return;
483 }
484
485 swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE); 481 swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE);
486 swayc_t *op = ws->parent; 482 swayc_t *op = ws->parent;
487 swayc_t *parent = container->parent;
488 int gap = container->is_floating ? 0 : swayc_gap(container); 483 int gap = container->is_floating ? 0 : swayc_gap(container);
489 if (gap % 2 != 0) { 484 if (gap % 2 != 0) {
490 // because gaps are implemented as "half sized margins" it's currently 485 // because gaps are implemented as "half sized margins" it's currently
@@ -492,16 +487,63 @@ void update_geometry(swayc_t *container) {
492 gap -= 1; 487 gap -= 1;
493 } 488 }
494 489
490 g->origin.x = container->x + gap/2 < op->width ? container->x + gap/2 : op->width-1;
491 g->origin.y = container->y + gap/2 < op->height ? container->y + gap/2 : op->height-1;
492 g->size.w = container->width > gap ? container->width - gap : 1;
493 g->size.h = container->height > gap ? container->height - gap : 1;
494
495 if ((!config->edge_gaps && gap > 0) || (config->smart_gaps && ws->children->length == 1)) {
496 // Remove gap against the workspace edges. Because a pixel is not
497 // divisable, depending on gap size and the number of siblings our view
498 // might be at the workspace edge without being exactly so (thus test
499 // with gap, and align correctly).
500 if (container->x - gap <= ws->x) {
501 g->origin.x = ws->x;
502 g->size.w = container->width - gap/2;
503 }
504 if (container->y - gap <= ws->y) {
505 g->origin.y = ws->y;
506 g->size.h = container->height - gap/2;
507 }
508 if (container->x + container->width + gap >= ws->x + ws->width) {
509 g->size.w = ws->x + ws->width - g->origin.x;
510 }
511 if (container->y + container->height + gap >= ws->y + ws->height) {
512 g->size.h = ws->y + ws->height - g->origin.y;
513 }
514 }
515
516 return gap;
517}
518
519void update_geometry(swayc_t *container) {
520 if (container->type != C_VIEW && container->type != C_CONTAINER) {
521 return;
522 }
523
524 swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE);
525 swayc_t *op = ws->parent;
526 swayc_t *parent = container->parent;
527
495 struct wlc_geometry geometry = { 528 struct wlc_geometry geometry = {
496 .origin = { 529 .origin = {
497 .x = container->x + gap/2 < op->width ? container->x + gap/2 : op->width-1, 530 .x = container->x < op->width ? container->x : op->width-1,
498 .y = container->y + gap/2 < op->height ? container->y + gap/2 : op->height-1 531 .y = container->y < op->height ? container->y : op->height-1
499 }, 532 },
500 .size = { 533 .size = {
501 .w = container->width > gap ? container->width - gap : 1, 534 .w = container->width,
502 .h = container->height > gap ? container->height - gap : 1, 535 .h = container->height,
503 } 536 }
504 }; 537 };
538
539 int gap = 0;
540
541 // apply inner gaps to non-tabbed/stacked containers
542 swayc_t *p = swayc_tabbed_stacked_parent(container);
543 if (p == NULL) {
544 gap = update_gap_geometry(container, &geometry);
545 }
546
505 if (swayc_is_fullscreen(container)) { 547 if (swayc_is_fullscreen(container)) {
506 swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); 548 swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
507 const struct wlc_size *size = wlc_output_get_resolution(output->handle); 549 const struct wlc_size *size = wlc_output_get_resolution(output->handle);
@@ -512,28 +554,7 @@ void update_geometry(swayc_t *container) {
512 if (op->focused == ws) { 554 if (op->focused == ws) {
513 wlc_view_bring_to_front(container->handle); 555 wlc_view_bring_to_front(container->handle);
514 } 556 }
515 } else if ((!config->edge_gaps && gap > 0) || (config->smart_gaps && ws->children->length == 1)) {
516 // Remove gap against the workspace edges. Because a pixel is not
517 // divisable, depending on gap size and the number of siblings our view
518 // might be at the workspace edge without being exactly so (thus test
519 // with gap, and align correctly).
520 if (container->x - gap <= ws->x) {
521 geometry.origin.x = ws->x;
522 geometry.size.w = container->width - gap/2;
523 }
524 if (container->y - gap <= ws->y) {
525 geometry.origin.y = ws->y;
526 geometry.size.h = container->height - gap/2;
527 }
528 if (container->x + container->width + gap >= ws->x + ws->width) {
529 geometry.size.w = ws->x + ws->width - geometry.origin.x;
530 }
531 if (container->y + container->height + gap >= ws->y + ws->height) {
532 geometry.size.h = ws->y + ws->height - geometry.origin.y;
533 }
534 }
535 557
536 if (swayc_is_fullscreen(container)) {
537 container->border_geometry = wlc_geometry_zero; 558 container->border_geometry = wlc_geometry_zero;
538 container->title_bar_geometry = wlc_geometry_zero; 559 container->title_bar_geometry = wlc_geometry_zero;
539 } else if (container->is_floating) { // allocate border for floating window 560 } else if (container->is_floating) { // allocate border for floating window
@@ -768,14 +789,23 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
768 x = container->x; 789 x = container->x;
769 y = container->y; 790 y = container->y;
770 791
792 // add gaps to top level tapped/stacked container
793 if (container->layout == L_TABBED || container->layout == L_STACKED) {
794 update_geometry(container);
795 width = container->border_geometry.size.w;
796 height = container->border_geometry.size.h;
797 x = container->border_geometry.origin.x;
798 y = container->border_geometry.origin.y;
799 }
800
771 // update container size if it's a child in a tabbed/stacked layout 801 // update container size if it's a child in a tabbed/stacked layout
772 if (swayc_is_tabbed_stacked(container)) { 802 if (swayc_is_tabbed_stacked(container)) {
773 // Use parent geometry as a base for calculating 803 // Use parent border_geometry as a base for calculating
774 // container geometry 804 // container geometry
775 container->width = container->parent->width; 805 container->width = container->parent->border_geometry.size.w;
776 container->height = container->parent->height; 806 container->height = container->parent->border_geometry.size.h;
777 container->x = container->parent->x; 807 container->x = container->parent->border_geometry.origin.x;
778 container->y = container->parent->y; 808 container->y = container->parent->border_geometry.origin.y;
779 update_geometry(container); 809 update_geometry(container);
780 width = container->width = container->actual_geometry.size.w; 810 width = container->width = container->actual_geometry.size.w;
781 height = container->height = container->actual_geometry.size.h; 811 height = container->height = container->actual_geometry.size.h;