[comp.windows.x] Cursor control

llovero@bbn.com (Linda Lovero) (04/13/89)

I am currently investigating X in the hopes that I can use it for my next
application. I have been pleased so far, with the exception that I haven't 
been able to find any calls that allow the application to control the location
of the cursor. My application needs to have complete control over the cursor
tracking since I need to use an input device which is not the mouse.  If it 
makes a difference, the input device will be plugged into a serial line, and
my application will determine the distance and speed of cursor movement.
It would also be nice to temporarily decouple mouse movement from cursor
movement.

If this is not possible, I need to know before I go any further with this. I
have found calls to define what the cursor looks like, and calls to assign
the cursor to a window, but haven't found any calls that put the cursor at
a particular location.

In case you're wondering, my application will be run under an environment
where it is the only application running at the time.  No one will be
using another X application on the machine.

Any information would be greatly appreciated!

- Linda Lovero

jik@ATHENA.MIT.EDU (Jonathan I. Kamens) (04/13/89)

Linda Lovero asks:

1. How to control the position of the mouse cursor.
2. How to decouple mouse movement from cursor movement.

  The XWarpPointer function can be used to change the position of the
mouse cursor.  Its declaration is as follows:

     XWarpPointer(display, src_w, dest_w, src_x, src_y, 
		  src_width, src_height, 
		  dest_x, dest_y)
             Display *display;
             Window src_w, dest_w;
             int src_x, src_y;
             unsigned int src_width, src_height;
             int dest_x, dest_y;

Look it up for further information.

  As for decoupling mouse movement from cursor movement, I do not
think there is any support for that.  The best you can do is to warp
the cursor back to where you want it every time you get a motion event
(I could be wrong, of course :-).

  Finally, you might want to consider writing a device driver for
whatever device you are using to control the pointer location.  If
you've got someone who can do it, it would probably be the best
solution -- make the serial device the mouse rather than the mouse....

Jonathan Kamens			              USnail:
MIT Project Athena				410 Memorial Drive, No. 223F
jik@Athena.MIT.EDU				Cambridge, MA 02139-4318
Office: 617-253-4261			      Home: 617-225-8218

klee@daisy.UUCP (Ken Lee) (04/13/89)

In article <38587@bbn.COM> llovero@bbn.com (Linda Lovero) writes:
>I haven't 
>been able to find any calls that allow the application to control the location
>of the cursor. My application needs to have complete control over the cursor
>tracking since I need to use an input device which is not the mouse.

Only mouse and keyboard input are well supported by standard X.  X can
be extended, however, to support other input devices, such as trackballs,
bitpads, etc.  Input extensions are still being standardized by the X
Consortium, but there is some documentation in the X extensions manual
under "input extensions".
-- 
Ken Lee
Daisy Systems Corp., Interactive Graphics Tools Dept.
Internet and Smail:  klee@daisy.uucp
              uucp:  uunet!daisy!klee

warlock@csuchico.edu (John Kennedy) (06/30/90)

  I have a problem that perhaps someone can answer.  I wish to make the cursor
temporarily disappear.  My current efforts have been foiled because X seems to
keep around an image of what's under the cursor.  Here is the situation:

  I'm using a Sun SPARCstation 1+  (8-bit color)
  X11R4

  I'm calling a function that apparently uses low-level pixrect calls to
move images around inside a box.  By clicking on a spot, the function centers
the image on that spot (so I'm basically panning around, seeing a piece of a
larger image).  That is all working fine, but the problem is this:  When I
click on a spot, the function copies a piece of the image on top of where my
cursor was.  When I move the mouse, what used to be under the cursor is
restored, leaving a cookie on the screen.  Defining the mouse shape as nothing
doesn't appear to help anything at all.

  Xterm appears to get around this problem nicely.  Does anybody know how it
does it?  Thanks for any help you might give.

--

Warlock, AKA              +----------------------------------------------------
John Kennedy              | internet: warlock@csuchico.edu
CSU Chico		  +----------------------------------------------------

mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (07/01/90)

> I have a problem that perhaps someone can answer.  I wish to make the
> cursor temporarily disappear.  My current efforts have been foiled
> because X seems to keep around an image of what's under the cursor.
> Here is the situation:

>  I'm using a Sun SPARCstation 1+  (8-bit color)
>  X11R4

> I'm calling a function that apparently uses low-level pixrect calls
> to move images around inside a box.

Ouch.  You're going to have trouble, then; X assumes it owns the frame
buffer and won't get along with programs that scribble on it behind X's
back.

> [T]he problem is this:  When I click on a spot, the function copies a
> piece of the image on top of where my cursor was.  When I move the
> mouse, what used to be under the cursor is restored, leaving a cookie
> on the screen.

Yup.  If the program did the copy via X instead of the pixrect library,
there'd be no problem.  (The program is clearly getting its mouse
clicks via X; do you have any idea why it's being so silly as to blit
pieces of the raw framebuffer around?)

> Xterm appears to get around this problem nicely.  Does anybody know
> how it does it?

When xterm wants to copy a piece of the screen around, it uses
XCopyArea instead of pr_rop.  This is portable, works across the
network, *and* interacts properly with the pointer image, because the X
server is what actually performs the copy, meaning it can erase the
pointer image for the duration of the copy if necessary.

If you have source, I'd recommend that you fix it to do the copies
properly, with XCopyArea, instead of by pr_rop()ing pieces of the
framebuffer around behind the X server's back.  If you don't have
source, there's not much you can do except complain to whoever gave you
a program with such a twisted misfeature in it.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu