From c5f5a57945564ef3ccc991e3165cea08de052490 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Sat, 18 Nov 2017 22:52:41 -0500
Subject: [PATCH] use recursive call to gobj_shouldvis to suppress nested gop
 drawings, also

remove redundant call in g_mycanvas.c and filter repeated label updates if
the label hasn't changed as in Pd Vanilla
---
 pd/src/g_all_guis.c | 10 +++-------
 pd/src/g_editor.c   |  9 ++++++++-
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c
index 84748f1d8..4c0c6591b 100644
--- a/pd/src/g_all_guis.c
+++ b/pd/src/g_all_guis.c
@@ -231,19 +231,15 @@ void iemgui_receive(t_iemgui *x, t_symbol *s)
 
 void iemgui_label(t_iemgui *x, t_symbol *s)
 {
+    t_symbol *old;
     if (s == &s_) s = s_empty; //tb: fix for empty label
+    old = x->x_lab;
     t_symbol *lab = iemgui_raute2dollar(s);
     x->x_lab_unexpanded = lab;
     x->x_lab = lab = canvas_realizedollar(x->x_glist, lab);
 
-    if(glist_isvisible(x->x_glist))
-    {
-        gui_vmess("gui_iemgui_label_set", "xxs",
-            glist_getcanvas(x->x_glist),
-            x,
-            s != s_empty ? x->x_lab->s_name : "");
+    if (glist_isvisible(x->x_glist) && lab != old)
         iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_CONFIG);
-    }
 }
 
 void iemgui_label_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index abea62817..f759c428c 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -220,6 +220,13 @@ int gobj_shouldvis(t_gobj *x, struct _glist *glist)
     //fprintf(stderr,"shouldvis %d %d %d %d\n",
     //    glist->gl_havewindow, glist->gl_isgraph,
     //    glist->gl_goprect, glist->gl_owner != NULL);
+        /* if our parent is a graph, and if that graph itself isn't
+        visible, then we aren't either. */
+    if (!glist->gl_havewindow && glist->gl_isgraph && glist->gl_owner
+        && !gobj_shouldvis(&glist->gl_gobj, glist->gl_owner))
+            return (0);
+        /* if we're graphing-on-parent and the object falls outside the
+        graph rectangle, don't draw it. */
     if (!glist->gl_havewindow && glist->gl_isgraph && glist->gl_goprect &&
         glist->gl_owner && (pd_class(&x->g_pd) != scalar_class) &&
         (pd_class(&x->g_pd) != garray_class))
@@ -2880,7 +2887,7 @@ static void canvas_donecanvasdialog(t_glist *x,
     {
         glist_noselect(x);
         gobj_vis(&x->gl_gobj, x->gl_owner, 0);
-        if (gobj_shouldvis(&x->gl_obj, x->gl_owner))
+        if (gobj_shouldvis(&x->gl_gobj, x->gl_owner))
         {
             gobj_vis(&x->gl_gobj, x->gl_owner, 1);
             //fprintf(stderr,"yes\n");
-- 
GitLab