Skip to content

Rework how icon pointer "hit detection" works

Brian Tarricone requested to merge kelnos/xfdesktop:rework-hit-detection into master

Previously, the code considered the pointer to be over an icon if it was anywhere inside a slot rect that had an item placed in it. This ends up being kind weird, where you can grab onto empty space near the icon, and it thinks you're grabbing onto the icon itself. This also ends up making it very difficult to start a rubberband selection in the middle of a crowded grid, since there's only a few pixels of spacing between slots.

Instead, now we use a cairo_region_t that contains the extents for the icon pixbuf and icon label (as well as the little smidgen of space between the pixbuf and label), and pointer tests will now use that region instead of the entire slot rectangle.

There is still one thing that uses the slot rect instead: determining if a location is a valid drop site during DnD. In this case I think it is valuable to have the larger "hit zone", and I don't really see downsides to this.

There's still some oddness: for some (all?) pixbufs the extents are a couple pixels off on the top, left, and right. Possibly because my extents calculation doesn't actually render the pixbuf, so it doesn't know exactly how large it is, and only guesses based on the requested icon size. But that will be something to fix another day.

Merge request reports

Loading