Re: FVWM: idea for new window placement policy

From: Dan Astoorian <djast_at_utopia.csas.com>
Date: Tue, 22 Oct 1996 10:00:42 -0400

On Tue, 22 Oct 1996 02:06:26 PDT, Trent Piepho writes:
>How about this for a new window placement policy, CleverPlacement? Currently
>we have SmartPlacement, which avoids all overlap and gives up if it can't,
>and DumbPlacement (er, RandomPlacement), which sticks the windows semi-randoml
>y
>on the screen. CleverPlacement should be like SmartPlacement, it tries to
>avoid overlap. If it can't avoid it entirely, it tries to minimize it.
>
>If I have two windows, each 100% vertical size and 51% horizontal size, the
>the best way to place them is so they fill the whole screen and overlap just
>a bit in the middle.
>
>Anyone have an idea on a heuristic to try and find the least overlapping
>position?

I was planning to do some work on this, but have just been too busy;
I'll share my thoughts and perhaps someone else will get around to
putting together some code before I do.

Currently, SmartPlacement is implemented something like this:
    Let x, y = 0
    loop
        try to place the window at (x,y)
        if the placement does not result in overlap
            return (x,y)

        set x to the right margin of the overlapping window
        if x + window width > right side of screen
            x = 0
            y = y + 1
            if y + window height > bottom of screen
                fail

Note that since y is only incremented by 1, it can take thousands of
iterations to conclude that there's no room on the desktop.

A possible optimization: keep a sorted list of the y coordinate of the
bottom edge of each existing window; then instead of adding 1, set y to
the next-higher element of the list. (Why this algorithm works is left
as an exercise.)

Once this improvement is made, the following enhancement becomes
feasible: each time an (x,y) placement fails, calculate the area of
overlap between that placement and all windows on the screen. Reject
the placement if this overlap exceeds the smallest found so far. (In
fact, when traversing the list of windows to calculate the total
overlap, you can stop early once you've found enough overlapping area to
eliminate the placement as a candidate.)

If an overlap of 0 is found during this process, that position is
returned and CleverPlacement works like SmartPlacement. If it hits the
bottom of the screen before finding such a 'perfect' placement, it uses
the best guess it found.

This method could be made even smarter if it kept a sorted list of the
right edges of each window as well as the bottom edges, and considered
each of those x positions as possible 'secondary' candidates even though
some of them had no chance of being the 'perfect' placement.

Another possible addition to the heuristic: when calculating overlap,
count window title bars and decorations as triple their actual area, in
order to discourage placing windows on top of them.

Thoughts?

-- People shouldn't think that it's better to have
Dan Astoorian loved and lost than never loved at all. It's
http://www.utopia.csas.com not, it's better to have loved and won. All
djast_at_utopia.csas.com the other options really suck. --Dan Redican
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Tue Oct 22 1996 - 09:01:24 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:59 BST