XTrap & window focus - Xwindows

This is a discussion on XTrap & window focus - Xwindows ; Hello, I am looking at writing an app (hack?) to allow gesture input for tablet computers (I use Kubuntu on my Fujitsu slate). I've worked out a way to get cursive handwriting recognition going, which led to the question of ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: XTrap & window focus

  1. XTrap & window focus

    Hello,

    I am looking at writing an app (hack?) to allow gesture input for tablet
    computers (I use Kubuntu on my Fujitsu slate). I've worked out a way to
    get cursive handwriting recognition going, which led to the question of
    how to invoke handwriting entry, which led to...

    One aspect is to make the gestures application (window) specific - this
    requires identifying the window/app on button-down at the beginning of
    any stroke inputs, providing a context for interpreting the meaning of
    the stroke.

    xprop gets me good information to identify what a window is at a user
    level (name or program, class of window, etc.), allowing a context for
    the meaning of a gesture, but requires an ID or control of the pointer
    to get it.

    XTrap feeds me X11 events, but I haven't found a way to reliably get the
    window ID out of it from the button-down message.

    I grafted code from xwininfo into the event callback for XTrap, but that
    doesn't provide IDs for some windows that don't appear to accept the
    focus, such as XVkbd (which I use for text input now).

    I'd like to leave the current X11 focus/input functionality alone, but
    provide a ghost-that-watches-for-gestures which pipes in keystrokes when
    it recognizes a gesture. So, if the user selects a window
    (button-down), X11 treats that as it does now, and if the user continues
    with a gesture, keystrokes appear in the X11 input (I don't think that's
    a problem). No recognized gesture, no input, and X11 sails along doing
    everything just as it always does. But getting the button-down
    context/focus isn't working.

    I'm a Java, python, and ant programmer. I'm afraid I'm lost in X11.
    I've done a bit of C in the past, but I'm not practiced.

    I'd greatly appreciate some discussion of how I might accomplish this -
    I'm really surprised XTrap doesn't give me the focus - there must be
    something fundamental about the system I don't understand.

    Thanks in advance,
    Bret

  2. Re: XTrap & window focus

    Bret Comstock Waldow wrote:
    > I grafted code from xwininfo into the event callback for XTrap, but that
    > doesn't provide IDs for some windows that don't appear to accept the
    > focus, such as XVkbd (which I use for text input now).


    Here is the event callback I have now for xtrapout (sorry about the line
    folding):

    static void print_evt_callback( XETC *tc, XETrapDatum *data, char *my_buf )
    {
    static Time last_time = 0;
    int delta, eventType;
    Window target_win = None, root = RootWindow(dpy, 0/*screen*/);

    delta = abs( ( int )last_time ? data->u.event.u.keyButtonPointer.time -
    ( int )last_time : ( int )last_time );
    last_time = data->u.event.u.keyButtonPointer.time;

    eventType = data->u.event.u.u.type;

    if ( ( 4 == eventType ) /*|| ( 5 == eventType ) || ( 6 == eventType )*/ )
    {
    XGetInputFocus (dpy, &focuswin, &focusrevert);
    fprintf (ofp, "focus: ");
    switch (focuswin)
    {
    case PointerRoot:
    fprintf (ofp, "PointerRoot\n");
    break;
    case None:
    fprintf (ofp, "None\n");
    break;
    default:
    fprintf(ofp, "window 0x%lx, revert to ", focuswin);
    switch (focusrevert)
    {
    case RevertToParent:
    fprintf (ofp, "Parent\n");
    break;
    case RevertToNone:
    fprintf (ofp, "None\n");
    break;
    case RevertToPointerRoot:
    fprintf (ofp, "PointerRoot\n");
    break;
    default: /* should not happen */
    fprintf (ofp, "%d\n", focusrevert);
    break;
    }
    break;
    }

    /* The "screen" and "root" fields aren't valid until "event"
    * vectoring becomes a reality. Currently, XTrap intercepts
    * the core events prior to when fields other than rootX, rootY,
    * type, detail, time, and state are filled in. This will be
    * addressed in the next release of XTrap (3.2?).
    */
    fprintf( ofp,
    /*"Event: %-15s (%d):det=%d scr=%d (%d,%d) root=%d Msk=%d
    TS=%d\n",*/
    "Event: %-15s (%d):det=%d window=0x%lx (%d,%d) root=%d Msk=%d
    TS=%d\n",
    XEEventIDToString( data->u.event.u.u.type, tc ),
    data->u.event.u.u.type,
    data->u.event.u.u.detail,
    /*data->hdr.screen, *//* Not really valid yet */
    data->u.event.u.focus.window,
    data->u.event.u.keyButtonPointer.rootX,
    data->u.event.u.keyButtonPointer.rootY,
    ( int )data->u.event.u.keyButtonPointer.root, /* Not
    really valid yet */
    ( int )data->u.event.u.keyButtonPointer.state,
    ( int )delta );
    fflush( ofp );
    }
    }


+ Reply to Thread