! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Smart placement of windows leaves a gap between them
Status:
RESOLVED: FIXED
Severity:
enhancement

Comments

Description José Romildo Malaquias 2009-09-24 12:30:15 CEST
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.
Comment 1 Peter de Ridder editbugs 2009-10-01 20:11:09 CEST
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.
Comment 2 Andreas Schneider 2011-08-01 23:46:22 CEST
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.
Comment 3 Andreas Schneider 2011-08-01 23:50:09 CEST
Created attachment 3809 
contiguous code, better readable than the patch
Comment 4 Nick Schermer editbugs 2012-12-01 11:01:44 CET
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.
Comment 5 Nick Schermer editbugs 2012-12-01 13:39:10 CET
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.
Comment 6 Nick Schermer editbugs 2012-12-01 20:50:28 CET
Pushed to a branch for easier testing: http://git.xfce.org/xfce/xfwm4/log/?h=nick/callgrinding
Comment 7 Nick Schermer editbugs 2012-12-04 23:25:55 CET
Some people tried the patch in git and it worked fine, so merged to master for more testing.

Bug #5785

Reported by:
José Romildo Malaquias
Reported on: 2009-09-24
Last modified on: 2012-12-04

People

Assignee:
Olivier Fourdan
CC List:
1 user

Version

Attachments

xfwm4.placement-gap.patch (403 bytes, patch)
2009-09-24 12:30 CEST , José Romildo Malaquias
no flags
added settings to the tweaks panel. (8.54 KB, patch)
2009-10-01 20:11 CEST , Peter de Ridder
no flags
patch: smarter position test (10.62 KB, patch)
2011-08-01 23:46 CEST , Andreas Schneider
no flags
contiguous code, better readable than the patch (6.54 KB, text/plain)
2011-08-01 23:50 CEST , Andreas Schneider
no flags
Pixel perfect smart placement (4.09 KB, patch)
2012-12-01 11:01 CET , Nick Schermer
no flags
Pixel perfect smart placement v2 (5.60 KB, patch)
2012-12-01 13:39 CET , Nick Schermer
no flags

Additional information