Skip to content

backends/native: Fix relative motion calculation if monitor isn't found

The method relative_motion_across_outputs is used to adjust the distance/delta of a mouse movement across multiple monitors to take the different scale factors of those monitors into account. This works by getting the adjacent monitors that the movement-line/vector intersects with and adjusting the final position (or end point of the movement-line) by multiplying the parts of the line spanning across different monitors with the scale factors of those monitors.

In the end of this calculation, we always want to set the new end coordinates of the relative motion to the new end coordinates of the adjusted movement-line. We currently only do that if all adjacent monitors the line is crossing actually exist, because only then we end up inside the "We reached the dest logical monitor" else-block and set x and y to the correct values. Fix that and make sure the returned values are also correct in case an adjacent monitor doesn't exist by adding separate final_x and final_y variables which we update during each pass of the while loop so we're always prepared for the while loop exiting before the destination monitor was found.

Thanks to @axkibe for reporting the initial bug and tracking the issue down to relative_motion_across_outputs.

Fixes #774 (closed)

Edited by Jonas Dreßler

Merge request reports