From 8772dae8e362134033b8f56e1547f5b20636db96 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Sat, 25 Feb 2012 10:48:43 -0500
Subject: [PATCH] improved logic for moving gop objects by checking if the gop
 has any legacy objects inside it that don't support displacefnwtag

---
 src/g_graph.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/g_graph.c b/src/g_graph.c
index ce33148c1..e01766db1 100644
--- a/src/g_graph.c
+++ b/src/g_graph.c
@@ -1051,20 +1051,6 @@ static void graph_getrect(t_gobj *z, t_glist *glist,
     *yp2 = y2;
 }
 
-static void graph_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy)
-{
-	//fprintf(stderr,"graph_displace_withtag %d %d\n", dx, dy);
-    t_glist *x = (t_glist *)z;
-    if (!x->gl_isgraph)
-        text_widgetbehavior.w_displacefnwtag(z, glist, dx, dy);
-    else
-    {
-        x->gl_obj.te_xpix += dx;
-        x->gl_obj.te_ypix += dy;
-        canvas_fixlinesfor(glist_getcanvas(glist), &x->gl_obj);
-    }
-}
-
 static void graph_displace(t_gobj *z, t_glist *glist, int dx, int dy)
 {
 	//fprintf(stderr,"graph_displace %d %d\n", dx, dy);
@@ -1087,6 +1073,29 @@ static void graph_displace(t_gobj *z, t_glist *glist, int dx, int dy)
     }
 }
 
+
+static void graph_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy)
+{
+	//fprintf(stderr,"graph_displace_withtag %d %d\n", dx, dy);
+    t_glist *x = (t_glist *)z;
+    if (!x->gl_isgraph)
+        text_widgetbehavior.w_displacefnwtag(z, glist, dx, dy);
+    else
+    {
+		//first check for legacy objects that don't offer displacefnwtag and fallback on the old way of doing things
+		t_gobj *g;
+		for (g = glist->gl_list; g; g = g->g_next) {
+			if (!g->g_pd->c_wb->w_displacefnwtag) {
+				graph_displace(z, glist, dx, dy);
+				return;
+			}
+		}
+        x->gl_obj.te_xpix += dx;
+        x->gl_obj.te_ypix += dy;
+        canvas_fixlinesfor(glist_getcanvas(glist), &x->gl_obj);
+    }
+}
+
 static void graph_select(t_gobj *z, t_glist *glist, int state)
 {
 	//fprintf(stderr,"graph_select .x%lx %d...\n", (t_int)z, state);
-- 
GitLab