[comp.windows.x] questions on server side implementation of XTest extension

lowe@nthropy.UUCP (Andy Lowe) (09/14/90)

Fellow server hackers,

I'm trying to implement the XTest input synthesis extension for our
X11R4 server and I'm confused about the following routines described
in $top/extensions/server/xtest1.frags:

...
> You also need to implement the following routines (documentation
> is needed; for now, see server/ddx/hp/hp/x_hil.c):
...
> XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey)
> XTestGetPointerPos(fmousex, fmousey)
> XTestJumpPointer(jx, jy, dev_type)

all I have in the indicated directory is: 

hp.300.o.Z
hp.800.o.Z

evidently, the dreaded institutional OCO (object code only) virus
attacked hp at the last minute!

In fact, 

19% cd $top/server/ddx
20% grep XTestGenerateEvent `find . -name "*.[ch]" -print`

generated only one match, and that was an invocation, not a definition:

./tek/pegInit.c:    XTestGenerateEvent(0, 0, 0, 0, 0);

Similarly, 

39% cd $top/extensions
40% grep XTestGenerateEvent `find . -name "*.[ch]" -print`

only generated two matches, also invocations, as it turns out:

./server/xtest1dd.c:void	XTestGenerateEvent();
./server/xtest1dd.c:			    XTestGenerateEvent(

Oddly, these functions are not mentioned at all in the (scant)
documentation I have ($top/doc/extensions/xtest1.mm), but I don't
think it will work without them.  Am I missing something?


Any assistance will be greatly appreciated!

regards,

Andy Lowe
andy@nth.com

gms@hpcvlx.cv.hp.com (George Sachs) (09/15/90)

XTestGenerateEvent is supposed to cause the server to generate a key or
button event, exactly as one would be generated if a user pressed a key
or pushed a mouse button.  Without knowing how your server does that for
normal input events, I can't tell you exactly how that should look, but 
it would be something like:

void
XTestGenerateEvent (dev_type, key_or_button_code, direction, x, y)
    int dev_type;		/* MOUSE = X pointer, KEYBOARD = X keyboard */
    int key_or_button_code;	/* code to stash in event */
    int direction;          	/* XTestKEY_UP or XTestKEY_DOWN */
    int x,y;			/* location of event  */
    {
    int type;
    xEvent *xE;		

    if (key_or_button_code < 8)		/* must be a button */
	if (direction == XTestKEY_UP)	/* it's a release event*/
	    type = ButtonRelease;
	else
	    type = ButtonPress;
    else				/* must be a key */
	if (direction == XTestKEY_UP)	/* it's a release event*/
	    type = KeyRelease;
	else
	    type = KeyPress;

    /* get an xEvent from some place where ProcessInputEvents can find it. */
    /* I don't know how your implementation does this. */

    xE = somehow_get_xEvent();

    xE->u.u.type = type;
    xE->u.u.detail = key_or_button_code;
    xE->u.keyButtonPointer.time = GetTimeInMillis();
    xE->u.keyButtonPointer.rootX = x;
    xE->u.keyButtonPointer.rootY = y;

    /* now call ProcessInputEvents to send the event to DIX for routing to the
       appropriate client(s). */

    ProcessInputEvents();
    }


XTestJumpPointer performs the equivalent function for pointer events.

void
XTestJumpPointer (x, y, dev_type)
    int x,y;
    int dev_type;
    {
    /* get an xEvent from some place where ProcessInputEvents can find it. */
    /* I don't know how your implementation does this. */

    xE = somehow_get_xEvent();

    xE->u.u.type = MotionNotify;
    xE->u.keyButtonPointer.time = GetTimeInMillis();
    xE->u.keyButtonPointer.rootX = x;
    xE->u.keyButtonPointer.rootY = y;

    /* Call some place in your server code that takes care of acceleration and 
       threshold.  Also constrain the move to the screen bounds.  You
       may also have a motion history buffer that should be updated with
       the information in this event.
       */

    deal_with_acceleration ();
    constrainxy();
    update_motion_history();

    /* now call ProcessInputEvents to send the event to DIX for routing to the
       appropriate client(s). */

    ProcessInputEvents();
    }

XTestGetPointerPos returns the server's notion of where the X pointer currently
is.  This is probably kept by ddx in some implementation-specific structure:

Implementation_Specific_Struct *i;

void
XTestGetPointerPos (x,y)
    short *x,*y;
    {
    *x = i->x;
    *y = i->y;
    }