[comp.windows.x] Trackball interface from the mouse/pointer?

garyo@THINK.COM (Gary Oberbrunner) (06/13/89)

Is there anyone out there who can help me get delta (trackball-style)
coordinates out of the mouse rather than absolute coords?

I'm trying to use the pointer to control rotation and other circular
parameters.  I blank the mouse pointer, then grab the mouse.  the x events
I get return an absolute position which I subtract from the previous
position to get relative coords.  But I'd like the mouse to be just like a
trackball; no window borders.  So I warp the mouse to the center when it
gets to the edge (the pointer is invisible, so it's not noticeable).
Unfortunately, this generates a mouse event that's apparently
indistinguishable from a real mouse motion event!  So I've come up with a
zillion kludgy methods to identify the warp event, but none of them is 100%
reliable or pretty.

Method 1:  Assume that the warp event will be on the queue with the same
coords that I warped it to, and throw it out (only if I recently warped the
pointer, of course).
This seems to work for small windows, but fails miserably when I grab the
mouse in the root window (which seems the most natural thing to do).  The
warp event is often absorbed into a preceding or following event, throwing
off the coordinates.

Method 1a: assume it's close to the center after being warped.
This is no better than the above, because with mouse acceleration (or when
the load average is high), the user can move the mouse arbitrarily far in
one event.

Method 2: Throw out big moves.
This is worse than the above, because not only do you lose true mouse
events, sometimes the warp event is collapsed into a mouse event and the
total is not "big".  Then you get jitters, which are totally unacceptable.

Method 3: XSync(display, flush = True) just after warping, then use the
next mouse event just to set last_x and last_y.
This is the method I'm using now; its disadvantage is that if the mouse
queue is long when the mouse reaches the edge, lots of motion can be
ignored.  This isn't great from a UI standpoint.

All the other things I tried were worse than these.

I'd be greatly indebted if anyone can tell me:

1) How I can distinguish a mouse event from a warp event. (ideal)
2) How I can keep warp events from being combined with mouse events.
3) How I can cause the warp not to generate an event.
4) How I can get "raw" delta mouse data.
4) Any other technique I can use to get the desired delta-motion events.

Reply to me, please; this group sometimes gets too big and I have to flush
it.

					Thanks;

					Gary O

-----------------------------------------------------------------------------
Remember,		      Truth is not beauty;	    Gary  Oberbrunner
Information is not knowledge; Beauty is not love;  {ames,harvard}!think!garyo
Knowledge is not wisdom;      Love is not music;	      garyo@think.com
Wisdom is not truth;	      Music is the best. - FZ	  (617) 876-1111 x265

rws@EXPO.LCS.MIT.EDU (06/14/89)

    1) How I can distinguish a mouse event from a warp event.

There is no direct way to do what you want, but here's something you can
try.  Motion events have a sequence number in them.  You can match this
with the sequence number of your WarpPointer request, and use it as an
indicator of which events to throw away.

karlton@fudge.sgi.com (Phil Karlton) (06/14/89)

In article <8906131957.AA00946@expire.lcs.mit.edu> rws@EXPO.LCS.MIT.EDU writes:

>    1) How I can distinguish a mouse event from a warp event.

>There is no direct way to do what you want, but here's something you can
>try.  Motion events have a sequence number in them.  You can match this
>with the sequence number of your WarpPointer request, and use it as an
>indicator of which events to throw away.

In addition, if you follow the WarpPointer immediately with a
NoOperation request, the serial number in the incoming motion events
will only match that of the WarpPointer request for a short amount of
time.

PK