[comp.windows.x] Hiding the cursor

db3l@ibm.com (David Bolen) (03/02/91)

I thought it should be pretty simple, but I can't figure out how to hide
the cursor for a window.  My application happens to be letting the user
adjust a sizing box, and I don't want the cursor visible, since it is the
visible box that is important to the user and not the location of the
pointer.  Defining a cursor of None just takes the parent cursor, which
doesn't help me.  I thought of defining my own Pixmap cursor with colors
that wouldn't show up, but given that the pointer will move over various
background colors in the window I didn't see how that could work.

Is there any way to tell X NOT to display a cursor at the pointer location
for a particular window?

Oh, and I should mention that I'm actually trying to do this within a
Motif application - for the DrawingArea widget of one of my windows, but
I think the question has more to do with X than Motif.

Thanks for any help.

--
-- David
--
/-----------------------------------------------------------------------\
 \                             David Bolen                             /
  |    Laboratory Automation, IBM Thomas J. Watson Research Center    |
 /              P.O. Box 218, Yorktown Heights, NY  10598              \
| - - - - - - - - - - - -  M i t h r a n d i r  - - - - - - - - - - - - |
| Internet : db3l@ibm.com                    | Bitnet : db3l@yktvmv     |
| Usenet   : uunet!bywater!arnor!larios!db3l | Phone  : (914) 945-1940  |
|   /---------------------------------------------------------------\   |
 \-( All comments/opinions are mine and don't represent those of IBM )-/
    \---------------------------------------------------------------/

mouse@lightning.mcrcim.mcgill.EDU (03/03/91)

> I thought it should be pretty simple, but I can't figure out how to
> hide the cursor for a window.  My application happens to be letting
> the user adjust a sizing box, and I don't want the cursor visible,
> since it is the visible box that is important to the user and not the
> location of the pointer.  [...]  I thought of defining my own Pixmap
> cursor with colors that wouldn't show up, but given that the pointer
> will move over various background colors in the window I didn't see
> how that could work.

What you do is use the mask pixmap to define a cursor with no pixels
visible.  You could, for example, create a 1x1 bitmap, set its only
pixel to 0, and use it as both the source and mask arguments to
XCreatePixmapCursor.  (Since neither the foreground nor the background
color will ever be displayed, the color arguments don't matter much.
If your server is stupid, you may have to pick colors that already
exist somewhere on the screen to avoid color trouble, though I don't
know of any servers that are that dumb.)

> Is there any way to tell X NOT to display a cursor at the pointer
> location for a particular window?

No, though as I said you can have it display a cursor image containing
no pixels, which amounts to the same thing visually.

And yes, I have tried this.  I have at least two different programs
using the technique, and it works fine for me.  (I am using the MIT
server, though it should work OK on any server.)

					der Mouse

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