Skip to content

backends/native: Keep general direction when crossing monitors

From the main commit:

    When the pointer crosses monitors, we account for a single motion event
    resulting in the pointer moving across more than 2 monitors, in order
    to correctly account each monitor scale and the distance traversed
    across each monitor in the resulting relative motion vector.
    
    However, memory on the direction is kept short, each iteration to
    find the target view just remembers the direction it came from. This
    brings a pathological case with 4 monitors with the same resolution
    in a 2x2 grid, and a motion vector that crosses monitors at the
    intersection of all 4 in a perfect diagonal. (Say, monitors are
    all 1920x1080 and pointer moves from 1920,1080 to 1919,1079).
    
    In that case, the intersection point at the crossing between 4
    monitors (say, 1920,1080) will be considered to intersect with 2
    edges of each view. Since there is always at least 2 directions to
    try, the loop will always find the direction other than the one
    it came from, and as a result endlessly jump across all 4 possible
    choices.
    
    In order to fix this, consider only the global v/h directions,
    we already know if the pointer moves left/right or up/down, so
    only consider those directions to jump across monitors.
    
    For the case at hand, this will result in three monitors visited,
    (either bottomright/bottomleft/topleft, or bottomright/topright/topleft)
    with a total distance of 0,0 in the middle one, effectively
    resulting in a correct diagonal motion.

Closes: #2598 (closed)

Edited by Carlos Garnacho

Merge request reports