From 9b94322e8dde0558b5b9167d555782e560a2d31b Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Sun, 17 Nov 2013 13:27:29 -0500 Subject: [PATCH] fixed cursor inconsistently failing to reflect topmost clickable object while ignoring non-clickable objects that are above topmost clickable object, both on main canvas and inside gop objects. --- pd/src/g_editor.c | 35 +++++++++++++++++++++++++---------- pd/src/g_graph.c | 26 ++++++++++++++++++++------ 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index df773a0b6..ff1af59f1 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -2752,10 +2752,10 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, t_gobj *y; int shiftmod, runmode, altmod, doublemod = 0, rightclick; - int x1=0, y1=0, x2=0, y2=0, clickreturned = 0; + int x1=0, y1=0, x2=0, y2=0, clickreturned = 0, tmpclickreturned = 0; t_gobj *yclick = NULL; - //fprintf(stderr,"canvas_doclick %d %d %d %d %d\n", xpos, ypos, which, mod, doit); + //fprintf(stderr,"MAIN canvas_doclick %d %d %d %d %d\n", xpos, ypos, which, mod, doit); if (!x->gl_editor) { @@ -2827,21 +2827,36 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, // if we are in runmode and it is not middle- or right-click if (runmode && !rightclick) { + //fprintf(stderr, "runmode && !rightclick\n"); for (y = x->gl_list; y; y = y->g_next) { - // check if the object wants to be clicked (we pick the topmost) - if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2)) + // check if the object wants to be clicked (we pick the topmost clickable) + if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2) && (tmpclickreturned = gobj_click(y, x, xpos, ypos, + shiftmod, ((mod & CTRLMOD) && (!x->gl_edit)) || altmod, + 0, 0))) { yclick = y; + clickreturned = tmpclickreturned; + //fprintf(stderr," MAIN found clickable %d\n", clickreturned); + } + } + if (yclick && doit) { + clickreturned = gobj_click(yclick, x, xpos, ypos, + shiftmod, ((mod & CTRLMOD) && (!x->gl_edit)) || altmod, + 0, doit); + //fprintf(stderr, " MAIN clicking\n"); } - if (yclick) clickreturned = gobj_click(yclick, x, xpos, ypos, - shiftmod, ((mod & CTRLMOD) && (!x->gl_edit)) || altmod, - 0, doit); // if we are not clicking if (!doit) { - if (yclick) + //fprintf(stderr, " MAIN not clicking\n"); + if (yclick) { + //fprintf(stderr, " MAIN cursor %d\n", clickreturned); canvas_setcursor(x, clickreturned); - else canvas_setcursor(x, CURSOR_RUNMODE_NOTHING); + } + else { + //fprintf(stderr, " MAIN cursor\n"); + canvas_setcursor(x, CURSOR_RUNMODE_NOTHING); + } } return; } @@ -4554,7 +4569,7 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, return; } if (canvas_last_glist_mod == -1 && mod != -1) { - //fprintf(stderr,"revert the cursor %d\n", x->gl_edit); + fprintf(stderr,"revert the cursor %d\n", x->gl_edit); if (x->gl_edit) canvas_setcursor(x, CURSOR_EDITMODE_NOTHING); else diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c index a0169a4d4..a1b77c794 100644 --- a/pd/src/g_graph.c +++ b/pd/src/g_graph.c @@ -1305,9 +1305,11 @@ static void graph_motion(void *z, t_floatarg dx, t_floatarg dy) static int graph_click(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { + //fprintf(stderr, "graph_click\n"); t_glist *x = (t_glist *)z; t_gobj *y, *clickme = NULL; int clickreturned = 0; + int tmpclickreturned = 0; if (!x->gl_isgraph) return (text_widgetbehavior.w_clickfn(z, glist, xpix, ypix, shift, alt, dbl, doit)); @@ -1320,17 +1322,29 @@ static int graph_click(t_gobj *z, struct _glist *glist, { /* check if the object wants to be clicked */ if (canvas_hitbox(x, y, xpix, ypix, &x1, &y1, &x2, &y2) - && (clickreturned = gobj_click(y, x, xpix, ypix, - shift, alt, 0, 0))) - clickme = y; + && (tmpclickreturned = gobj_click(y, x, xpix, ypix, + shift, alt, 0, 0))) { + clickme = y; + clickreturned = tmpclickreturned; + //fprintf(stderr," found clickable %d\n", clickreturned); + } } - if (clickme != NULL) clickreturned = gobj_click(clickme, x, xpix, ypix, + if (clickme != NULL && doit) { + //fprintf(stderr," clicking\n"); + clickreturned = gobj_click(clickme, x, xpix, ypix, shift, alt, 0, doit); + } if (!doit) { - if (clickme) + //fprintf(stderr," not clicking %lx %d\n", (t_int)clickme, clickreturned); + if (clickme != NULL) { + //fprintf(stderr," cursor %d\n", clickreturned); canvas_setcursor(glist_getcanvas(x), clickreturned); - else canvas_setcursor(glist_getcanvas(x), CURSOR_RUNMODE_NOTHING); + } + else { + //fprintf(stderr," cursor 0\n"); + canvas_setcursor(glist_getcanvas(x), CURSOR_RUNMODE_NOTHING); + } } return (clickreturned); } -- GitLab