Skip to content

clutter/stage: Test the cursor is inside an actor

Daniel van Vugt requested to merge vanvugt/mutter:fix-debian-test-failure into master

The cursor location comes to us as integer (x,y) representing a 1x1 pixel on screen. We however need to test whether this pixel is inside some arbitrary quadrilateral that is the actor's pick record.

If we use coordinate float (x,y) then that represents the top left corner of the pixel and in some cases floating point precision will put it inside and in other cases it will be outside. So it's unreliable and ambiguous to use coordinate float (x,y).

To fix this we could test if most of the 1x1 pixel rectangle is inside the quadrilateral but that's unreasonably complex. A simpler solution is to just test if the centre of the pixel is inside the quadrilateral. This will work reliably for all possible values of integer (x,y) on any quadrilateral rendered with at least 1px precision, so any quadrilateral.

Fixes test failures (and probably other bugs):

Clutter-Conform:ERROR:../src/tests/clutter/conform/actor-layout.c:85:actor_margin_layout: assertion failed (actor Yellow Flower at 106.00,50.00): found actor Vase

Debian test failure here.

Edited by Daniel van Vugt

Merge request reports