Fix rectangle/point distance computation.#2020
Conversation
Previously, the implementation would treat the point (0, w) as having 0 distance to the rectangle defined by (0, 0), (w, h). The distance should be 1, since the rectangle only contains the points (x, y) for x in [0, w) and y in [0, h). This could lead to screen/workspace assignments being computed incorrectly for adjacent monitors. For example, for two monitors: monitor 1: (0, 0) .. (100, 100) monitor 2: (100, 0) .. (200, 100) The point (100, 0) would be considered as having distance 0 to both monitors, which could lead to `monitorApproximation` for that point incorrectly returning monitor 1 if it appears first in the monitors list. Fix this by subtracting 1 from maxX/maxY when determining the bottom/right bounds of a rectangle.
|
The patch makes sense, thanks! I am curious: how did you find this bug? Did you find it by just browsing the source code? Or do you have a real world scenario? |
|
I ran into this issue in my own usage after rebuilding from HEAD. I don't understand why this wasn't biting me before though - I was able to bisect the monitor mixup to 204f4aa, but I don't see how that change should have any effect on |
|
I don't see how the mentioned commit could cause this bug either. Anyway, merged. Given the positive interaction history, I gave you the write access to the repo, and allowed you to create issues: 6f37ad0 I am a big fan of the post-push review process, where commits are reviewed after being pushed to the The bare minimum is to keep git commit message history elaborate (which you’re already doing great) and to keep the CI green (Mostly, Feel free to push directly to the Thanks! |
|
Much appreciated, I do happen to have two small fixes lined up that I'll push - will keep an eye out for any comments, thanks! |
Previously, the implementation would treat the point (0, w) as having 0
distance to the rectangle defined by (0, 0), (w, h). The distance should
be 1, since the rectangle only contains the points (x, y) for x in [0,
w) and y in [0, h).
This could lead to screen/workspace assignments being computed
incorrectly for adjacent monitors. For example, for two monitors:
monitor 1: (0, 0) .. (100, 100)
monitor 2: (100, 0) .. (200, 100)
The point (100, 0) would be considered as having distance 0 to both
monitors, which could lead to
monitorApproximationfor that pointincorrectly returning monitor 1 if it appears first in the monitors
list.
Fix this by subtracting 1 from maxX/maxY when determining the
bottom/right bounds of a rectangle.
PR checklist
./run-tests.shexits with non-zero exit code.Failure to follow the checklist with no apparent reasons will result in silent PR rejection.