Commit e90ea28e authored by Ivica Bukvic's avatar Ivica Bukvic Committed by Albert Gräf
Browse files

Proper fix for glist_grabbed keyboard focus

parent 2f1ee177
......@@ -1265,7 +1265,7 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
array_motion_ycumulative = 0;
}
//fprintf(stderr," glist_grab %d %d\n", xpix, ypix);
glist_grab(glist, 0, array_motion, 0, 0, 0, xpix, ypix);
glist_grab(glist, 0, array_motion, 0, 0, xpix, ypix);
}
if (alt)
{
......
......@@ -111,8 +111,7 @@ typedef struct _editor
t_gobj *e_grab; /* object being dragged/focused */
t_glistmotionfn e_motionfn; /* ... motion callback */
t_glistkeyfn e_keyfn; /* ... keypress callback */
t_glistkeynamefn e_keynamefn; /* ... keyname press callback */
t_glistkeynameafn e_keynameafn; /* ... keynamea press callback */
t_glistkeynameafn e_keynameafn; /* ... keyname with autorepeat press callback */
t_binbuf *e_connectbuf; /* connections to deleted objects */
t_binbuf *e_deleted; /* last stuff we deleted */
t_guiconnect *e_guiconnect; /* GUI connection for filtering messages */
......@@ -462,7 +461,7 @@ EXTERN void glist_selectall(t_glist *x);
EXTERN void glist_delete(t_glist *x, t_gobj *y);
EXTERN void glist_retext(t_glist *x, t_text *y);
EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
t_glistkeyfn keyfn, t_glistkeynamefn keynamefn, t_glistkeynameafn keynameafn,
t_glistkeyfn keyfn, t_glistkeynameafn keynameafn,
int xpos, int ypos);
EXTERN int glist_isvisible(t_glist *x);
EXTERN int glist_istoplevel(t_glist *x);
......
......@@ -3577,7 +3577,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
if (doit && x->gl_editor->e_grab && x->gl_editor->e_keyfn)
{
(* x->gl_editor->e_keyfn) (x->gl_editor->e_grab, 0);
glist_grab(x, 0, 0, 0, 0, 0, 0, 0);
glist_grab(x, 0, 0, 0, 0, 0, 0);
}
if (doit && !runmode && xpos == canvas_upx && ypos == canvas_upy &&
......@@ -5508,38 +5508,6 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
pd_list(keynamesym_a->s_thing, 0, 2, at);
}
}
// we need to explicitly pass key/keyname/keyname_a to the grabbed object
// since the above code is being bypassed. Only do so to the grabbed object.
else if (x && x->gl_editor && x->gl_editor->e_grab)
{
if (!autorepeat)
{
if (x->gl_editor->e_keyfn && down)
pd_float((void *)x->gl_editor->e_keyfn, (t_float)keynum);
if (x->gl_editor->e_keyfn && !down)
pd_float((void *)x->gl_editor->e_keyfn, (t_float)keynum);
if (x->gl_editor->e_keynamefn)
{
at[0] = av[0];
SETFLOAT(at, down);
SETSYMBOL(at+1, gotkeysym);
pd_list((void *)x->gl_editor->e_keynamefn, 0, 2, at);
}
}
// now do the same for autorepeat-enabled objects (key et al. alternative behavior)
if (x->gl_editor->e_keyfn && down)
pd_float((void *)x->gl_editor->e_keyfn, (t_float)keynum);
if (x->gl_editor->e_keyfn && !down)
pd_float((void *)x->gl_editor->e_keyfn, (t_float)keynum);
if (keynamesym_a->s_thing)
{
at[0] = av[0];
SETFLOAT(at, down);
SETSYMBOL(at+1, gotkeysym);
pd_list((void *)x->gl_editor->e_keynameafn, 0, 2, at);
}
}
if (!x || !x->gl_editor)
return;
......@@ -5549,10 +5517,19 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
if (x->gl_editor->e_onmotion == MA_MOVE)
x->gl_editor->e_onmotion = MA_NONE;
/* if an object has "grabbed" keys just send them on */
if (x->gl_editor->e_grab
&& x->gl_editor->e_keyfn && keynum && focus)
if (x->gl_editor->e_grab)
{
if (x->gl_editor->e_keyfn && keynum && focus)
(* x->gl_editor->e_keyfn)
(x->gl_editor->e_grab, (t_float)keynum);
if (x->gl_editor->e_keynameafn && gotkeysym && focus)
{
at[0] = av[0];
SETFLOAT(at, down);
SETSYMBOL(at+1, gotkeysym);
(* x->gl_editor->e_keynameafn) (x->gl_editor->e_grab, 0, 2, at);
}
}
/* if a text editor is open send the key on, as long as
it is either "real" (has a key number) or else is an arrow key. */
else if (x->gl_editor->e_textedfor && focus && (keynum
......
......@@ -367,7 +367,7 @@ void glist_retext(t_glist *glist, t_text *y)
}
void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn, t_glistkeyfn keyfn,
t_glistkeynamefn keynamefn, t_glistkeynameafn keynameafn, int xpos, int ypos)
t_glistkeynameafn keynameafn, int xpos, int ypos)
{
//fprintf(stderr,"glist_grab\n");
t_glist *x2 = glist_getcanvas(x);
......@@ -377,7 +377,6 @@ void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn, t_glistkeyfn ke
x2->gl_editor->e_grab = y;
x2->gl_editor->e_motionfn = motionfn;
x2->gl_editor->e_keyfn = keyfn;
x2->gl_editor->e_keynamefn = keynamefn;
x2->gl_editor->e_keynameafn = keynameafn;
x2->gl_editor->e_xwas = xpos;
x2->gl_editor->e_ywas = ypos;
......
......@@ -594,7 +594,7 @@ static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos,
{
//post("my_numbox_click");
glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
(t_glistmotionfn)my_numbox_motion, my_numbox_key, 0, my_numbox_list, xpos, ypos);
(t_glistmotionfn)my_numbox_motion, my_numbox_key, my_numbox_list, xpos, ypos);
}
static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
......
......@@ -392,7 +392,7 @@ static void slider_click(t_slider *x, t_floatarg xpos, t_floatarg ypos,
x->x_is_last_float=0; // does anyone know how this works with !steady && rcv==snd ?
slider_bang(x);
glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
(t_glistmotionfn)slider_motion, 0, 0, 0, xpos, ypos);
(t_glistmotionfn)slider_motion, 0, 0, xpos, ypos);
}
static int slider_newclick(t_gobj *z, struct _glist *glist,
......
......@@ -4475,7 +4475,7 @@ static int draw_click(t_gobj *z, t_glist *glist,
&draw_motion_scalar->sc_gobj);
else gpointer_setarray(&draw_motion_gpointer,
draw_motion_array, draw_motion_wp);
glist_grab(glist, z, draw_motion, 0, 0, 0, xpix, ypix);
glist_grab(glist, z, draw_motion, 0, 0, xpix, ypix);
//outlet_anything(x->x_obj.ob_outlet, gensym("click"), 0, 0);
}
//draw_notifyforscalar(x, glist, sc, gensym("mousedown"), 5, at);
......@@ -4693,7 +4693,7 @@ static int draw_click(t_gobj *z, t_glist *glist,
&draw_motion_scalar->sc_gobj);
else gpointer_setarray(&draw_motion_gpointer,
draw_motion_array, draw_motion_wp);
glist_grab(glist, z, draw_motion, 0, 0, 0, xpix, ypix);
glist_grab(glist, z, draw_motion, 0, 0, xpix, ypix);
}
post("we got clicked");
outlet_anything(x->x_obj.ob_outlet, gensym("click"), 0, 0);
......@@ -5475,7 +5475,7 @@ static int curve_click(t_gobj *z, t_glist *glist,
&curve_motion_scalar->sc_gobj);
else gpointer_setarray(&curve_motion_gpointer,
curve_motion_array, curve_motion_wp);
glist_grab(glist, z, curve_motion, 0, 0, 0, xpix, ypix);
glist_grab(glist, z, curve_motion, 0, 0, xpix, ypix);
}
return (1);
}
......@@ -7507,7 +7507,7 @@ static int drawsymbol_click(t_gobj *z, t_glist *glist,
drawsymbol_motion_array, drawsymbol_motion_wp);
/* ico@vt.edu 20200920: LATER consider also using keyname (currently 0) */
glist_grab(glist, z, drawsymbol_motion, drawsymbol_key,
0, 0, xpix, ypix);
0, xpix, ypix);
}
return (1);
}
......@@ -7938,7 +7938,7 @@ static int drawimage_click(t_gobj *z, t_glist *glist,
drawimage_motion_array, drawimage_motion_wp);
/* ico@vt.edu 20200920: LATER consider also using keyname (currently 0) */
glist_grab(glist, z, drawimage_motion, drawimage_key,
0, 0, xpix, ypix);
0, xpix, ypix);
}
return (1);
}
......
......@@ -1191,7 +1191,7 @@ static void gatom_key(void *z, t_floatarg f)
x->a_buf[0] = 0;
/* We want to keep grabbing the keyboard after hitting "Enter", so
we're commenting the following out */
//glist_grab(x->a_glist, 0, 0, 0, 0, 0, 0, 0);
//glist_grab(x->a_glist, 0, 0, 0, 0, 0, 0);
}
else if (len < (ATOMBUFSIZE-1))
{
......@@ -1257,7 +1257,7 @@ static void gatom_click(t_gatom *x,
}
x->a_shift = shift;
glist_grab(x->a_glist, &x->a_text.te_g, gatom_motion, gatom_key,
0, gatom_list, xpos, ypos);
gatom_list, xpos, ypos);
//post("a_shift_clicked=%d", x->a_shift_clicked);
x->a_shift_clicked = shift;
// second click wipes prior text
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment