Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!mips!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hp-pcd!hpcvlx!gms From: gms@hpcvlx.cv.hp.com (George Sachs) Newsgroups: comp.windows.x Subject: Re: questions on server side implementation of XTest extension Message-ID: <100920249@hpcvlx.cv.hp.com> Date: 14 Sep 90 20:52:43 GMT References: <9009141145.AA12379@nth.com> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 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; }