summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-05-08 09:48:29 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-05-08 09:48:29 +0200
commit02d10acd119cfd82f292449bafb7853757339263 (patch)
treeb72dddb6411c46a57f137c820a21a8bd5982cfb9 /src/gui
parentbce12fd38c7a3651673e9b26ad1816870db86eea (diff)
downloadweechat-02d10acd119cfd82f292449bafb7853757339263.zip
core: ensure that new split percent is between 1 and 99 for balance of windows
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-window.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index 4c2099c5a..2e9e3e1c9 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -1991,7 +1991,7 @@ gui_window_balance_count (struct t_gui_window_tree *tree, int split_horizontal)
int
gui_window_balance (struct t_gui_window_tree *tree)
{
- int balanced, count_left, count_right, new_split;
+ int balanced, count_left, count_right, new_split_pct;
balanced = 0;
if (tree && tree->child1 && tree->child2)
@@ -1999,15 +1999,19 @@ gui_window_balance (struct t_gui_window_tree *tree)
count_left = gui_window_balance_count (tree->child1, tree->split_horizontal) + 1;
count_right = gui_window_balance_count (tree->child2, tree->split_horizontal) + 1;
if (count_right > count_left)
- new_split = (count_left * 100) / (count_left + count_right);
+ new_split_pct = (count_left * 100) / (count_left + count_right);
else
- new_split = (count_right * 100) / (count_left + count_right);
+ new_split_pct = (count_right * 100) / (count_left + count_right);
+ if (new_split_pct < 1)
+ new_split_pct = 1;
+ if (new_split_pct > 99)
+ new_split_pct = 99;
if ((tree->split_horizontal && (count_right > count_left))
|| (!tree->split_horizontal && (count_left > count_right)))
- new_split = 100 - new_split;
- if (tree->split_pct != new_split)
+ new_split_pct = 100 - new_split_pct;
+ if (tree->split_pct != new_split_pct)
{
- tree->split_pct = new_split;
+ tree->split_pct = new_split_pct;
balanced = 1;
}
balanced |= gui_window_balance (tree->child1);