util/box: Calculation error of wlr_box_closest_point in multi-screen mode

In multi-screen mode, when the mouse is on the first screen (default
position (100,100)), when the first mask is removed, box is (1920,0).
If you directly assign *dest_x = box->x, the mouse position on the
second screen will become (1920,100), which is wrong. When x < box->x,
x should also be added to box, and y should be the same.
This commit is contained in:
Lu YaNing 2024-08-13 20:30:35 +08:00
parent 4da4269d8f
commit 5c2ce751b7

View file

@ -26,7 +26,7 @@ void wlr_box_closest_point(const struct wlr_box *box, double x, double y,
// find the closest x point // find the closest x point
if (x < box->x) { if (x < box->x) {
*dest_x = box->x; *dest_x = box->x + x - 1/65536.0;
} else if (x > box->x + box->width - 1/65536.0) { } else if (x > box->x + box->width - 1/65536.0) {
*dest_x = box->x + box->width - 1/65536.0; *dest_x = box->x + box->width - 1/65536.0;
} else { } else {
@ -35,7 +35,7 @@ void wlr_box_closest_point(const struct wlr_box *box, double x, double y,
// find closest y point // find closest y point
if (y < box->y) { if (y < box->y) {
*dest_y = box->y; *dest_y = box->y + y - 1/65536.0;
} else if (y > box->y + box->height - 1/65536.0) { } else if (y > box->y + box->height - 1/65536.0) {
*dest_y = box->y + box->height - 1/65536.0; *dest_y = box->y + box->height - 1/65536.0;
} else { } else {