xcursorint.h revision e6d5e4e0
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#include "config.h"
40
41typedef struct _XcursorFontInfo {
42    struct _XcursorFontInfo	*next;
43    Font			font;
44    XcursorBool			is_cursor_font;
45} XcursorFontInfo;
46
47/*
48 * Track a few recently created bitmaps to see
49 * if they get used to create cursors.  This
50 * is done by hooking into Xlib and watching
51 * for XCreatePixmap, XPutImage, XCreatePixmapCursor
52 * with appropriate arguments.  When this happens
53 * Xcursor computes a hash value for the source image
54 * and tries to load a library cursor of that name.
55 */
56
57/* large bitmaps are unlikely to be cursors */
58#define MAX_BITMAP_CURSOR_SIZE	64
59/* don't need to remember very many; in fact, 2 is likely sufficient */
60#define NUM_BITMAPS	    8
61
62typedef struct _XcursorBitmapInfo {
63    Pixmap	    bitmap;
64    unsigned long   sequence;
65    unsigned int    width, height;
66    Bool	    has_image;
67    unsigned char   hash[XCURSOR_BITMAP_HASH_SIZE];
68} XcursorBitmapInfo;
69
70typedef enum _XcursorDither {
71    XcursorDitherThreshold,
72    XcursorDitherMedian,
73    XcursorDitherOrdered,
74    XcursorDitherDiffuse
75} XcursorDither;
76
77typedef struct _XcursorDisplayInfo {
78    struct _XcursorDisplayInfo	*next;
79    Display			*display;
80    XExtCodes			*codes;
81    XcursorBool			has_render_cursor;
82    XcursorBool			has_anim_cursor;
83    XcursorBool			theme_core;
84    int				size;
85    XcursorFontInfo		*fonts;
86    char			*theme;
87    char                        *theme_from_config;
88    XcursorDither		dither;
89    XcursorBitmapInfo		bitmaps[NUM_BITMAPS];
90} XcursorDisplayInfo;
91
92XcursorDisplayInfo *
93_XcursorGetDisplayInfo (Display *dpy);
94
95Cursor
96_XcursorCreateGlyphCursor(Display	    *dpy,
97			  Font		    source_font,
98			  Font		    mask_font,
99			  unsigned int	    source_char,
100			  unsigned int	    mask_char,
101			  XColor _Xconst    *foreground,
102			  XColor _Xconst    *background);
103
104Cursor
105_XcursorCreateFontCursor (Display *dpy, unsigned int shape);
106
107#endif /* _XCURSORINT_H_ */
108