Comment 102 for bug 1335492

Revision history for this message
Thomas Schweikle (tps) wrote :

Yes this is what I see too, but it depends …: if for some reason while my desktop is prepared after logging in something starts using disks heavily icons will rearrange, even if the system had time to calm down. Until now the whole system of arranging icons depends on exact:

1. read the positions from ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc
   (or if it exists and matches screen width/height: ${HOME}/.config/xfce4/desktop/icons.screen0-<width>x<height>.rc)
2. read directory content from ${HOME}/Desktop while reading rearrange icons to given positions

If this is not done exactly after each other icons will rearrange. Both actions are now distinct and started at the same time, running concurrently. Now just guss what happens, if 2 is ready before 1, or 2 starts, 1 catches up – icons will rearrange completly or partly. Why? Because reading an item from ${HOME}/Desktop without finding it in position data structures defaults the position of this item. It will be placed to the next free, available position. Since all positions are free until ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc is read the icon position is located by what you defined as default for the first one read (0,0) incremented by one position to the right or down for the next one. If finally ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc is read, all positions are thrown away, since all icons are arranged already.

Now lets have a look what happens if reading ${HOME}/Desktop starts, but is caught up by reading ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc: the first few icons are rearanged, then, since data structures are filled and icons found these are positioned as given. But only it the position the icon wants is free. If it is not, this icon goes for the default – finding the first free place by using what is defined: starting at 0,0, extending one down filling colums from top left to bottom down.

Next if reading ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc starts, but is caught up by ${HOME}/Desktop: in this case all icons with positions in data structures are placed as expected. Then all those not having positions are placed as defaults define, occupying free places.

All of this is made more complicated as the system immediately stores "newly" found icon positions to ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc overwriting this file as often as there are items in ${HOME}/Desktop.

From this:
1. make sure reading ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc is complete BEFORE
2. reading any items from ${HOME}/Desktop

and

3. make sure ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc is never written before all items in ${HOME}/Desktop are read and positioned.

A simple solution would be to block execution of reading items from ${HOME}/Desktop until ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc is read. And block writing ${HOME}/.config/xfce4/desktop/icons.screen0-default.rc while items are read from ${HOME}/Desktop.