Ticket #3944: 0002-Do-not-check-intersection-with-the-same-icon.patch

File 0002-Do-not-check-intersection-with-the-same-icon.patch, 1.3 KB (added by humitos, 11 years ago)

A little improved version of _detect_collisions

  • src/jarabe/desktop/grid.py

    From 470dd09380ac2cf000af2b40d0b68fc203958764 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Mon, 10 Dec 2012 18:43:43 -0300
    Subject: [PATCH sugar 2/2] Do not check intersection with the same icon
    
    Skip the intersection check against the same icon and use the new Gdk
    API to know if there was a collision (Gdk.rectangle_intersect returns
    a boolean value).
    
    http://developer.gnome.org/gdk/stable/gdk-Points-Rectangles-and-Regions.html#gdk-rectangle-intersect
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     src/jarabe/desktop/grid.py | 5 ++++-
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    diff --git a/src/jarabe/desktop/grid.py b/src/jarabe/desktop/grid.py
    index 83404e2..e9a5658 100644
    a b class Grid(SugarExt.Grid): 
    198198        collision_found = False
    199199        child_rect = self._child_rects[child]
    200200        for c in self._children:
     201            if c == child:
     202                continue
     203
    201204            intersects_, intersection = Gdk.rectangle_intersect(
    202205                child_rect, self._child_rects[c])
    203             if c != child and intersection.width > 0:
     206            if intersects_:
    204207                collision_found = True
    205208                if (c not in self._locked_children and
    206209                    c not in self._collisions):