diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 36d9aa913bbe5d58e9dcf8ee54db04cf9412ac7b..a22a37d838d66a6ecd2a19359d9b4c2d0155e197 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5362,24 +5362,31 @@ void canvas_mouseup(t_canvas *x, x->gl_editor->e_onmotion = MA_NONE; } - //fprintf(stderr,"canvas_mouseup -> canvas_doclick %d\n", which); - /* this is to ignore scrollbar clicks from within tcl and is - unused within nw.js 2.x implementation and onward. here, - we use doit = -1 to signify mouseup */ - //if (canvas_last_glist_mod == -1) { if (x->gl_editor->e_onmotion == MA_PASSOUT) { // here we borrow the double-click flag and make it -1 which signifies // mouse up since otherwise doit (the last argument) value of 0 is // shared between mouse up and mouse motion, making this unclear - int clickreturned = gobj_click( - x->gl_editor->e_grab, x, xpos, ypos, glob_shift, glob_alt, -1, 0); + if (x->gl_editor->e_grab) + { + int clickreturned = gobj_click( + x->gl_editor->e_grab, x, xpos, ypos, glob_shift, glob_alt, -1, 0); + } + // however, in the case of an array which does not have an e_grab declared + // we have to let go of the glist_grab instead + else + glist_grab(x, 0, 0, 0, 0, 0, 0, 0); x->gl_editor->e_onmotion = MA_NONE; } - canvas_doclick(x, xpos, ypos, 0, - (glob_shift + glob_ctrl*2 + glob_alt*4), 0); - //} + //fprintf(stderr,"canvas_mouseup -> canvas_doclick %d\n", which); + /* this is to ignore scrollbar clicks from within tcl and is + unused within nw.js 2.x implementation and onward. since + canvas_last_glist_mod is never set to -1 */ + //if (canvas_last_glist_mod == -1) + // canvas_doclick(x, xpos, ypos, 0, \ + // (glob_shift + glob_ctrl*2 + glob_alt*4), 0); + // now dispatch to any click listeners canvas_dispatch_mouseclick(0., xpos, ypos, which); } @@ -5933,8 +5940,8 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, //fprintf(stderr,"canvas_motion MA_SCROLL\n"); } else { - //fprintf(stderr,"canvas_motion -> doclick %d %d\n", - // x->gl_editor->e_onmotion, mod); + //post("canvas_motion -> doclick %d %d\n", \ + x->gl_editor->e_onmotion, mod); //canvas_getscroll( x); canvas_doclick(x, xpos, ypos, 0, mod, 0); //pd_vmess(&x->gl_pd, gensym("mouse"), "ffff", diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c index 86821c87ec580646c0fdd247afd98e19cb3f628c..a5704a1c7280bd878c25a30d8f6d46ce8544c2da 100644 --- a/pd/src/g_graph.c +++ b/pd/src/g_graph.c @@ -64,17 +64,18 @@ extern t_canvas *canvas_templatecanvas_forgroup(t_canvas *c); /* ico@vt.edu 2020-08-24: check if canvas consists of only scalars and returns 2. if the canvas only has the last object as a non-scalar (e.g. a new object has just been created, -then we return 1, otherwise return 0. this is used to prevent creation of new -objects in an GOP window that only has scalars inside it or scalars with one -newly created object that is yet to be typed into and therefore properly -instantiated */ +then we return 1, otherwise return 0. this is used to determine whether the +GOP redrect should be drawn inside the GOP-enabled toplevel window, depending +whether it only has scalars inside it or scalars with one newly created object +that is yet to be typed into and therefore properly instantiated */ int canvas_has_scalars_only(t_canvas *x) { t_gobj *g = x->gl_list; - int hasonlyscalars = 2; + int hasonlyscalars = 0; while (g) { //post("g..."); + hasonlyscalars = 2; if (pd_class(&g->g_pd) != scalar_class) { /* @@ -85,17 +86,20 @@ int canvas_has_scalars_only(t_canvas *x) /* ico@vt.edu 2020-08-24: if we have one more object or the last object is not newly - instantiated text object - to distinguish between a comment and a text object that is - yet to be instantiated we use: + instantiated text object to distinguish between a comment and + a text object that is yet to be instantiated we use: 1) comment is text_class and its te_type is T_TEXT 2) blank object one is typing into is text_class but is NOT T_TEXT - 3) instantiated object is something other than text_class (unless) - it is a comment + 3) instantiated object is something other than text_class (unless + it is a comment) 4) object that has failed to create is same as blank object */ if (g->g_next || (pd_class(&g->g_pd) != text_class || ((t_text *)g)->te_type == T_TEXT)) hasonlyscalars = 0; + // check if we are not the only object on the canvas, in which case we should still + // return 0 since we have no scalars inside the canvas + else if (g == x->gl_list && !g->g_next) + hasonlyscalars = 0; else hasonlyscalars = 1; break; @@ -103,7 +107,6 @@ int canvas_has_scalars_only(t_canvas *x) //post("...scalar, comment, or uninitialized object=yes"); g = g->g_next; } - //post("has scalars only=%d", hasonlyscalars); return(hasonlyscalars); } @@ -128,7 +131,7 @@ void glist_update_redrect(t_glist *x) } else if (canvas_has_scalars_only(x) && x->gl_goprect) { - x->gl_goprect = 0; + x->gl_goprect = 0; canvas_drawredrect(x, 0); } } diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index ae48b08d8453a6c16ff319354701dfcf26fa77e6..14a7fa2135a5f00efe5a71938be265d3b731e48d 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -47,8 +47,11 @@ static void my_numbox_tick_reset(t_my_numbox *x) // 2 = exclusive keyboard and mouse focus static void my_numbox_remove_grab(t_my_numbox *x) { - x->x_focused = 0; - glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0, 0, 0); + if (x->x_focused) + { + x->x_focused = 0; + glist_grab(x->x_gui.x_glist, 0, 0, 0, 0, 0, 0, 0); + } } void my_numbox_clip(t_my_numbox *x) @@ -485,9 +488,9 @@ static void my_numbox_save(t_gobj *z, t_binbuf *b) t_symbol *srl[3]; iemgui_save(&x->x_gui, srl, bflcol); + my_numbox_remove_grab(x); if(x->x_focused) { - my_numbox_remove_grab(x); clock_unset(x->x_clock_reset); x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -548,9 +551,9 @@ static void my_numbox_properties(t_gobj *z, t_glist *owner) t_symbol *srl[3]; iemgui_properties(&x->x_gui, srl); - if(x->x_gui.x_change) + my_numbox_remove_grab(x); + if(x->x_focused) { - my_numbox_remove_grab(x); clock_unset(x->x_clock_reset); x->x_gui.x_changed = 1; sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update); @@ -1136,7 +1139,6 @@ static void my_numbox_free(t_my_numbox *x) { if(iemgui_has_rcv(&x->x_gui)) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); - x->x_focused = 0; my_numbox_remove_grab(x); clock_free(x->x_clock_reset); gfxstub_deleteforkey(x);