Fix region snap-size threshold check

Checking to snap the region within a threshold didn't use the absolute
delta before comparison, making a larger snap size always pass
the threshold check.

Also assign variables for clarity.
This commit is contained in:
Campbell Barton
2023-06-27 16:23:27 +10:00
parent 64bfbddf35
commit 8ff65fe63f

View File

@@ -3866,12 +3866,10 @@ int ED_region_snap_size_test(const ARegion *region)
/* Use a larger value because toggling scrollbars can jump in size. */
const int snap_match_threshold = 16;
if (region->type->snap_size != nullptr) {
return ((((region->sizex - region->type->snap_size(region, region->sizex, 0)) <=
snap_match_threshold)
<< 0) |
(((region->sizey - region->type->snap_size(region, region->sizey, 1)) <=
snap_match_threshold)
<< 1));
const int snap_size_x = region->type->snap_size(region, region->sizex, 0);
const int snap_size_y = region->type->snap_size(region, region->sizey, 1);
return (((abs(region->sizex - snap_size_x) <= snap_match_threshold) << 0) |
((abs(region->sizey - snap_size_y) <= snap_match_threshold) << 1));
}
return 0;
}