On Sat, Nov 20, 2021 at 5:22 PM Dominik Vogt <dominik.v...@gmx.de> wrote:
>
>
> 1) Can we safely assume that the "bool" C type is available in
>    every relevant compiler?

The bool type is used elsewhere in the fvwm code, so I would assume it is okay.

> 2) Please break up the calculations in DoSnapGrid into multiple
>    lines unsing temp variable.  It's too hard to read = hard to
>    maintain.  The previous un-readability of the code shouldn't be
>    the standard we aim at.  ;-)

I tried to clean this up a bit, was mostly just cutting/pasting code.

> 3) Same for "smap_mon = ...".  Ouch.

Agreed, tried to simplify it a bit.

> 4) I'm not sure whether screen boundaries should have a higher
>    priority than windows and not equal priorities.  That would
>    require scoring.
>
>    Shouldn't be too difficult to implement; the new sub functions
>    would simply return a score = the absolute snapping distance
>    that was used, and the lowest one wins.  (Gird is still only
>    used if there was no other snapping.)
>

Returning a single score won't work, since vertical and horizontal are
treated separately.

Instead I now find both an appropriate monitor edge and window edge.
Then snap to the closest. If none is found, fallback to using the
grid.

> 5) Edge resistance is a kind of reverse snapping with a different
>    snap distance:  A window that has been moved past the screen
>    edge "snaps" back until it has moved more than the edge
>    resistance past the edge.  This is exactly what snapattraction
>    does, just with the snap distance from a different variable.
>
>    Can that be merged with the new code?

This ended up being a bit more complicated, since the resistance isn't
the same as snap attraction (since snap attraction snaps both
left/right but resistance is only one direction). But I was able to
update the monitor function to be able to now deal with both snapping
and resistance by passing it a few bools to control its behavior. I
also took advantage of the new info about if a monitor edge is an
outside or inside edge to distinguish resistance between monitors and
between pages. Though the code is a bit more complicated, I hope it is
readable.

On Sat, Nov 20, 2021 at 9:45 PM Dominik Vogt <dominik.v...@gmx.de> wrote:
>
> And there's still a bug that had been present in the old code:
>
> I.e. the top/left/right/bottom border of a window shouldn't snap
> to the bottom/right/left/top border of a windows if that latter is
> aligned with a screen edge.
>

I have added a final check in DoSnapWindow that ignores snapping to
windows on the monitor edge. I think this fixes the issue.

All of the updates have been pushed to js/snapattract.

jaimos

Reply via email to