Entry: Fix get_icon_at_pos()

This was comparing the input position, which is documented as being
relative to the top-left of the Entry allocation, to icon allocations
that were not adjusted accordingly. This could result in tooltips for
icons not being shown in various conditions, since the ::query-tooltip
handler uses get_icon_at_pos() to check whether to show an icon tooltip.

The fix is to compare to the icon border box, not border allocation, as
CssGadget::get_border_box() adjusts relative to the widget. Better yet:
we can just make CssGadget::border_box_contains_point() compare for us.

Delegating to Entry::get_icon_area(), which manually reimplements
CssGadget::get_border_box(), would also work, but this is simpler.

https://bugzilla.gnome.org/show_bug.cgi?id=780938
This commit is contained in:
Daniel Boles 2017-07-31 13:22:19 +01:00 committed by Daniel Boles
parent ad06a08b99
commit 3680e3d40b

View File

@ -9007,14 +9007,11 @@ gtk_entry_get_icon_at_pos (GtkEntry *entry,
for (i = 0; i < MAX_ICONS; i++)
{
EntryIconInfo *icon_info = priv->icons[i];
GtkAllocation allocation;
if (icon_info == NULL)
continue;
gtk_css_gadget_get_border_allocation (icon_info->gadget, &allocation, NULL);
if (x >= allocation.x && x < allocation.x + allocation.width &&
y >= allocation.y && y < allocation.y + allocation.height)
if (gtk_css_gadget_border_box_contains_point (icon_info->gadget, x, y))
return i;
}