2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value Sym_Pointer_Root;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Reparent_Window (w, parent, x, y) s48_value w, parent, x, y; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (w, T_Window);
|
|
|
|
Check_Type (parent, T_Window);
|
|
|
|
XReparentWindow (WINDOW(w)->dpy, WINDOW(w)->win, WINDOW(parent)->win,
|
2001-05-14 09:48:37 -04:00
|
|
|
(int)s48_extract_integer (x), (int)s48_extract_integer (y));
|
2001-05-08 10:21:00 -04:00
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Install_Colormap (c) s48_value c; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (c, T_Colormap);
|
|
|
|
XInstallColormap (COLORMAP(c)->dpy, COLORMAP(c)->cm);
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Uninstall_Colormap (c) s48_value c; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (c, T_Colormap);
|
|
|
|
XUninstallColormap (COLORMAP(c)->dpy, COLORMAP(c)->cm);
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_List_Installed_Colormaps (w) s48_value w; {
|
2001-05-08 10:21:00 -04:00
|
|
|
int i, n;
|
|
|
|
Colormap *ret;
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value v;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
Check_Type (w, T_Window);
|
|
|
|
ret = XListInstalledColormaps (WINDOW(w)->dpy, WINDOW(w)->win, &n);
|
2001-05-14 09:48:37 -04:00
|
|
|
v = s48_make_vector (n, S48_NULL);
|
|
|
|
S48_GC_PROTECT_1 (v);
|
2001-05-08 10:21:00 -04:00
|
|
|
for (i = 0; i < n; i++) {
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value c;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
c = Make_Colormap (0, WINDOW(w)->dpy, ret[i]);
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_VECTOR_SET(v, i, c;)
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
XFree ((char *)ret);
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_GC_UNPROTECT;
|
2001-05-08 10:21:00 -04:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Set_Input_Focus (d, win, revert_to, time) s48_value d, win,
|
2001-05-08 10:21:00 -04:00
|
|
|
revert_to, time; {
|
|
|
|
Window focus = PointerRoot;
|
|
|
|
|
|
|
|
Check_Type (d, T_Display);
|
2001-05-14 09:48:37 -04:00
|
|
|
if (!S48_EQ_P(win, Sym_Pointer_Root))
|
2001-05-08 10:21:00 -04:00
|
|
|
focus = Get_Window (win);
|
|
|
|
XSetInputFocus (DISPLAY(d)->dpy, focus, Symbols_To_Bits (revert_to, 0,
|
|
|
|
Revert_Syms), Get_Time (time));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Input_Focus (d) s48_value d; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Window win;
|
|
|
|
int revert_to;
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value ret, x;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
Check_Type (d, T_Display);
|
|
|
|
XGetInputFocus (DISPLAY(d)->dpy, &win, &revert_to);
|
2001-05-14 09:48:37 -04:00
|
|
|
ret = s48_cons (S48_NULL, S48_NULL);
|
|
|
|
S48_GC_PROTECT_1 (ret);
|
2001-05-08 10:21:00 -04:00
|
|
|
x = Make_Window (0, DISPLAY(d)->dpy, win);
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_CAR (ret) = x;
|
2001-05-08 10:21:00 -04:00
|
|
|
x = Bits_To_Symbols ((unsigned long)revert_to, 0, Revert_Syms);
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_CDR (ret) = x;
|
|
|
|
S48_GC_UNPROTECT;
|
2001-05-08 10:21:00 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_General_Warp_Pointer (dpy, dst, dstx, dsty, src, srcx, srcy,
|
|
|
|
srcw, srch) s48_value dpy, dst, dstx, dsty, src, srcx, srcy, srcw, srch; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (dpy, T_Display);
|
|
|
|
XWarpPointer (DISPLAY(dpy)->dpy, Get_Window (src), Get_Window (dst),
|
2001-05-14 09:48:37 -04:00
|
|
|
(int)s48_extract_integer (srcx), (int)s48_extract_integer (srcy), (int)s48_extract_integer (srcw),
|
|
|
|
(int)s48_extract_integer (srch), (int)s48_extract_integer (dstx), (int)s48_extract_integer (dsty));
|
2001-05-08 10:21:00 -04:00
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Bell (argc, argv) s48_value *argv; {
|
2001-05-08 10:21:00 -04:00
|
|
|
register percent = 0;
|
|
|
|
|
|
|
|
Check_Type (argv[0], T_Display);
|
|
|
|
if (argc == 2) {
|
2001-05-14 09:48:37 -04:00
|
|
|
percent = (int)s48_extract_integer (argv[1]);
|
2001-05-08 10:21:00 -04:00
|
|
|
if (percent < -100 || percent > 100)
|
|
|
|
Range_Error (argv[1]);
|
|
|
|
}
|
|
|
|
XBell (DISPLAY(argv[0])->dpy, percent);
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Set_Access_Control (dpy, on) s48_value dpy, on; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (dpy, T_Display);
|
|
|
|
Check_Type (on, T_Boolean);
|
2001-05-14 09:48:37 -04:00
|
|
|
XSetAccessControl (DISPLAY(dpy)->dpy, S48_EQ_P(on, S48_TRUE));
|
2001-05-08 10:21:00 -04:00
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Change_Save_Set (win, mode) s48_value win, mode; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (win, T_Window);
|
|
|
|
XChangeSaveSet (WINDOW(win)->dpy, WINDOW(win)->win,
|
|
|
|
Symbols_To_Bits (mode, 0, Saveset_Syms));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Set_Close_Down_Mode (dpy, mode) s48_value dpy, mode; {
|
2001-05-08 10:21:00 -04:00
|
|
|
Check_Type (dpy, T_Display);
|
|
|
|
XSetCloseDownMode (DISPLAY(dpy)->dpy,
|
|
|
|
Symbols_To_Bits (mode, 0, Closemode_Syms));
|
|
|
|
return Void;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Get_Pointer_Mapping (dpy) s48_value dpy; {
|
2001-05-08 10:21:00 -04:00
|
|
|
unsigned char map[256];
|
|
|
|
register i, n;
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value ret;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
Check_Type (dpy, T_Display);
|
|
|
|
n = XGetPointerMapping (DISPLAY(dpy)->dpy, map, 256);
|
2001-05-14 09:48:37 -04:00
|
|
|
ret = s48_make_vector (n, S48_NULL);
|
2001-05-08 10:21:00 -04:00
|
|
|
for (i = 0; i < n; i++)
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_VECTOR_SET(ret, i, s48_enter_integer (map[i]);)
|
2001-05-08 10:21:00 -04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
static s48_value P_Set_Pointer_Mapping (dpy, map) s48_value dpy, map; {
|
2001-05-08 10:21:00 -04:00
|
|
|
register i, n;
|
|
|
|
register unsigned char *p;
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value ret;
|
2001-05-08 10:21:00 -04:00
|
|
|
Alloca_Begin;
|
|
|
|
|
|
|
|
Check_Type (dpy, T_Display);
|
|
|
|
Check_Type (map, T_Vector);
|
2001-05-14 09:48:37 -04:00
|
|
|
n = S48_VECTOR_LENGTH(map);
|
2001-05-08 10:21:00 -04:00
|
|
|
Alloca (p, unsigned char*, n);
|
|
|
|
for (i = 0; i < n; i++)
|
2001-05-14 09:48:37 -04:00
|
|
|
p[i] = (int)s48_extract_integer (VECTOR(map)->data[i]);
|
2001-05-08 10:21:00 -04:00
|
|
|
ret = XSetPointerMapping (DISPLAY(dpy)->dpy, p, n) == MappingSuccess ?
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_TRUE : S48_FALSE;
|
2001-05-08 10:21:00 -04:00
|
|
|
Alloca_End;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
elk_init_xlib_wm () {
|
|
|
|
Define_Primitive (P_Reparent_Window, "reparent-window", 4, 4, EVAL);
|
|
|
|
Define_Primitive (P_Install_Colormap, "install-colormap", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_Uninstall_Colormap,
|
|
|
|
"uninstall-colormap", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_List_Installed_Colormaps,
|
|
|
|
"list-installed-colormaps", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_Set_Input_Focus, "set-input-focus", 4, 4, EVAL);
|
|
|
|
Define_Primitive (P_Input_Focus, "input-focus", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_General_Warp_Pointer,
|
|
|
|
"general-warp-pointer", 9, 9, EVAL);
|
|
|
|
Define_Primitive (P_Bell, "bell", 1, 2, VARARGS);
|
|
|
|
Define_Primitive (P_Set_Access_Control,
|
|
|
|
"set-access-control", 2, 2, EVAL);
|
|
|
|
Define_Primitive (P_Change_Save_Set, "change-save-set", 2, 2, EVAL);
|
|
|
|
Define_Primitive (P_Set_Close_Down_Mode,
|
|
|
|
"set-close-down-mode", 2, 2, EVAL);
|
|
|
|
Define_Primitive (P_Get_Pointer_Mapping,
|
|
|
|
"get-pointer-mapping", 1, 1, EVAL);
|
|
|
|
Define_Primitive (P_Set_Pointer_Mapping,
|
|
|
|
"set-pointer-mapping", 2, 2, EVAL);
|
|
|
|
Define_Symbol(&Sym_Pointer_Root, "pointer-root");
|
|
|
|
}
|