[gtk+/gtk-3-22] Entry: Fix get_icon_at_pos()



commit 3680e3d40b13e26345d0d3000ce9b5a9cc56fd74
Author: Daniel Boles <dboles src gnome org>
Date:   Mon Jul 31 13:22:19 2017 +0100

    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

 gtk/gtkentry.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 803024a..ee2ac83 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -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;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]