[gcompris-devel] [PATCH] Fixes to make 2click mode work better

Mattias Lindblad matlin at gmail.com
Wed Jul 13 20:20:50 UTC 2011


Hi all,

I have had some problems with using the "2 clicks" mode in some of the
boards, for example the geography board. The problem is that when the
pointer moves outside of the dragged item (which may occur when doing
a fast drag or having a slow computer), the item gets stuck. I
descriped the problem in more detail in Ubuntu Launchpad:
https://bugs.launchpad.net/ubuntu/+source/gcompris/+bug/777349

However, filing a bug in Launchpad didn't automagically solve the
problem for me :) So I had a look at the code instead, and found some
problems with the drag handling in 2 click mode. And while testing my
fixes, I also noted noticed that moving an already placed item is
almost impossible in 2 clicks mode.

Below is my proposed solution to both these problems. The first
problem is solved by always getting the canvas coordinates when
dragging in 2 clicks mode, and converting them to item-referenced
coordinates. The second problem is solved by making the shadows never
receive any events.

I have tested the patches in both 2-click mode and normal mode, and
found no problems as far as I can tell.

Best regards,
Mattias Lindblad

---
 src/babymatch-activity/shapegame.c |    2 ++
 src/gcompris/drag.c                |   10 ++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/babymatch-activity/shapegame.c
b/src/babymatch-activity/shapegame.c
index fff9f5d..2aeb887 100644
--- a/src/babymatch-activity/shapegame.c
+++ b/src/babymatch-activity/shapegame.c
@@ -992,6 +992,8 @@ item_event_drag(GooCanvasItem *item,
 					     NULL);
 	  g_object_set(shadow_item, "visibility",
 		       GOO_CANVAS_ITEM_INVISIBLE, NULL);
+	  g_object_set(shadow_item, "pointer-events",
+		       GOO_CANVAS_EVENTS_NONE, NULL);
 	  gdk_pixbuf_unref(dest);
 	}
       dragged = shape->item;
diff --git a/src/gcompris/drag.c b/src/gcompris/drag.c
index 5d27605..17fc361 100644
--- a/src/gcompris/drag.c
+++ b/src/gcompris/drag.c
@@ -150,6 +150,16 @@ gc_drag_event_root(GooCanvasItem * item,
 		   GdkEventMotion *event,
 		   gpointer data)
 {
+  if(gc_drag_mode & GC_DRAG_MODE_2CLICKS) {
+    gdouble new_x = event->x_root;
+    gdouble new_y = event->y_root;
+    goo_canvas_convert_to_item_space(goo_canvas_item_get_canvas(item),
+				     gc_drag_item, &new_x, &new_y);
+    event->x = new_x;
+    event->y = new_y;
+    target = gc_drag_target;
+  }
+
   if(gc_drag_target != target)
     return FALSE;

-- 
1.7.4.1




More information about the Gcompris-devel mailing list