From 3a6427cdc64d1fc3854f77a6120ab7ee19edb89b Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 7 May 2014 09:00:21 -0300 Subject: [PATCH] CellRendererIcon: improve calculation in do_render MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a more efficient method to check if the pointer is inside the cell, because we have the cell_area in the do_render method. Signed-off-by: Manuel QuiƱones Signed-off-by: Gonzalo Odiard --- src/sugar3/graphics/icon.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py index c9a11026..3d7e281a 100644 --- a/src/sugar3/graphics/icon.py +++ b/src/sugar3/graphics/icon.py @@ -983,7 +983,14 @@ class CellRendererIcon(Gtk.CellRenderer): context.save() context.add_class("sugar-icon-cell") - pointer_inside = self._point_in_cell_renderer(widget) + def is_pointer_inside(): + # widget is the treeview + x, y = widget.get_pointer() + x, y = widget.convert_widget_to_bin_window_coords(x, y) + return ((cell_area.x <= x <= cell_area.x + cell_area.width) + and (cell_area.y <= y <= cell_area.y + cell_area.height)) + + pointer_inside = is_pointer_inside() # The context will have prelight state if the mouse pointer is # in the entire row, but we want that state if the pointer is