0001-fix-sizing.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. commit 38b8a198bac62c16d351c54ed83ead29a2e0ecc8
  2. Author: nicm <nicm>
  3. Date: Tue May 14 07:37:50 2019 +0000
  4. Fix sizing of main-vertical and main-horizontal layouts, GitHub issue 1736.
  5. diff --git a/layout-set.c b/layout-set.c
  6. index 3a088a4c..12b4780f 100644
  7. --- a/layout-set.c
  8. +++ b/layout-set.c
  9. @@ -185,7 +185,7 @@ layout_set_main_h(struct window *w)
  10. {
  11. struct window_pane *wp;
  12. struct layout_cell *lc, *lcmain, *lcother, *lcchild;
  13. - u_int n, mainh, otherh, sx;
  14. + u_int n, mainh, otherh, sx, sy;
  15. layout_print_cell(w->layout_root, __func__, 1);
  16. @@ -195,22 +195,25 @@ layout_set_main_h(struct window *w)
  17. return;
  18. n--; /* take off main pane */
  19. + /* Find available height - take off one line for the border. */
  20. + sy = w->sy - 1;
  21. +
  22. /* Get the main pane height and work out the other pane height. */
  23. mainh = options_get_number(w->options, "main-pane-height");
  24. - if (mainh + PANE_MINIMUM + 1 >= w->sy) {
  25. - if (w->sy <= PANE_MINIMUM + 1 + PANE_MINIMUM)
  26. + if (mainh + PANE_MINIMUM >= sy) {
  27. + if (sy <= PANE_MINIMUM + PANE_MINIMUM)
  28. mainh = PANE_MINIMUM;
  29. else
  30. - mainh = w->sy - (PANE_MINIMUM + 1);
  31. + mainh = sy - PANE_MINIMUM;
  32. otherh = PANE_MINIMUM;
  33. } else {
  34. otherh = options_get_number(w->options, "other-pane-height");
  35. if (otherh == 0)
  36. - otherh = w->sy - mainh;
  37. - else if (otherh > w->sy || w->sy - otherh < mainh)
  38. - otherh = w->sy - mainh;
  39. + otherh = sy - mainh;
  40. + else if (otherh > sy || sy - otherh < mainh)
  41. + otherh = sy - mainh;
  42. else
  43. - mainh = w->sy - otherh;
  44. + mainh = sy - otherh;
  45. }
  46. /* Work out what width is needed. */
  47. @@ -221,7 +224,7 @@ layout_set_main_h(struct window *w)
  48. /* Free old tree and create a new root. */
  49. layout_free(w);
  50. lc = w->layout_root = layout_create_cell(NULL);
  51. - layout_set_size(lc, sx, mainh + otherh, 0, 0);
  52. + layout_set_size(lc, sx, mainh + otherh + 1, 0, 0);
  53. layout_make_node(lc, LAYOUT_TOPBOTTOM);
  54. /* Create the main pane. */
  55. @@ -269,7 +272,7 @@ layout_set_main_v(struct window *w)
  56. {
  57. struct window_pane *wp;
  58. struct layout_cell *lc, *lcmain, *lcother, *lcchild;
  59. - u_int n, mainw, otherw, sy;
  60. + u_int n, mainw, otherw, sx, sy;
  61. layout_print_cell(w->layout_root, __func__, 1);
  62. @@ -279,22 +282,25 @@ layout_set_main_v(struct window *w)
  63. return;
  64. n--; /* take off main pane */
  65. + /* Find available width - take off one line for the border. */
  66. + sx = w->sx - 1;
  67. +
  68. /* Get the main pane width and work out the other pane width. */
  69. mainw = options_get_number(w->options, "main-pane-width");
  70. - if (mainw + PANE_MINIMUM + 1 >= w->sx) {
  71. - if (w->sx <= PANE_MINIMUM + 1 + PANE_MINIMUM)
  72. + if (mainw + PANE_MINIMUM >= sx) {
  73. + if (sx <= PANE_MINIMUM + PANE_MINIMUM)
  74. mainw = PANE_MINIMUM;
  75. else
  76. - mainw = w->sx - (PANE_MINIMUM + 1);
  77. + mainw = sx - PANE_MINIMUM;
  78. otherw = PANE_MINIMUM;
  79. } else {
  80. otherw = options_get_number(w->options, "other-pane-width");
  81. if (otherw == 0)
  82. - otherw = w->sx - mainw;
  83. - else if (otherw > w->sx || w->sx - otherw < mainw)
  84. - otherw = w->sx - mainw;
  85. + otherw = sx - mainw;
  86. + else if (otherw > sx || sx - otherw < mainw)
  87. + otherw = sx - mainw;
  88. else
  89. - mainw = w->sx - otherw;
  90. + mainw = sx - otherw;
  91. }
  92. /* Work out what height is needed. */
  93. @@ -305,7 +311,7 @@ layout_set_main_v(struct window *w)
  94. /* Free old tree and create a new root. */
  95. layout_free(w);
  96. lc = w->layout_root = layout_create_cell(NULL);
  97. - layout_set_size(lc, mainw + otherw, sy, 0, 0);
  98. + layout_set_size(lc, mainw + otherw + 1, sy, 0, 0);
  99. layout_make_node(lc, LAYOUT_LEFTRIGHT);
  100. /* Create the main pane. */