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

Broken implementation of grab focus improvement (to be migrated to linux...

Broken implementation of grab focus improvement (to be migrated to linux because Windoze debugging is a joke)
parent 00794d7f
......@@ -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, xpix, ypix);
glist_grab(glist, 0, array_motion, 0, 0, 0, xpix, ypix);
}
if (alt)
{
......
......@@ -60,6 +60,8 @@ typedef struct _updateheader
/* types to support glists grabbing mouse motion or keys from parent */
typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
typedef void (*t_glistkeynamefn)(void *z, t_symbol *s, int argc, t_atom *argv);
typedef void (*t_glistkeynameafn)(void *z, t_symbol *s, int argc, t_atom *argv);
EXTERN_STRUCT _rtext;
#define t_rtext struct _rtext
......@@ -106,9 +108,11 @@ typedef struct _editor
t_rtext *e_rtext; /* text responder linked list */
t_selection *e_selection; /* head of the selection list */
t_rtext *e_textedfor; /* the rtext if any that we are editing */
t_gobj *e_grab; /* object being "dragged" */
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_binbuf *e_connectbuf; /* connections to deleted objects */
t_binbuf *e_deleted; /* last stuff we deleted */
t_guiconnect *e_guiconnect; /* GUI connection for filtering messages */
......@@ -458,7 +462,8 @@ 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, int xpos, int ypos);
t_glistkeyfn keyfn, t_glistkeynamefn keynamefn, t_glistkeynameafn keynameafn,
int xpos, int ypos);
EXTERN int glist_isvisible(t_glist *x);
EXTERN int glist_istoplevel(t_glist *x);
EXTERN t_glist *glist_findgraph(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);
glist_grab(x, 0, 0, 0, 0, 0, 0, 0);
}
if (doit && !runmode && xpos == canvas_upx && ypos == canvas_upy &&
......@@ -5478,7 +5478,7 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
// now broadcast key press to key et al. objects
// ico@vt.edu 20200918: only do so if we do not have an object
// that has grabbed the keyboard, such as gatom or iemgui numbox
if (!x || !x->gl_editor || !x->gl_editor->e_keyfn)
if (!x || !x->gl_editor || !x->gl_editor->e_grab)
{
if (!autorepeat)
{
......@@ -5508,6 +5508,38 @@ 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;
......
......@@ -366,8 +366,8 @@ void glist_retext(t_glist *glist, t_text *y)
}
}
void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
t_glistkeyfn keyfn, int xpos, int ypos)
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)
{
//fprintf(stderr,"glist_grab\n");
t_glist *x2 = glist_getcanvas(x);
......@@ -377,6 +377,8 @@ void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
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;
}
......
......@@ -28,6 +28,7 @@ t_widgetbehavior my_numbox_widgetbehavior;
// forward declaration
static void my_numbox_set_change(t_my_numbox *x, t_floatarg f);
static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av);
static t_symbol *numbox_keyname_sym_a;
......@@ -593,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, xpos, ypos);
(t_glistmotionfn)my_numbox_motion, my_numbox_key, 0, 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, xpos, ypos);
(t_glistmotionfn)slider_motion, 0, 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, xpix, ypix);
glist_grab(glist, z, draw_motion, 0, 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, xpix, ypix);
glist_grab(glist, z, draw_motion, 0, 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, xpix, ypix);
glist_grab(glist, z, curve_motion, 0, 0, 0, xpix, ypix);
}
return (1);
}
......@@ -7505,8 +7505,9 @@ static int drawsymbol_click(t_gobj *z, t_glist *glist,
drawsymbol_motion_glist, &drawsymbol_motion_scalar->sc_gobj);
else gpointer_setarray(&drawsymbol_motion_gpointer,
drawsymbol_motion_array, drawsymbol_motion_wp);
glist_grab(glist, z, drawsymbol_motion, drawsymbol_key,
xpix, ypix);
/* ico@vt.edu 20200920: LATER consider also using keyname (currently 0) */
glist_grab(glist, z, drawsymbol_motion, drawsymbol_key,
0, 0, xpix, ypix);
}
return (1);
}
......@@ -7935,8 +7936,9 @@ static int drawimage_click(t_gobj *z, t_glist *glist,
drawimage_motion_glist, &drawimage_motion_scalar->sc_gobj);
else gpointer_setarray(&drawimage_motion_gpointer,
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,
xpix, ypix);
0, 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);
//glist_grab(x->a_glist, 0, 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,
xpos, ypos);
0, 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