On Sun, 21 Dec 2025 02:42:12 GMT, Cormac Redmond <[email protected]> wrote:

> Fix overflow menu triggering due to floating-point precision error.
> 
> At 1.25 display scaling on Windows, floating-point comparison errors (e.g. 
> 109.60000000000001 > 109.6) cause the overflow menu to appear when the 
> lefthand value is regarded as larger than the righthand value.
> 
> These should be treated as equal (and therefore not display the overflow 
> menu).
> 
> This bug can happen in both horizontal and vertical toolbar orientation.
> 
> The new tests added fail without this fix, and pass with it. An existing test 
> has been re-factored slightly to allow re-use and more flexibility in 
> specifying the scene's root node.

We wouldn't have problems like this if we didn't try to emulate integer 
arithmetic with doubles. So instead of snapping everywhere, it would be 
conceptually easier to just do:
1. Convert input values to pixel-space integers.
2. Do all arithmetic with integers.
3. Convert back to doubles.

Now everything is snapped by definition, because all operations happened with 
actual integer arithmetic. This also scales nicely with multiple intermediate 
operations, and it is not affected by arithmetic drift (so repeatedly adding 
some numbers won't cause the result to be slightly off).

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2016#issuecomment-3679558546

Reply via email to