Switching from focused W1 to the west will switch to the W3 despite W2 being visually closer. It happens because the absolute distance w3_max - w1 is less than w2_max - w1.
Allowing for distance to be negative solves the problem: negative values are preferred by the search algorithm and the closer the overlapping windows are, the lesser the negative distance becomes, allowing to switch to the closest overlapping window if there are many.
In a layouts like so:
Switching from focused
W1
to the west will switch to theW3
despiteW2
being visually closer. It happens because the absolute distancew3_max - w1
is less thanw2_max - w1
.Allowing for distance to be negative solves the problem: negative values are preferred by the search algorithm and the closer the overlapping windows are, the lesser the negative distance becomes, allowing to switch to the closest overlapping window if there are many.