
Example 13-2. The hot_spot.c program (continued)
/*
* create_cursor() creates a bull’s eye cursor and assigns it
* to the window (parameter).
*/
create_cursor(window)
Xv_Window window;
{
Xv_Cursor cursor;
Server_image image;
Pixmap pixmap;
Display *dpy = (Display *)xv_get(window, XV_DISPLAY);
GC gc;
XGCValues gcvalues;
image = (Server_image)xv_create(XV_NULL, SERVER_IMAGE,
XV_WIDTH, 16,
XV_HEIGHT, 16,
NULL);
pixmap = (Pixmap)xv_get(image, XV_XID);
/* Create GC with reversed foreground and background colors to
* clear pixmap first. Use 1 and 0 because pixmap is 1-bit deep.
*/
gcvalues.foreground = 0;
gcvalues.background = 1;
gc = XCreateGC(dpy, pixmap, GCForeground|GCBackground, &gcvalues);
XFillRectangle(dpy, pixmap, gc, 0, 0, 16, 16);
/*
* Reset foreground and background values for XDrawArc() routines.
*/
gcvalues.foreground = 1;
gcvalues.background = 0;
XChangeGC(dpy, gc, GCForeground | GCBackground, &gcvalues);
XDrawArc(dpy, pixmap, gc, 2, 2, 12, 12, 0, 360 * 64);
XDrawArc(dpy, pixmap, gc, 6, 6, 4, 4, 0, 360 * 64);
/* Create cursor and assign it to the window (parameter) */
cursor = xv_create(XV_NULL, CURSOR,
CURSOR_IMAGE, image,
CURSOR_XHOT, 7,
CURSOR_YHOT, 7,
NULL);
xv_set(window, WIN_CURSOR, cursor, NULL);
/* free the GC -- the cursor and the image must not be freed. */
XFreeGC(dpy, gc);
}
When the program is running, each time the panel button is pushed, it prints the cursor’s
position relative to the panel’s window ...