From 0974f348e8ba6fe2c5caf28c60d128bd18b809c9 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Tue, 18 Jul 2017 11:36:54 -0400
Subject: [PATCH] use "legacy_" prefix to guard against namespace collisions
 (plus self-documentation of the relevant classes)

---
 externals/hcs/cursor.pd | 66 ++++++++++++++++++++---------------------
 pd/nw/pd_canvas.js      |  2 +-
 pd/src/g_editor.c       |  8 ++---
 pd/src/x_gui.c          | 12 ++++----
 4 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/externals/hcs/cursor.pd b/externals/hcs/cursor.pd
index d1dfbbc47..927664763 100644
--- a/externals/hcs/cursor.pd
+++ b/externals/hcs/cursor.pd
@@ -1,7 +1,4 @@
-#N canvas 220 51 450 464 10;
-#X obj 68 170 mousemotion;
-#X obj 203 220 mousewheel;
-#X obj 304 220 mouseclick;
+#N canvas 221 76 450 464 10;
 #X obj 68 279 list prepend motion;
 #X obj 37 5 inlet;
 #X obj 68 400 outlet;
@@ -55,33 +52,36 @@ runmode_addpoint editmode_nothing editmode_connect editmode_disconnect
 #X connect 1 6 2 0;
 #X connect 2 0 3 0;
 #X restore 130 57 pd error;
-#X connect 0 0 16 0;
-#X connect 0 1 16 1;
-#X connect 1 1 7 0;
-#X connect 2 0 9 0;
-#X connect 2 1 9 1;
-#X connect 3 0 8 0;
-#X connect 4 0 20 0;
-#X connect 6 0 5 0;
-#X connect 7 0 6 0;
-#X connect 8 0 6 0;
-#X connect 9 0 10 0;
-#X connect 9 1 10 1;
-#X connect 10 0 11 0;
-#X connect 11 0 12 0;
-#X connect 12 0 6 0;
-#X connect 13 0 19 0;
+#X obj 68 170 legacy_mousemotion;
+#X obj 173 220 legacy_mousewheel;
+#X obj 304 220 legacy_mouseclick;
+#X connect 0 0 5 0;
+#X connect 1 0 17 0;
+#X connect 3 0 2 0;
+#X connect 4 0 3 0;
+#X connect 5 0 3 0;
+#X connect 6 0 7 0;
+#X connect 6 1 7 1;
+#X connect 7 0 8 0;
+#X connect 8 0 9 0;
+#X connect 9 0 3 0;
+#X connect 10 0 16 0;
+#X connect 10 1 11 0;
+#X connect 12 0 3 1;
+#X connect 13 0 15 0;
 #X connect 13 1 14 0;
