diff options
author | Luminarys <kizunanohikari@gmail.com> | 2015-08-21 21:22:29 -0500 |
---|---|---|
committer | Luminarys <kizunanohikari@gmail.com> | 2015-08-21 21:22:29 -0500 |
commit | ad1ca31dd5a36736176002ec7b7c9548cd63113d (patch) | |
tree | 31eb7742d4f2b5ede4cdf408d19e721c8b2fca43 | |
parent | More resize fixes (diff) | |
download | sway-ad1ca31dd5a36736176002ec7b7c9548cd63113d.tar.gz sway-ad1ca31dd5a36736176002ec7b7c9548cd63113d.tar.zst sway-ad1ca31dd5a36736176002ec7b7c9548cd63113d.zip |
Altered resize command to prevent resizing past min h/w
-rw-r--r-- | sway/commands.c | 147 | ||||
-rw-r--r-- | sway/handlers.c | 2 |
2 files changed, 117 insertions, 32 deletions
diff --git a/sway/commands.c b/sway/commands.c index ef76c169..36299c8d 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -497,43 +497,85 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { | |||
497 | } | 497 | } |
498 | sway_log(L_DEBUG, "Found the proper parent: %p. It has %d l conts, and %d r conts", parent->parent, lnumber, rnumber); | 498 | sway_log(L_DEBUG, "Found the proper parent: %p. It has %d l conts, and %d r conts", parent->parent, lnumber, rnumber); |
499 | //TODO: Ensure rounding is done in such a way that there are NO pixel leaks | 499 | //TODO: Ensure rounding is done in such a way that there are NO pixel leaks |
500 | bool valid = true; | ||
500 | for (i = 0; i < parent->parent->children->length; i++) { | 501 | for (i = 0; i < parent->parent->children->length; i++) { |
501 | bool valid = true; | ||
502 | sibling = parent->parent->children->items[i]; | 502 | sibling = parent->parent->children->items[i]; |
503 | if (sibling->x != focused->x) { | 503 | if (sibling->x != focused->x) { |
504 | if (sibling->x < parent->x) { | 504 | if (sibling->x < parent->x) { |
505 | double pixels = -1 * amount; | 505 | double pixels = -1 * amount; |
506 | pixels /= lnumber; | 506 | pixels /= lnumber; |
507 | if (rnumber) { | 507 | if (rnumber) { |
508 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_RIGHT); | 508 | if ((sibling->width + pixels/2) < min_sane_w) { |
509 | valid = false; | ||
510 | break; | ||
511 | } | ||
509 | } else { | 512 | } else { |
510 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_RIGHT); | 513 | if ((sibling->width + pixels) < min_sane_w) { |
514 | valid = false; | ||
515 | break; | ||
516 | } | ||
511 | } | 517 | } |
512 | } else if (sibling->x > parent->x) { | 518 | } else if (sibling->x > parent->x) { |
513 | double pixels = -1 * amount; | 519 | double pixels = -1 * amount; |
514 | pixels /= rnumber; | 520 | pixels /= rnumber; |
515 | if (lnumber) { | 521 | if (lnumber) { |
516 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_LEFT); | 522 | if ((sibling->width + pixels/2) < min_sane_w) { |
523 | valid = false; | ||
524 | break; | ||
525 | } | ||
517 | } else { | 526 | } else { |
518 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_LEFT); | 527 | if ((sibling->width + pixels) < min_sane_w) { |
528 | valid = false; | ||
529 | break; | ||
530 | } | ||
519 | } | 531 | } |
520 | } | 532 | } |
521 | } else { | 533 | } else { |
522 | if (rnumber != 0 && lnumber != 0) { | 534 | double pixels = amount; |
523 | double pixels = amount; | 535 | if (parent->width + pixels < min_sane_w) { |
524 | pixels /= 2; | 536 | valid = false; |
525 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_LEFT); | 537 | break; |
526 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_RIGHT); | ||
527 | } else if (rnumber) { | ||
528 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_RIGHT); | ||
529 | } else if (lnumber) { | ||
530 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_LEFT); | ||
531 | } | 538 | } |
532 | } | 539 | } |
533 | } | 540 | } |
534 | // Recursive resize does not handle positions, let arrange_windows | 541 | if (valid) { |
535 | // take care of that. | 542 | for (i = 0; i < parent->parent->children->length; i++) { |
536 | arrange_windows(swayc_active_workspace(), -1, -1); | 543 | sibling = parent->parent->children->items[i]; |
544 | if (sibling->x != focused->x) { | ||
545 | if (sibling->x < parent->x) { | ||
546 | double pixels = -1 * amount; | ||
547 | pixels /= lnumber; | ||
548 | if (rnumber) { | ||
549 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_RIGHT); | ||
550 | } else { | ||
551 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_RIGHT); | ||
552 | } | ||
553 | } else if (sibling->x > parent->x) { | ||
554 | double pixels = -1 * amount; | ||
555 | pixels /= rnumber; | ||
556 | if (lnumber) { | ||
557 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_LEFT); | ||
558 | } else { | ||
559 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_LEFT); | ||
560 | } | ||
561 | } | ||
562 | } else { | ||
563 | if (rnumber != 0 && lnumber != 0) { | ||
564 | double pixels = amount; | ||
565 | pixels /= 2; | ||
566 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_LEFT); | ||
567 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_RIGHT); | ||
568 | } else if (rnumber) { | ||
569 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_RIGHT); | ||
570 | } else if (lnumber) { | ||
571 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_LEFT); | ||
572 | } | ||
573 | } | ||
574 | } | ||
575 | // Recursive resize does not handle positions, let arrange_windows | ||
576 | // take care of that. | ||
577 | arrange_windows(swayc_active_workspace(), -1, -1); | ||
578 | } | ||
537 | return true; | 579 | return true; |
538 | } else if (strcmp(argv[1], "height") == 0) { | 580 | } else if (strcmp(argv[1], "height") == 0) { |
539 | int tnumber = 0; | 581 | int tnumber = 0; |
@@ -561,6 +603,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { | |||
561 | } | 603 | } |
562 | sway_log(L_DEBUG, "Found the proper parent: %p. It has %d b conts, and %d t conts", parent->parent, bnumber, tnumber); | 604 | sway_log(L_DEBUG, "Found the proper parent: %p. It has %d b conts, and %d t conts", parent->parent, bnumber, tnumber); |
563 | //TODO: Ensure rounding is done in such a way that there are NO pixel leaks | 605 | //TODO: Ensure rounding is done in such a way that there are NO pixel leaks |
606 | bool valid = true; | ||
564 | for (i = 0; i < parent->parent->children->length; i++) { | 607 | for (i = 0; i < parent->parent->children->length; i++) { |
565 | sibling = parent->parent->children->items[i]; | 608 | sibling = parent->parent->children->items[i]; |
566 | if (sibling->y != focused->y) { | 609 | if (sibling->y != focused->y) { |
@@ -568,32 +611,74 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { | |||
568 | double pixels = -1 * amount; | 611 | double pixels = -1 * amount; |
569 | pixels /= bnumber; | 612 | pixels /= bnumber; |
570 | if (tnumber) { | 613 | if (tnumber) { |
571 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_BOTTOM); | 614 | if ((sibling->height + pixels/2) < min_sane_h) { |
615 | valid = false; | ||
616 | break; | ||
617 | } | ||
572 | } else { | 618 | } else { |
573 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_BOTTOM); | 619 | if ((sibling->height + pixels) < min_sane_h) { |
620 | valid = false; | ||
621 | break; | ||
622 | } | ||
574 | } | 623 | } |
575 | } else if (sibling->x > parent->x) { | 624 | } else if (sibling->y > parent->y) { |
576 | double pixels = -1 * amount; | 625 | double pixels = -1 * amount; |
577 | pixels /= tnumber; | 626 | pixels /= tnumber; |
578 | if (bnumber) { | 627 | if (bnumber) { |
579 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_TOP); | 628 | if ((sibling->height + pixels/2) < min_sane_h) { |
629 | valid = false; | ||
630 | break; | ||
631 | } | ||
580 | } else { | 632 | } else { |
581 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_TOP); | 633 | if ((sibling->height + pixels) < min_sane_h) { |
634 | valid = false; | ||
635 | break; | ||
636 | } | ||
582 | } | 637 | } |
583 | } | 638 | } |
584 | } else { | 639 | } else { |
585 | if (bnumber != 0 && tnumber != 0) { | 640 | double pixels = amount; |
586 | double pixels = amount/2; | 641 | if (parent->height + pixels < min_sane_h) { |
587 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_TOP); | 642 | valid = false; |
588 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_BOTTOM); | 643 | break; |
589 | } else if (tnumber) { | 644 | } |
590 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_TOP); | 645 | } |
591 | } else if (bnumber) { | 646 | } |
592 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_BOTTOM); | 647 | if (valid) { |
648 | for (i = 0; i < parent->parent->children->length; i++) { | ||
649 | sibling = parent->parent->children->items[i]; | ||
650 | if (sibling->y != focused->y) { | ||
651 | if (sibling->y < parent->y) { | ||
652 | double pixels = -1 * amount; | ||
653 | pixels /= bnumber; | ||
654 | if (tnumber) { | ||
655 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_BOTTOM); | ||
656 | } else { | ||
657 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_BOTTOM); | ||
658 | } | ||
659 | } else if (sibling->x > parent->x) { | ||
660 | double pixels = -1 * amount; | ||
661 | pixels /= tnumber; | ||
662 | if (bnumber) { | ||
663 | recursive_resize(sibling, pixels/2, WLC_RESIZE_EDGE_TOP); | ||
664 | } else { | ||
665 | recursive_resize(sibling, pixels, WLC_RESIZE_EDGE_TOP); | ||
666 | } | ||
667 | } | ||
668 | } else { | ||
669 | if (bnumber != 0 && tnumber != 0) { | ||
670 | double pixels = amount/2; | ||
671 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_TOP); | ||
672 | recursive_resize(parent, pixels, WLC_RESIZE_EDGE_BOTTOM); | ||
673 | } else if (tnumber) { | ||
674 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_TOP); | ||
675 | } else if (bnumber) { | ||
676 | recursive_resize(parent, amount, WLC_RESIZE_EDGE_BOTTOM); | ||
677 | } | ||
593 | } | 678 | } |
594 | } | 679 | } |
680 | arrange_windows(swayc_active_workspace(), -1, -1); | ||
595 | } | 681 | } |
596 | arrange_windows(swayc_active_workspace(), -1, -1); | ||
597 | return true; | 682 | return true; |
598 | } | 683 | } |
599 | return true; | 684 | return true; |
diff --git a/sway/handlers.c b/sway/handlers.c index 3756b628..d8f9e987 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -435,7 +435,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
435 | } else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_UP) == view) { | 435 | } else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_UP) == view) { |
436 | pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20; | 436 | pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20; |
437 | pointer_state.lock.temp_up = true; | 437 | pointer_state.lock.temp_up = true; |
438 | } else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_UP) == view) { | 438 | } else if (get_swayc_in_direction(pointer_state.tiling.init_view, MOVE_DOWN) == view) { |
439 | pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20; | 439 | pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20; |
440 | pointer_state.lock.temp_down = true; | 440 | pointer_state.lock.temp_down = true; |
441 | } | 441 | } |