Skip to content

WIP: Fix jumping icons

Rastersoft requested to merge fix_dancing_icons into master

In several cases, after a refresh of the desktop, the icons are moved into new positions instead of remain on its place.

One of the several causes is because when a file is removed from the desktop, the metadata is preserved. This means that a new file created with the same name in the Desktop will receive the old desktop coordinates. If between the delete and the creation, a new icon is located in the place previously used by the deleted file, when the new file with the same name than the deleted file is created, it will have the same coordinates, so both will "fight" for it in each refresh.

Also, it is not a good idea to always update the coordinates of the icons, because there are several situations where the desktop resolution can change and affects the icon location. If the user has a laptop and an external monitor, if (s)he uses it in double-screen configuration, every time the monitor is disconnected, the icons located in it must be relocated to the laptop screen. Another case is when (s)he uses it in single-screen mode, but the external monitor and the internal one have different resolutions.

Ideally, unless the icons are moved, they should return to the original location in the external monitor (or the bigger one), while being temporarily relocated when only one monitor (or the smaller one) is connected.

Always updating the final coordinates would break this use case because every time the resolution would change and the icons were relocated, their new coordinates would be stored, remaining in the new place also when the configuration with more resolution is restored.

The first patch fixes the first case by erasing the metadata coordinates every time a file is deleted or created (this is done in both cases to avoid corner cases where a file is deleted or created with the extension disabled).

The second patch does several changes in the layout process. Instead of the two old passes, it does three: first it paints all the icons that fit inside their corresponding screen, and in case that they must be relocated because their coordinates are already used by another icon, their stored coordinates will be updated to the new place. This fixes the problem with icons with the same stored coordinates.

The second pass will paint all the icons that have stored coordinates but fall out of the available screen (because an smaller screen is being used, or because only one screen is connected instead of two). These icons will be placed in the nearest grid location, but must be painted after the icons that belong to this screen. Not doing this can result in placing first an outsider icon in a grid location (and its coordinates not being updated), and after that, when trying to put in the same grid location an icon from this screen, it will find that the place is occupied, so it will be moved to the nearest free place and its stored coordinates updated, which is an undesirable behavior.

The third pass will add all the new icons, those that still don't have stored coordinates.

Fixes #34 (closed).

Edited by Rastersoft

Merge request reports