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