-#X connect 15 0 6 1;
-#X connect 16 0 18 0;
-#X connect 16 1 17 0;
-#X connect 17 0 3 0;
-#X connect 18 0 3 0;
-#X connect 19 0 17 0;
-#X connect 19 0 18 0;
-#X connect 20 0 21 0;
-#X connect 20 1 21 1;
-#X connect 20 1 13 0;
-#X connect 20 2 23 0;
-#X connect 21 0 22 0;
-#X connect 22 0 13 0;
+#X connect 14 0 0 0;
+#X connect 15 0 0 0;
+#X connect 16 0 14 0;
+#X connect 16 0 15 0;
+#X connect 17 0 18 0;
+#X connect 17 1 18 1;
+#X connect 17 1 10 0;
+#X connect 17 2 20 0;
+#X connect 18 0 19 0;
+#X connect 19 0 10 0;
+#X connect 21 0 13 0;
+#X connect 21 1 13 1;
+#X connect 22 1 4 0;
+#X connect 23 0 6 0;
+#X connect 23 1 6 1;
diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js
index 062179290..7753dfbd7 100644
--- a/pd/nw/pd_canvas.js
+++ b/pd/nw/pd_canvas.js
@@ -768,7 +768,7 @@ var canvas_events = (function() {
         // Send a message on to Pd for the [mousewheel] legacy object
         // (in the future we can refcount if we want to prevent forwarding
         // these messages when there's no extant receiver)
-        pdgui.pdsend(name, "mousewheel", d.deltaX, d.deltaY, d.deltaZ);
+        pdgui.pdsend(name, "legacy_mousewheel", d.deltaX, d.deltaY, d.deltaZ);
     });
 
     // The following is commented out because we have to set the
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 71c33cfb0..667469047 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -3760,7 +3760,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
 void canvas_dispatch_mouseclick(t_float down, t_float xpos, t_float ypos,
     t_float which)
 {
-    t_symbol *mouseclicksym = gensym("#mouseclick");
+    t_symbol *mouseclicksym = gensym("#legacy_mouseclick");
     if (mouseclicksym->s_thing)
     {
         t_atom at[4];
@@ -3784,7 +3784,7 @@ void canvas_mousedown(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
 void canvas_mousewheel(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
     t_floatarg zpos)
 {
-    t_symbol *mousewheelsym = gensym("#mousewheel");
+    t_symbol *mousewheelsym = gensym("#legacy_mousewheel");
     if (mousewheelsym->s_thing)
     {
         t_atom at[3];
@@ -5349,7 +5349,7 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
     x->gl_editor->e_lastmoved = 1;
     // Dispatch to any listeners for the motion message
     if (!mousemotionsym)
-        mousemotionsym = gensym("#mousemotion");
+        mousemotionsym = gensym("#legacy_mousemotion");
     if (mousemotionsym->s_thing)
     {
         t_atom at[2];
@@ -7597,7 +7597,7 @@ void g_editor_setup(void)
     class_addmethod(canvas_class, (t_method)canvas_mousedown_middle,
         gensym("mouse-2"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
     class_addmethod(canvas_class, (t_method)canvas_mousewheel,
-        gensym("mousewheel"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
+        gensym("legacy_mousewheel"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
     class_addmethod(canvas_class, (t_method)canvas_key, gensym("key"),
         A_GIMME, A_NULL);
     class_addmethod(canvas_class, (t_method)canvas_motion, gensym("motion"),
diff --git a/pd/src/x_gui.c b/pd/src/x_gui.c
index 5d902a924..b5b66ca6b 100644
--- a/pd/src/x_gui.c
+++ b/pd/src/x_gui.c
@@ -594,23 +594,23 @@ static void mousewheel_free(t_mousewheel *x)
 
 static void mouse_setup(void)
 {
-    mousemotion_class = class_new(gensym("mousemotion"),
+    mousemotion_class = class_new(gensym("legacy_mousemotion"),
         (t_newmethod)mousemotion_new, (t_method)mousemotion_free,
         sizeof(t_mousemotion), CLASS_NOINLET, 0);
     class_addlist(mousemotion_class, mousemotion_list);
-    mousemotion_sym = gensym("#mousemotion");
+    mousemotion_sym = gensym("#legacy_mousemotion");
 
-    mouseclick_class = class_new(gensym("mouseclick"),
+    mouseclick_class = class_new(gensym("legacy_mouseclick"),
         (t_newmethod)mouseclick_new, (t_method)mouseclick_free,
         sizeof(t_mouseclick), CLASS_NOINLET, 0);
     class_addlist(mouseclick_class, mouseclick_list);
-    mouseclick_sym = gensym("#mouseclick");
+    mouseclick_sym = gensym("#legacy_mouseclick");
 
-    mousewheel_class = class_new(gensym("mousewheel"),
+    mousewheel_class = class_new(gensym("legacy_mousewheel"),
         (t_newmethod)mousewheel_new, (t_method)mousewheel_free,
         sizeof(t_mousewheel), CLASS_NOINLET, 0);
     class_addfloat(mousewheel_class, mousewheel_list);
-    mousewheel_sym = gensym("#mousewheel");
+    mousewheel_sym = gensym("#legacy_mousewheel");
 }
 
 /* -------------------------- setup routine ------------------------------ */
-- 
GitLab