Calculate optimum number of columns for table

Stephan Haller nomad at
Mon Sep 7 19:42:51 CEST 2015

Hi adlo,

I have this problem either in xfdashboard. I learned that this is a
"packing problem", sometimes also called "bin packing problem" or "box
packing problem".

I haven't implemented any of these algorithm yet, so I cannot say if it
really helps and how hard it is to implement. But I think you could
start your search there.


Am Montag, den 07.09.2015, 16:15 +0100 schrieb adlo:
> I am writing a program that displays previews of all open windows in a grid/table. Depending on factors such as the dimensions of the grid and the number of previews displayed, it would be useful to dynamically change the number of columns/rows in the grid, in order to ensure that the previews are as large as possible while making the best use of the available space.
> For example, when there are only a few previews, the number of columns and rows can be reduced in order to ensure that the previews are as large as possible. However, if there are a lot of previews and there is some extra horizontal space, the number of columns should be increased.
> It would be useful to have an algorithm that could calculate the optimum number of columns. Does anyone have any ideas?
> Regards
> adlo
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at

More information about the Xfce4-dev mailing list