xcursorint.h revision 7914d74b
1/*
2 * $Id: xcursorint.h,v 1.1.1.1 2008/07/30 02:45:52 mrg Exp $
3 *
4 * Copyright © 2002 Keith Packard
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission.  Keith Packard makes no
13 * representations about the suitability of this software for any purpose.  It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25#ifndef _XCURSORINT_H_
26#define _XCURSORINT_H_
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#include <X11/Xlib.h>
33#include <X11/cursorfont.h>
34#include <X11/extensions/Xrender.h>
35
36#ifdef HAVE_XFIXES
37#include <X11/extensions/Xfixes.h>
38#endif
39
40#include "Xcursor.h"
41#include "config.h"
42
43typedef struct _XcursorFontInfo {
44    struct _XcursorFontInfo	*next;
45    Font			font;
46    XcursorBool			is_cursor_font;
47} XcursorFontInfo;
48
49/*
50 * Track a few recently created bitmaps to see
51 * if they get used to create cursors.  This
52 * is done by hooking into Xlib and watching
53 * for XCreatePixmap, XPutImage, XCreatePixmapCursor
54 * with appropriate arguments.  When this happens
55 * Xcursor computes a hash value for the source image
56 * and tries to load a library cursor of that name.
57 */
58
59/* large bitmaps are unlikely to be cursors */
60#define MAX_BITMAP_CURSOR_SIZE	64
61/* don't need to remember very many; in fact, 2 is likely sufficient */
62#define NUM_BITMAPS	    8
63
64typedef struct _XcursorBitmapInfo {
65    Pixmap	    bitmap;
66    unsigned long   sequence;
67    unsigned int    width, height;
68    Bool	    has_image;
69    unsigned char   hash[XCURSOR_BITMAP_HASH_SIZE];
70} XcursorBitmapInfo;
71
72typedef enum _XcursorDither {
73    XcursorDitherThreshold,
74    XcursorDitherMedian,
75    XcursorDitherOrdered,
76    XcursorDitherDiffuse
77} XcursorDither;
78
79typedef struct _XcursorDisplayInfo {
80    struct _XcursorDisplayInfo	*next;
81    Display			*display;
82    XExtCodes			*codes;
83    XcursorBool			has_render_cursor;
84    XcursorBool			has_anim_cursor;
85    XcursorBool			theme_core;
86    int				size;
87    XcursorFontInfo		*fonts;
88    char			*theme;
89    char                        *theme_from_config;
90    XcursorDither		dither;
91    XcursorBitmapInfo		bitmaps[NUM_BITMAPS];
92} XcursorDisplayInfo;
93
94XcursorDisplayInfo *
95_XcursorGetDisplayInfo (Display *dpy);
96
97Cursor
98_XcursorCreateGlyphCursor(Display	    *dpy,
99			  Font		    source_font,
100			  Font		    mask_font,
101			  unsigned int	    source_char,
102			  unsigned int	    mask_char,
103			  XColor _Xconst    *foreground,
104			  XColor _Xconst    *background);
105
106Cursor
107_XcursorCreateFontCursor (Display *dpy, unsigned int shape);
108
109#endif /* _XCURSORINT_H_ */
110