mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-21 16:39:39 +00:00
window_layouter: calculate weighted dimension in double
The change prevents integer overflows with reasonable large values. Thanks Peter for reporting.
This commit is contained in:
@ -76,7 +76,7 @@ class Window_layouter::Target_list
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* amount of pixels we can use for weighed columns */
|
/* amount of pixels we can use for weighed columns */
|
||||||
unsigned const weigthed_avail = avail_px - preserved_pixels;
|
unsigned const weighted_avail = avail_px - preserved_pixels;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate positions
|
* Calculate positions
|
||||||
@ -91,9 +91,9 @@ class Window_layouter::Target_list
|
|||||||
if (px)
|
if (px)
|
||||||
return px;
|
return px;
|
||||||
|
|
||||||
unsigned const weight = weight_attr_value(child);
|
double const weight = weight_attr_value(child);
|
||||||
if (weight && total_weight)
|
if (weight && total_weight)
|
||||||
return (((weight << 16)*weigthed_avail)/total_weight) >> 16;
|
return (unsigned) (weight/total_weight*weighted_avail);
|
||||||
|
|
||||||
return 0U;
|
return 0U;
|
||||||
};
|
};
|
||||||
@ -103,12 +103,12 @@ class Window_layouter::Target_list
|
|||||||
if (weighted)
|
if (weighted)
|
||||||
count_weighted++;
|
count_weighted++;
|
||||||
|
|
||||||
/* true if target is the last weigthed column or row */
|
/* true if target is the last weighted column or row */
|
||||||
bool const last_weighted = weighted
|
bool const last_weighted = weighted
|
||||||
&& (count_weighted == num_weighted);
|
&& (count_weighted == num_weighted);
|
||||||
|
|
||||||
unsigned const px_size = last_weighted
|
unsigned const px_size = last_weighted
|
||||||
? (weigthed_avail - used_weighted)
|
? (weighted_avail - used_weighted)
|
||||||
: calc_px_size();
|
: calc_px_size();
|
||||||
|
|
||||||
if (weighted)
|
if (weighted)
|
||||||
|
Reference in New Issue
Block a user