From 20879ac9c9ca23d15ed99903656e08fd81b6556d Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 10 Sep 2014 10:51:59 -0400
Subject: [PATCH] *reversed autopositioning patch since it causes a lot of
 problems with paste and other relocations

---
 pd/src/g_canvas.c | 2 +-
 pd/src/g_editor.c | 8 +++++---
 pd/src/g_text.c   | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index 31feaba78..7eb344224 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -457,7 +457,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
     x->x_mhandle = scalehandle_new((t_object *)x,x,0,canvasgop__clickhook,canvasgop__motionhook);
 
     x->u_queue = canvas_undo_init(x);
-    glist_setlastxy(x, 20, 20);
+    //glist_setlastxy(x, 20, 20);
     return(x);
 }
 
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 067062f74..a2376d563 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -31,6 +31,7 @@ char *class_gethelpdir(t_class *c);
 /* ------------------ forward declarations --------------- */
 static void canvas_doclear(t_canvas *x);
 void glist_setlastxymod(t_glist *gl, int xval, int yval, int mod);
+void glist_setlastxy(t_glist *gl, int xval, int yval);
 static void glist_donewloadbangs(t_glist *x);
 static t_binbuf *canvas_docopy(t_canvas *x);
 static void canvas_dopaste(t_canvas *x, t_binbuf *b);
@@ -4994,8 +4995,8 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
     glist_setlastxymod(x, xpos, ypos, mod);
     if (x->gl_editor->e_onmotion == MA_MOVE)
     {
-        //fprintf(stderr,"%g %g %d %d\n", xpos - x->gl_editor->e_xwas,
-        //    ypos - x->gl_editor->e_ywas, x->gl_editor->e_xwas, x->gl_editor->e_ywas);
+        //fprintf(stderr,"x-was=%g y-was=%g xwas=%d ywas=%d x=%g y=%g\n", xpos - x->gl_editor->e_xwas,
+        //    ypos - x->gl_editor->e_ywas, x->gl_editor->e_xwas, x->gl_editor->e_ywas, xpos, ypos);
         canvas_displaceselection(x, 
             xpos - x->gl_editor->e_xwas, ypos - x->gl_editor->e_ywas);
         x->gl_editor->e_xwas = xpos;
@@ -5886,7 +5887,7 @@ static void canvas_paste_xyoffset(t_canvas *x)
 static void canvas_paste_atmouse(t_canvas *x)
 {
     t_selection *sel;
-    //fprintf(stderr,"paste_atmouse\n");
+    fprintf(stderr,"paste_atmouse\n");
     /* use safe values for x1 and y1 which are essentially the same as xyoffset */
     int x1 = x->gl_editor->e_xwas+10, y1 = x->gl_editor->e_ywas+10, init = 0;
     t_float sx = 0.0, sy = 0.0;
@@ -5931,6 +5932,7 @@ static void canvas_paste_atmouse(t_canvas *x)
     canvas_undo_already_set_move = 1;
     canvas_displaceselection(x,
         (x->gl_editor->e_xwas)+5-x1, (x->gl_editor->e_ywas)-y1);
+    //glist_setlastxy(x, (int)((x->gl_editor->e_xwas)+5-x1), (int)((x->gl_editor->e_ywas)-y1));
     canvas_startmotion(x);
 }
 
diff --git a/pd/src/g_text.c b/pd/src/g_text.c
index 7a85776dd..b33e790cb 100644
--- a/pd/src/g_text.c
+++ b/pd/src/g_text.c
@@ -395,7 +395,7 @@ void canvas_obj_abstraction_from_menu(t_glist *gl, t_symbol *s,
     }
     else if (connectme == 0)
     {
-        glist_setlastxy(glist_getcanvas(gl), xpix, ypix);
+        //glist_setlastxy(glist_getcanvas(gl), xpix, ypix);
         canvas_startmotion(glist_getcanvas(gl));
     }
     canvas_undo_add(glist_getcanvas(gl), 9, "create",
-- 
GitLab