[comp.windows.x] too many motion notify events

jdi@sparky.UUCP (John Irwin) (12/14/88)

These experiences are brought to you by a Sun4/OS(4.0|3.2),
X11.R3 patchlevel 3, and my mouse.

Has anyone else seen cases where motion events go on "too long" after a button
is released?  For example: Drag a window with uwm; release the button
and continue to drag the mouse.  Sometimes I have the window keep moving
with the mouse *after* I've released the button.

I'm also able to recreate this occasionally using Lisp and CLX.
The pointer is grabbed with :button-motion and :pointer-motion-hint on,
but after the button is released (no others are down) the client receives some
more motion events.

This only seems to happen when the X11 server is loaded, and didn't seem to
happen with X.V11R2.  Has anyone seen this?

	-- John

jim@athsys.uucp (Jim Becker) (12/15/88)

From article <8812132316.AA05716@sparky>, by jdi@sparky.UUCP (John Irwin):
> 
> Has anyone else seen cases where motion events go on "too long" after a button
> is released?  For example: Drag a window with uwm; release the button
> and continue to drag the mouse.  Sometimes I have the window keep moving
> with the mouse *after* I've released the button.


	Although this is a guess, it is possible that the software
processing the motion events is doing an XQueryPointer() to get the
current mouse coordinates (rather than those in the XEvent structure).
This is actually sometimes needed if the application and/or server is
having problems keeping up with the user.  If the processing was fast
enough, this would not be needed, but that isn't always the case.

	If this is the case, a simple check of the mouse button mask
could shortcut the operation. (i.e. -- check the "state" returned from
XQueryPointer() to see if the buttons are still down).

	In my own personal case I have taken out usage of MouseMotion
events.  If I wish to track what the user is going I go into a (ugghh)
polling loop while the mouse button is down of doing XQueryPointers().
The numbers are always current and there is no latency problem after
the button is released.

	I didn't originally do this, but scrollbars and popups work a
lot better with this type of logic. And the user has Full control!

> 
> 	-- John

-Jim Becker

nobody@tekecs.TEK.COM (-for inetd server command) (12/20/88)

In article <214@tityus.UUCP> you write:
>...
>	In my own personal case I have taken out usage of MouseMotion
>events.  If I wish to track what the user is going I go into a (ugghh)
>polling loop while the mouse button is down of doing XQueryPointers().
>The numbers are always current and there is no latency problem after
>the button is released.
>
>	I didn't originally do this, but scrollbars and popups work a
>lot better with this type of logic. And the user has Full control!
>
>-Jim Becker


An alternative approach is the following:

	case MotionNotify:

	    /* Find the latest motion event on the queue. Discard
	       all the others */
	    
	    while (XCheckMaskEvent(dpy, PointerMotionMask, &e_temp)) {
		e = e_temp;
	    }

I perform 'e = e_temp' because I am paranoid of what XCheckMaskEvent
does to the returned event when the result is "False".

This procedure works for me, but it may not be totally correct since
it will skip over events on the queue that don't match the pattern.  So the
pattern

	motion ... button press ... motion .. last motion event

will be processed as

	last motion event ... button press

which is not exactly correct.  What I'd like to do would be to have a
function which like XCheckMaskEvent which returns False if the queue
is empty OR if the next event on the queue fails to match the mask.

Are there better ways to do this?

					-- antoniof@af.GWD.TEK.COM


					-- antoniof@af  x2433

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (12/20/88)

    What I'd like to do would be to have a
    function which like XCheckMaskEvent which returns False if the queue
    is empty OR if the next event on the queue fails to match the mask.

With a little cleverness, you can do almost anything with XIfEvent.
You'll need to store and look at extra state somewhere in the "arg".
Not all that elegant (the predicate probably should have been designed
with a "giveup" return value), but it will work.

klee@daisy.UUCP (Ken Lee) (12/21/88)

In article <10759@tekecs.TEK.COM> antoniof@af.UUCP (Antonio Freixas) writes:
>An alternative approach is the following:
>
>	case MotionNotify:
>	    /* Find the latest motion event on the queue. Discard
>	       all the others */
>	    while (XCheckMaskEvent(dpy, PointerMotionMask, &e_temp)) {
>		e = e_temp;
>	    }

This should be about the same as using PointerMotionHints and
XQueryPointer.  In fact, PointerMotionHints may be more efficient, since
the server doesn't send as much stuff back to the client.

Ken Lee
Daisy Systems Corp., Interactive Graphics Tools Dept.
-- 
uucp:  uunet!daisy!klee		arpanet:  daisy!klee@uunet.uu.net

"DC6 which is being used for [Contra weapons supply] runs out of New Orleans
is probably being used for drug runs into U.S." - Oliver North, August, 1985