xcursorint.h revision e6d5e4e0
17914d74bSmrg/*
27914d74bSmrg * Copyright © 2002 Keith Packard
37914d74bSmrg *
47914d74bSmrg * Permission to use, copy, modify, distribute, and sell this software and its
57914d74bSmrg * documentation for any purpose is hereby granted without fee, provided that
67914d74bSmrg * the above copyright notice appear in all copies and that both that
77914d74bSmrg * copyright notice and this permission notice appear in supporting
87914d74bSmrg * documentation, and that the name of Keith Packard not be used in
97914d74bSmrg * advertising or publicity pertaining to distribution of the software without
107914d74bSmrg * specific, written prior permission.  Keith Packard makes no
117914d74bSmrg * representations about the suitability of this software for any purpose.  It
127914d74bSmrg * is provided "as is" without express or implied warranty.
137914d74bSmrg *
147914d74bSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
157914d74bSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
167914d74bSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
177914d74bSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
187914d74bSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
197914d74bSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
207914d74bSmrg * PERFORMANCE OF THIS SOFTWARE.
217914d74bSmrg */
227914d74bSmrg
237914d74bSmrg#ifndef _XCURSORINT_H_
247914d74bSmrg#define _XCURSORINT_H_
257914d74bSmrg
267914d74bSmrg#ifdef HAVE_CONFIG_H
277914d74bSmrg#include "config.h"
287914d74bSmrg#endif
29e6d5e4e0Smrg
307914d74bSmrg#include <X11/Xlib.h>
317914d74bSmrg#include <X11/cursorfont.h>
327914d74bSmrg#include <X11/extensions/Xrender.h>
337914d74bSmrg
347914d74bSmrg#ifdef HAVE_XFIXES
357914d74bSmrg#include <X11/extensions/Xfixes.h>
367914d74bSmrg#endif
377914d74bSmrg
387914d74bSmrg#include "Xcursor.h"
397914d74bSmrg#include "config.h"
407914d74bSmrg
417914d74bSmrgtypedef struct _XcursorFontInfo {
427914d74bSmrg    struct _XcursorFontInfo	*next;
437914d74bSmrg    Font			font;
447914d74bSmrg    XcursorBool			is_cursor_font;
457914d74bSmrg} XcursorFontInfo;
467914d74bSmrg
477914d74bSmrg/*
487914d74bSmrg * Track a few recently created bitmaps to see
497914d74bSmrg * if they get used to create cursors.  This
507914d74bSmrg * is done by hooking into Xlib and watching
517914d74bSmrg * for XCreatePixmap, XPutImage, XCreatePixmapCursor
527914d74bSmrg * with appropriate arguments.  When this happens
537914d74bSmrg * Xcursor computes a hash value for the source image
547914d74bSmrg * and tries to load a library cursor of that name.
557914d74bSmrg */
56e6d5e4e0Smrg
577914d74bSmrg/* large bitmaps are unlikely to be cursors */
587914d74bSmrg#define MAX_BITMAP_CURSOR_SIZE	64
597914d74bSmrg/* don't need to remember very many; in fact, 2 is likely sufficient */
607914d74bSmrg#define NUM_BITMAPS	    8
617914d74bSmrg
627914d74bSmrgtypedef struct _XcursorBitmapInfo {
637914d74bSmrg    Pixmap	    bitmap;
647914d74bSmrg    unsigned long   sequence;
657914d74bSmrg    unsigned int    width, height;
667914d74bSmrg    Bool	    has_image;
677914d74bSmrg    unsigned char   hash[XCURSOR_BITMAP_HASH_SIZE];
687914d74bSmrg} XcursorBitmapInfo;
697914d74bSmrg
707914d74bSmrgtypedef enum _XcursorDither {
717914d74bSmrg    XcursorDitherThreshold,
727914d74bSmrg    XcursorDitherMedian,
737914d74bSmrg    XcursorDitherOrdered,
747914d74bSmrg    XcursorDitherDiffuse
757914d74bSmrg} XcursorDither;
767914d74bSmrg
777914d74bSmrgtypedef struct _XcursorDisplayInfo {
787914d74bSmrg    struct _XcursorDisplayInfo	*next;
797914d74bSmrg    Display			*display;
807914d74bSmrg    XExtCodes			*codes;
817914d74bSmrg    XcursorBool			has_render_cursor;
827914d74bSmrg    XcursorBool			has_anim_cursor;
837914d74bSmrg    XcursorBool			theme_core;
847914d74bSmrg    int				size;
857914d74bSmrg    XcursorFontInfo		*fonts;
867914d74bSmrg    char			*theme;
877914d74bSmrg    char                        *theme_from_config;
887914d74bSmrg    XcursorDither		dither;
897914d74bSmrg    XcursorBitmapInfo		bitmaps[NUM_BITMAPS];
907914d74bSmrg} XcursorDisplayInfo;
917914d74bSmrg
927914d74bSmrgXcursorDisplayInfo *
937914d74bSmrg_XcursorGetDisplayInfo (Display *dpy);
947914d74bSmrg
957914d74bSmrgCursor
967914d74bSmrg_XcursorCreateGlyphCursor(Display	    *dpy,
977914d74bSmrg			  Font		    source_font,
987914d74bSmrg			  Font		    mask_font,
997914d74bSmrg			  unsigned int	    source_char,
1007914d74bSmrg			  unsigned int	    mask_char,
1017914d74bSmrg			  XColor _Xconst    *foreground,
1027914d74bSmrg			  XColor _Xconst    *background);
1037914d74bSmrg
1047914d74bSmrgCursor
1057914d74bSmrg_XcursorCreateFontCursor (Display *dpy, unsigned int shape);
106e6d5e4e0Smrg
1077914d74bSmrg#endif /* _XCURSORINT_H_ */
108