Skip to content

desktopGrid.js: fix incorrect initial size for grids

Rastersoft requested to merge fix_initial_grid_size into master

Each grid, when created, is inserted inside an St.Widget. This widget, as expected, doesn't have an allocation until the main loop is able to process it. Unfortunately, the grid doesn't resize to fill this widget, because it uses a FixedLayout; and what's worse, it gets an initial size of 0x0, so each element has also an assigned size of 0x0 pixels.

The problem is that, if a new file has been added to the desktop, it still hasn't stored coordinates, so the placeholder coordinates will be used. But these coordinates are incorrect because, although the grid and the containers in each grid position have been realized, they seem to don't assign a size yet, so each element is considered to have a size of 0x0 pixels. This means that the coordinates that will be assigned will be always (0, heigh-of-gnome-top-bar).

This not only makes the icons to jump each time a refresh is issued (because there will be several files with the same coordinates), but also when doing DnD of a new file, it will be located the first time in an erroneous place (because the final location is the original one plus the distance moved; since the original location is wrong, the final one will also be wrong). Of course, now the grid has been realized, so the placeholder coordinates are now right. This means that the icon will now store a set of coordinates that truly correspond to the current place where it is located, and this is why new DnD operations work fine.

Also, in the original code it is presumed that the grid size is always the same than the workarea size, but this can be untrue.

This patch fixes this by setting the constraint to the grid instead than to the container, fixing its size to the workarea. This ensures that the size and location of each grid element is correctly calculated, and thus the location for each grid element will be also correct. It also uses now the grid size instead of the workarea size.

Edited by Rastersoft

Merge request reports