[comp.windows.x] Creating cursor problem

scott@mccall.com (08/28/90)

I've got a problem with creating a cursor.

I'm wanting to create a 4x4 pixel cursor(please no flames
for choice of cursor,as it is relevant to the application
I'm working on) with a hotspot at 2,2.  And cursor_bits defined
as:: static char cursor_bits[] = {0x0f,0x0f,0x0f,0x0f};

I setup a routine that has these calls:

XCreatePixmapFromBitmapData
XLookupColor
XCreatePixmapCursor
XDefineCursor

The pixmap displayed seems to be 4 high and 16(?) long, with
the first 4 pixels set and random pixels set after that.  It
does seem to change from compliation to compliation.

I'm running this on VMS ver5.3 on a DECstation 2000.
Any comments and help is greatly appreciated.  Thanks.
-- 
Scott Davis <scott@mccall.com>            The McCall Pattern Company
(uucp: ...!rutgers!ksuvax1!mccall!scott)  615 McCall Road
(800)255-2762, in Kansas (913)776-4041    Manhattan, KS 66502, USA

mouse@LARRY.MCRCIM.MCGILL.EDU (09/04/90)

> I'm wanting to create a 4x4 pixel cursor [...] with a hotspot at 2,2.
> And cursor_bits defined as:: static char cursor_bits[] = {[...]};

> I setup a routine that has these calls:

> XCreatePixmapFromBitmapData
> XLookupColor
> XCreatePixmapCursor
> XDefineCursor

> The pixmap displayed seems to be 4 high and 16(?) long, with the
> first 4 pixels set and random pixels set after that.  It does seem to
> change from compliation to compliation.

Without seeing the arguments you pass to those calls (in particular, to
XCreatePixmapFromBitmapData and XCreatePixmapCursor), it's hard to do
more than guess.

However...

I would guess you are passing None as the mask pixmap to
XCreatePixmapCursor, and the cursor image pixmap is actually stored
with a width of 16, and the other 12 columns are junk left over from
whatever was previously using that memory.  I suspect this is
technically legal; the Xlib document says "The components of the cursor
can be transformed arbitrarily to meet display limitations.", which
sounds like a license to do anything it pleases, but I would still call
this a bug.  (Seems to me it should restrict the cursor to the size of
the supplied pixmap!)

The likliest-to-work fix that comes to mind is to use an explicit mask
pixmap.  Since you say you want a 4x4 cursor, create a 4x4 pixmap of
depth 1 and fill it with 1s (either with XCreatePixmapFromBitmapData or
with explicit calls), then pass that to XCreatePixmapCursor.

					der Mouse

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