2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
|
|
|
|
|
|
|
Generic_Predicate (Cursor)
|
|
|
|
|
|
|
|
Generic_Equal_Dpy (Cursor, CURSOR, cursor)
|
|
|
|
|
|
|
|
Generic_Print (Cursor, "#[cursor %lu]", CURSOR(x)->cursor)
|
|
|
|
|
|
|
|
Generic_Get_Display (Cursor, CURSOR)
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value Internal_Make_Cursor (finalize, dpy, cursor)
|
2001-05-08 10:21:00 -04:00
|
|
|
Display *dpy; Cursor cursor; {
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value c;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
if (cursor == None)
|
|
|
|
return Sym_None;
|
|
|
|
c = Find_Object (T_Cursor, (GENERIC)dpy, Match_X_Obj, cursor);
|
2001-05-14 09:48:37 -04:00
|
|
|
if (S48_NULL_P (c)) {
|
2001-05-08 10:21:00 -04:00
|
|
|
c = Alloc_Object (sizeof (struct S_Cursor), T_Cursor, 0);
|
2001-05-14 09:48:37 -04:00
|
|
|
CURSOR(c)->tag = S48_NULL;
|
2001-05-08 10:21:00 -04:00
|
|
|
CURSOR(c)->cursor = cursor;
|
|
|
|
CURSOR(c)->dpy = dpy;
|
|
|
|
CURSOR(c)->free = 0;
|
|
|
|
Register_Object (c, (GENERIC)dpy,
|
|
|
|
finalize ? P_Free_Cursor : (PFO)0, 0);
|
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Backwards compatibility: */
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value Make_Cursor (dpy, cursor) Display *dpy; Cursor cursor; {
|
2001-05-08 10:21:00 -04:00
|
|
|
return Internal_Make_Cursor (1, dpy, cursor);
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value Make_Cursor_Foreign (dpy, cursor) Display *dpy; Cursor cursor; {
|
2001-05-08 10:21:00 -04:00
|
|
|
return Internal_Make_Cursor (0, dpy, cursor);
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
Cursor Get_Cursor (c) s48_value c; {
|
|
|
|
if (S48_EQ_P(c, Sym_None))
|
2001-05-08 10:21:00 -04:00
|
|
|
return None;
|
|
|
|
Check_Type (c, T_Cursor);
|
|
|
|
return CURSOR(c)->cursor;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value P_Free_Cursor (c) s48_value c; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (c, T_Cursor);
|
|
|
|
if (!CURSOR(c)->free)
|
|
|
|
XFreeCursor (CURSOR(c)->dpy, CURSOR(c)->cursor);
|
|
|
|
Deregister_Object (c);
|
|
|
|
CURSOR(c)->free = 1;
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Create_Cursor (srcp, maskp, x, y, f, b)
|
|
|
|
s48_value srcp, maskp, x, y, f, b; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Pixmap sp = Get_Pixmap (srcp), mp;
|
|
|
|
Display *d = PIXMAP(srcp)->dpy;
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
mp = S48_EQ_P(maskp, Sym_None) ? None : Get_Pixmap (maskp);
|
2001-05-08 10:21:00 -04:00
|
|
|
return Make_Cursor (d, XCreatePixmapCursor (d, sp, mp,
|
2001-05-14 09:48:37 -04:00
|
|
|
Get_Color (f), Get_Color (b), (int)s48_extract_integer (x), (int)s48_extract_integer (y)));
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Create_Glyph_Cursor (srcf, srcc, maskf, maskc, f, b)
|
|
|
|
s48_value srcf, srcc, maskf, maskc, f, b; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Font sf = Get_Font (srcf), mf;
|
|
|
|
Display *d = FONT(srcf)->dpy;
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
mf = S48_EQ_P(maskf, Sym_None) ? None : Get_Font (maskf);
|
2001-05-08 10:21:00 -04:00
|
|
|
return Make_Cursor (d, XCreateGlyphCursor (d, sf, mf,
|
2001-05-14 09:48:37 -04:00
|
|
|
(int)s48_extract_integer (srcc), mf == None ? 0 : (int)s48_extract_integer (maskc),
|
2001-05-08 10:21:00 -04:00
|
|
|
Get_Color (f), Get_Color (b)));
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Recolor_Cursor (c, f, b) s48_value c, f, b; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (c, T_Cursor);
|
|
|
|
XRecolorCursor (CURSOR(c)->dpy, CURSOR(c)->cursor, Get_Color (f),
|
|
|
|
Get_Color (b));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
|
|
|
elk_init_xlib_cursor () {
|
|
|
|
Generic_Define (Cursor, "cursor", "cursor?");
|
|
|
|
Define_Primitive (P_Cursor_Display, "cursor-display", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_Free_Cursor, "free-cursor", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_Create_Cursor, "create-cursor", 6, 6, EVAL);
|
|
|
|
Define_Primitive (P_Create_Glyph_Cursor, "create-glyph-cursor",
|
|
|
|
6, 6, EVAL);
|
|
|
|
Define_Primitive (P_Recolor_Cursor, "recolor-cursor", 3, 3, EVAL);
|
|
|
|
}
|