1
/* $Xorg: CrGlCur.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
4
Copyright 1986, 1998 The Open Group
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
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of The Open Group shall not be
23
used in advertising or otherwise to promote the sale, use or other dealings
24
in this Software without prior written authorization from The Open Group.
27
/* $XFree86: xc/lib/X11/CrGlCur.c,v 1.6 2002/09/05 18:17:31 keithp Exp $ */
31
#ifdef USE_DYNAMIC_XCURSOR
42
typedef shl_dt XModuleType;
44
typedef void *XModuleType;
48
#define LIBXCURSOR "libXcursor.so"
51
static char libraryName[] = LIBXCURSOR;
56
char *library = libraryName;
62
module = shl_load(library, BIND_DEFERRED, 0L);
64
module = dlopen(library, RTLD_LAZY);
68
dot = strrchr (library, '.');
77
fetch_symbol (XModuleType module, char *under_symbol)
80
char *symbol = under_symbol + 1;
83
struct shl_symbol *symbols;
85
getsyms_cnt = shl_getsymbols(module, TYPE_PROCEDURE,
86
EXPORT_SYMBOLS, malloc, &symbols);
88
for(i=0; i<getsyms_cnt; i++) {
89
if(!strcmp(symbols[i].name, symbol)) {
90
result = symbols[i].value;
99
result = dlsym (module, symbol);
101
result = dlsym (module, under_symbol);
106
typedef void (*NoticeCreateBitmapFunc) (Display *dpy,
109
unsigned int height);
111
typedef void (*NoticePutBitmapFunc) (Display *dpy,
115
typedef Cursor (*TryShapeBitmapCursorFunc) (Display *dpy,
123
typedef Cursor (*TryShapeCursorFunc) (Display *dpy,
126
unsigned int source_char,
127
unsigned int mask_char,
128
XColor _Xconst *foreground,
129
XColor _Xconst *background);
131
static XModuleType _XcursorModule;
132
static Bool _XcursorModuleTried;
134
#define GetFunc(type,name,ret) {\
135
static Bool been_here; \
136
static type staticFunc; \
138
_XLockMutex (_Xglobal_lock); \
142
if (!_XcursorModuleTried) \
144
_XcursorModuleTried = True; \
145
_XcursorModule = open_library (); \
147
if (_XcursorModule) \
148
staticFunc = (type) fetch_symbol (_XcursorModule, "_" name); \
151
_XUnlockMutex (_Xglobal_lock); \
155
_XTryShapeCursor (Display *dpy,
158
unsigned int source_char,
159
unsigned int mask_char,
160
XColor _Xconst *foreground,
161
XColor _Xconst *background)
163
TryShapeCursorFunc func;
165
GetFunc (TryShapeCursorFunc, "XcursorTryShapeCursor", func);
167
return (*func) (dpy, source_font, mask_font, source_char, mask_char,
168
foreground, background);
173
_XNoticeCreateBitmap (Display *dpy,
178
NoticeCreateBitmapFunc func;
180
GetFunc (NoticeCreateBitmapFunc, "XcursorNoticeCreateBitmap", func);
182
(*func) (dpy, pid, width, height);
186
_XNoticePutBitmap (Display *dpy,
190
NoticePutBitmapFunc func;
192
GetFunc (NoticePutBitmapFunc, "XcursorNoticePutBitmap", func);
194
(*func) (dpy, draw, image);
198
_XTryShapeBitmapCursor (Display *dpy,
206
TryShapeBitmapCursorFunc func;
208
GetFunc (TryShapeBitmapCursorFunc, "XcursorTryShapeBitmapCursor", func);
210
return (*func) (dpy, source, mask, foreground, background, x, y);
215
Cursor XCreateGlyphCursor(dpy, source_font, mask_font,
216
source_char, mask_char,
217
foreground, background)
218
register Display *dpy;
219
Font source_font, mask_font;
220
unsigned int source_char, mask_char;
221
XColor _Xconst *foreground, *background;
225
register xCreateGlyphCursorReq *req;
227
#ifdef USE_DYNAMIC_XCURSOR
228
cid = _XTryShapeCursor (dpy, source_font, mask_font,
229
source_char, mask_char, foreground, background);
234
GetReq(CreateGlyphCursor, req);
235
cid = req->cid = XAllocID(dpy);
236
req->source = source_font;
237
req->mask = mask_font;
238
req->sourceChar = source_char;
239
req->maskChar = mask_char;
240
req->foreRed = foreground->red;
241
req->foreGreen = foreground->green;
242
req->foreBlue = foreground->blue;
243
req->backRed = background->red;
244
req->backGreen = background->green;
245
req->backBlue = background->blue;