Created attachment 2547 xfwm4.placement-gap.patch When set up to do smart placement of windows, xfwm4 is leaving a gap between them, as can be seen in the screenshot at http://www.decom.ufop.br/prof/romildo/misc/xfce1.jpg. This small space is lost and useless to me. If there is no gap, the available screen space to place new windows would be a little bigger. Looking at the source code, I found that the position to place a new window is tried in steps of 8 (a constant hard coded in the code) in both horizontal and vertical directions. After reducing this value to 2 (see attached patch), the gap is gone. The screenshot at http://www.decom.ufop.br/prof/romildo/misc/xfce2.jpg shows the result in my desktop. I think this is an enhancement and it should be applied to the source code. Maybe a configuration option could be added, so that the user could set up which step is better for him.
Created attachment 2563 added settings to the tweaks panel. This patch makes the grid size configurable from the tweaks panel. The range is 1 upto 50.
Created attachment 3808 patch: smarter position test This patch replaces the "good old CPU consuming algorithm" with a smarter algorithm. It tests overlap only at positions where a window is adjacent to another window or the desktop edge. This is much faster (except in edge cases) and avoids the gaps. Another change is that the position will be shifted slightly (if possible) if two windows with the same size would be at the same position otherwise. Also fixes trivial bug 7547.
Created attachment 3809 contiguous code, better readable than the patch
Created attachment 4772 Pixel perfect smart placement The patch looks for the next suitable x/y test position in the placement code. Beside the fact this this save a ridiculous amount of loops, it also makes the window placement pixel aligned so therefore i've attached it here.
Created attachment 4773 Pixel perfect smart placement v2 Previous patch was not working properly with multiple monitors and had some other small mistakes. This seems to be working as expected on my setup. Callgrind shows a big drop in the amount of function calls: when creating 9 terminal windows, fetch cost of smartPlacement went from 59.19% to 1.91% (relative to total used from start to stop of xfwm4). The terminals also now also aligned next to each other, without % 8 possible space between them.
Pushed to a branch for easier testing: http://git.xfce.org/xfce/xfwm4/log/?h=nick/callgrinding
Some people tried the patch in git and it worked fine, so merged to master for more testing.