diff options
-rw-r--r-- | sway/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sway/handlers.c | 4 | ||||
-rw-r--r-- | sway/layout.c | 42 |
3 files changed, 35 insertions, 12 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 | ||
37 | install( | 38 | install( |
diff --git a/sway/handlers.c b/sway/handlers.c index 751e894c..b8bd9eff 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -279,8 +279,8 @@ static void handle_view_focus(wlc_handle view, bool focus) { | |||
279 | } | 279 | } |
280 | 280 | ||
281 | static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) { | 281 | static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) { |
282 | sway_log(L_DEBUG, "geometry request for %ld %dx%d : %dx%d", | 282 | sway_log(L_DEBUG, "geometry request for %ld %dx%d @ %d,%d", handle, |
283 | handle, geometry->origin.x, geometry->origin.y, geometry->size.w, geometry->size.h); | 283 | geometry->size.w, geometry->size.h, geometry->origin.x, geometry->origin.y); |
284 | // If the view is floating, then apply the geometry. | 284 | // If the view is floating, then apply the geometry. |
285 | // Otherwise save the desired width/height for the view. | 285 | // Otherwise save the desired width/height for the view. |
286 | // This will not do anything for the time being as WLC improperly sends geometry requests | 286 | // This will not do anything for the time being as WLC improperly sends geometry requests |
diff --git a/sway/layout.c b/sway/layout.c index d7265605..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,11 +436,16 @@ 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); |
436 | 447 | ||
437 | int x = 0, y = 0; | 448 | double x = 0, y = 0; |
438 | switch (container->type) { | 449 | switch (container->type) { |
439 | case C_ROOT: | 450 | case C_ROOT: |
440 | for (i = 0; i < container->children->length; ++i) { | 451 | for (i = 0; i < container->children->length; ++i) { |
@@ -489,8 +500,8 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
489 | } | 500 | } |
490 | } | 501 | } |
491 | int gap = swayc_gap(container); | 502 | int gap = swayc_gap(container); |
492 | container->x = x + gap; | 503 | x = container->x = x + gap; |
493 | container->y = y + gap; | 504 | y = container->y = y + gap; |
494 | width = container->width = width - gap * 2; | 505 | width = container->width = width - gap * 2; |
495 | height = container->height = height - gap * 2; | 506 | height = container->height = height - gap * 2; |
496 | sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", container->name, container->x, container->y); | 507 | sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", container->name, container->x, container->y); |
@@ -509,10 +520,11 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
509 | default: | 520 | default: |
510 | container->width = width; | 521 | container->width = width; |
511 | container->height = height; | 522 | container->height = height; |
523 | x = container->x; | ||
524 | y = container->y; | ||
512 | break; | 525 | break; |
513 | } | 526 | } |
514 | 527 | ||
515 | x = y = 0; | ||
516 | double scale = 0; | 528 | double scale = 0; |
517 | switch (container->layout) { | 529 | switch (container->layout) { |
518 | case L_HORIZ: | 530 | case L_HORIZ: |
@@ -536,9 +548,14 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
536 | for (i = 0; i < container->children->length; ++i) { | 548 | for (i = 0; i < container->children->length; ++i) { |
537 | swayc_t *child = container->children->items[i]; | 549 | swayc_t *child = container->children->items[i]; |
538 | 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); |
539 | child->x = x + container->x; | 551 | child->x = x; |
540 | child->y = y + container->y; | 552 | child->y = y; |
541 | 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 | } | ||
542 | x += child->width; | 559 | x += child->width; |
543 | } | 560 | } |
544 | } | 561 | } |
@@ -563,9 +580,14 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { | |||
563 | for (i = 0; i < container->children->length; ++i) { | 580 | for (i = 0; i < container->children->length; ++i) { |
564 | swayc_t *child = container->children->items[i]; | 581 | swayc_t *child = container->children->items[i]; |
565 | 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); |
566 | child->x = x + container->x; | 583 | child->x = x; |
567 | child->y = y + container->y; | 584 | child->y = y; |
568 | 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 | } | ||
569 | y += child->height; | 591 | y += child->height; |
570 | } | 592 | } |
571 | } | 593 | } |