summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/CMakeLists.txt1
-rw-r--r--sway/layout.c25
2 files changed, 24 insertions, 2 deletions
diff --git a/sway/CMakeLists.txt b/sway/CMakeLists.txt
index 259e9ab3..23829dc3 100644
--- a/sway/CMakeLists.txt
+++ b/sway/CMakeLists.txt
@@ -32,6 +32,7 @@ target_link_libraries(sway
32 ${PCRE_LIBRARIES} 32 ${PCRE_LIBRARIES}
33 ${JSONC_LIBRARIES} 33 ${JSONC_LIBRARIES}
34 ${WAYLAND_SERVER_LIBRARIES} 34 ${WAYLAND_SERVER_LIBRARIES}
35 m
35) 36)
36 37
37install( 38install(
diff --git a/sway/layout.c b/sway/layout.c
index 8c253fe4..d5fdbf0b 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -1,5 +1,6 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdbool.h> 2#include <stdbool.h>
3#include <math.h>
3#include <wlc/wlc.h> 4#include <wlc/wlc.h>
4#include "extensions.h" 5#include "extensions.h"
5#include "layout.h" 6#include "layout.h"
@@ -379,6 +380,11 @@ void update_geometry(swayc_t *container) {
379 swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE); 380 swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE);
380 swayc_t *op = ws->parent; 381 swayc_t *op = ws->parent;
381 int gap = container->is_floating ? 0 : swayc_gap(container); 382 int gap = container->is_floating ? 0 : swayc_gap(container);
383 if (gap % 2 != 0) {
384 // because gaps are implemented as "half sized margins" it's currently
385 // not possible to align views properly with odd sized gaps.
386 gap -= 1;
387 }
382 388
383 struct wlc_geometry geometry = { 389 struct wlc_geometry geometry = {
384 .origin = { 390 .origin = {
@@ -430,6 +436,11 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
430 width = container->width; 436 width = container->width;
431 height = container->height; 437 height = container->height;
432 } 438 }
439 // pixels are indivisable. if we don't round the pixels, then the view
440 // calculations will be off (e.g. 50.5 + 50.5 = 101, but in reality it's
441 // 50 + 50 = 100). doing it here cascades properly to all width/height/x/y.
442 width = floor(width);
443 height = floor(height);
433 444
434 sway_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", container, 445 sway_log(L_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", container,
435 container->name, container->width, container->height, container->x, container->y); 446 container->name, container->width, container->height, container->x, container->y);
@@ -539,7 +550,12 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
539 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, width, scale); 550 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, width, scale);
540 child->x = x; 551 child->x = x;
541 child->y = y; 552 child->y = y;
542 arrange_windows_r(child, child->width * scale, height); 553 if (i == container->children->length - 1) {
554 double remaining_width = container->x + width - x;
555 arrange_windows_r(child, remaining_width, height);
556 } else {
557 arrange_windows_r(child, child->width * scale, height);
558 }
543 x += child->width; 559 x += child->width;
544 } 560 }
545 } 561 }
@@ -566,7 +582,12 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
566 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, height, scale); 582 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, height, scale);
567 child->x = x; 583 child->x = x;
568 child->y = y; 584 child->y = y;
569 arrange_windows_r(child, width, child->height * scale); 585 if (i == container->children->length - 1) {
586 double remaining_height = container->y + height - y;
587 arrange_windows_r(child, width, remaining_height);
588 } else {
589 arrange_windows_r(child, width, child->height * scale);
590 }
570 y += child->height; 591 y += child->height;
571 } 592 }
572 } 593 }