From 0c5703e92dfbaeb92e335a43b49ff41053d670ab Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Thu, 13 Nov 2014 23:17:40 -0500
Subject: [PATCH] *reverted commit 46933bb2f5fe486e22dcad84036ce91f71b84dd0 as
 it deemed unnecessary (it was designed to support buggy backwards-compatible
 behavior that defies common UI practices). *further enhanced getrect
 calculation for the mycanvas widget to disallow clicking through a canvas
 across its entire size, rather than just the area by which one can "grab" and
 move the widget

---
 pd/src/g_editor.c   | 6 ++----
 pd/src/g_graph.c    | 6 ++----
 pd/src/g_mycanvas.c | 3 ++-
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index c294e0287..fc814ed00 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -3017,8 +3017,6 @@ static double canvas_upclicktime;
 static int canvas_upx, canvas_upy;
 #define DCLICKINTERVAL 0.25
 
-extern t_class *my_canvas_class; // for ignoring runtime clicks
-
     /* mouse click */
 void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
     int mod, int doit)
@@ -3131,8 +3129,8 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
             if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2))
             {
                 ob = pd_checkobject(&y->g_pd);
-                /* do not give clicks to comments or cnv during runtime */
-                if (!ob || (ob->te_type != T_TEXT && ob->ob_pd != my_canvas_class)) 
+                /* do not give clicks to comments during runtime */
+                if (!ob || ob->te_type != T_TEXT) 
                     yclick = y;
                 //fprintf(stderr,"    MAIN found clickable %d\n",
                 //    clickreturned);
diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c
index 6c1b05bdf..0a62b4c75 100644
--- a/pd/src/g_graph.c
+++ b/pd/src/g_graph.c
@@ -1483,8 +1483,6 @@ static void graph_motion(void *z, t_floatarg dx, t_floatarg dy)
     garray_redraw(a);
 }
 
-extern t_class *my_canvas_class; // for ignoring runtime clicks
-
 static int graph_click(t_gobj *z, struct _glist *glist,
     int xpix, int ypix, int shift, int alt, int dbl, int doit)
 {
@@ -1519,8 +1517,8 @@ static int graph_click(t_gobj *z, struct _glist *glist,
                 if (canvas_hitbox(x, y, xpix, ypix, &x1, &y1, &x2, &y2))
                 {
                     ob = pd_checkobject(&y->g_pd);
-                    /* do not give clicks to comments or cnv during runtime */
-                    if (!ob || (ob->te_type != T_TEXT && ob->ob_pd != my_canvas_class)) 
+                    /* do not give clicks to comments during runtime */
+                    if (!ob || ob->te_type != T_TEXT) 
                         clickme = y;
                     //fprintf(stderr,"    found clickable %d\n", clickreturned);
                 }
diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c
index bd05bd5e6..c3254df71 100644
--- a/pd/src/g_mycanvas.c
+++ b/pd/src/g_mycanvas.c
@@ -149,9 +149,10 @@ static void my_canvas_getrect(t_gobj *z, t_glist *glist,
     
     *xp1 = text_xpix(&x->x_gui.x_obj, glist);
     *yp1 = text_ypix(&x->x_gui.x_obj, glist);
-    if (!glist_istoplevel(glist))
+    if (!glist_istoplevel(glist) || !glist->gl_edit)
     {
         //if we are trying to calculate visibility of a widget inside a GOP
+        //or are calculating getrect during runtime
         *xp2 = *xp1 + x->x_vis_w;
         *yp2 = *yp1 + x->x_vis_h;
     }
-- 
GitLab