From 163c6377b35dfd5451edc4ca951cc2a470661071 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 17 Jan 2014 14:01:48 +0000 Subject: [PATCH] Tiling2: Added weight correction code. Total weight should always be 1.0. This may go off sometimes because of the nature of floating point. Always correct it when reapply tree. --- src/modules/tiling/window_tree.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/tiling/window_tree.c b/src/modules/tiling/window_tree.c index b20dea629..6f79c2574 100644 --- a/src/modules/tiling/window_tree.c +++ b/src/modules/tiling/window_tree.c @@ -256,15 +256,20 @@ _tiling_window_tree_level_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y, { Window_Tree *itr; Tiling_Split_Type split_type = level % 2; + double total_weight = 0.0; if (root->client) - tiling_e_client_move_resize_extra(root->client, x, y, w, h); + { + tiling_e_client_move_resize_extra(root->client, x, y, w, h); + return; + } if (split_type == TILING_SPLIT_HORIZONTAL) { EINA_INLIST_FOREACH(root->children, itr) { Evas_Coord itw = w * itr->weight; + total_weight += itr->weight; _tiling_window_tree_level_apply(itr, x, y, itw, h, level + 1); x += itw; } @@ -274,10 +279,14 @@ _tiling_window_tree_level_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y, EINA_INLIST_FOREACH(root->children, itr) { Evas_Coord ith = h * itr->weight; + total_weight += itr->weight; _tiling_window_tree_level_apply(itr, x, y, w, ith, level + 1); y += ith; } } + + /* Adjust the last item's weight in case weight < 1.0 */ + ((Window_Tree *) root->children->last)->weight += 1.0 - total_weight; } void