149 lines
4.3 KiB
C
149 lines
4.3 KiB
C
#include "xlib.h"
|
|
#include "scheme48.h"
|
|
|
|
s48_value Reparent_Window(s48_value Xdisplay, s48_value Xwindow,
|
|
s48_value Xwindow_parent, s48_value x,
|
|
s48_value y) {
|
|
XReparentWindow(EXTRACT_DISPLAY(Xdisplay),
|
|
EXTRACT_WINDOW(Xwindow),
|
|
EXTRACT_WINDOW(Xwindow_parent),
|
|
(int)s48_extract_integer (x), (int)s48_extract_integer (y));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Install_Colormap(s48_value Xdisplay, s48_value Xcolormap) {
|
|
XInstallColormap(EXTRACT_DISPLAY(Xdisplay), EXTRACT_COLORMAP(Xcolormap));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Uninstall_Colormap(s48_value Xdisplay, s48_value Xcolormap) {
|
|
XUninstallColormap(EXTRACT_DISPLAY(Xdisplay), EXTRACT_COLORMAP(Xcolormap));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value List_Installed_Colormaps(s48_value Xdisplay, s48_value Xwindow) {
|
|
int i, n;
|
|
Colormap *ret;
|
|
s48_value v;
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
ret = XListInstalledColormaps(EXTRACT_DISPLAY(Xdisplay),
|
|
EXTRACT_WINDOW(Xwindow),
|
|
&n);
|
|
v = s48_make_vector (n, S48_FALSE);
|
|
S48_GC_PROTECT_1 (v);
|
|
for (i = 0; i < n; i++) {
|
|
S48_VECTOR_SET(v, i, ENTER_COLORMAP(ret[i]));
|
|
}
|
|
XFree ((char *)ret);
|
|
S48_GC_UNPROTECT();
|
|
return v;
|
|
}
|
|
|
|
s48_value Set_Input_Focus(s48_value Xdisplay, s48_value Xwindow,
|
|
s48_value revert_to, s48_value time) {
|
|
Window focus = PointerRoot;
|
|
|
|
if (!S48_SYMBOL_P(Xwindow))
|
|
focus = EXTRACT_WINDOW(Xwindow);
|
|
|
|
XSetInputFocus (EXTRACT_DISPLAY(Xdisplay), focus,
|
|
Symbol_To_Bit (revert_to, Revert_Syms),
|
|
EXTRACT_TIME(time));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Input_Focus (s48_value Xdisplay) {
|
|
Window win;
|
|
int revert_to;
|
|
s48_value ret, x;
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
XGetInputFocus (EXTRACT_DISPLAY(Xdisplay), &win, &revert_to);
|
|
ret = s48_cons (S48_NULL, S48_NULL);
|
|
S48_GC_PROTECT_1 (ret);
|
|
x = ENTER_WINDOW(win); S48_SET_CAR(ret, x);
|
|
x = Bit_To_Symbol((unsigned long)revert_to, Revert_Syms);
|
|
S48_SET_CDR(ret, x);
|
|
|
|
S48_GC_UNPROTECT();
|
|
return ret;
|
|
}
|
|
|
|
s48_value General_Warp_Pointer(s48_value dpy, s48_value dst, s48_value dstx,
|
|
s48_value dsty, s48_value src, s48_value srcx,
|
|
s48_value srcy, s48_value srcw, s48_value srch) {
|
|
XWarpPointer (EXTRACT_DISPLAY(dpy),
|
|
EXTRACT_WINDOW(src), EXTRACT_WINDOW(dst),
|
|
(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));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Bell(s48_value Xdisplay, s48_value percent) {
|
|
int p = (int)s48_extract_integer(percent);
|
|
XBell (EXTRACT_DISPLAY(Xdisplay), p);
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Set_Access_Control(s48_value Xdisplay, s48_value on) {
|
|
XSetAccessControl (EXTRACT_DISPLAY(Xdisplay), !S48_FALSE_P(on));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Change_Save_Set(s48_value Xdisplay, s48_value win, s48_value mode) {
|
|
XChangeSaveSet(EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(win),
|
|
Symbol_To_Bit(mode, Saveset_Syms));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Set_Close_Down_Mode(s48_value Xdisplay, s48_value mode) {
|
|
XSetCloseDownMode(EXTRACT_DISPLAY(Xdisplay),
|
|
Symbol_To_Bit (mode, Closemode_Syms));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
static s48_value Get_Pointer_Mapping(s48_value Xdisplay) {
|
|
unsigned char map[256];
|
|
int i, n;
|
|
s48_value ret;
|
|
|
|
n = XGetPointerMapping (EXTRACT_DISPLAY(Xdisplay), map, 256);
|
|
ret = s48_make_vector (n, S48_NULL);
|
|
for (i = 0; i < n; i++)
|
|
S48_VECTOR_SET(ret, i, s48_enter_integer (map[i]));
|
|
return ret;
|
|
}
|
|
|
|
s48_value Set_Pointer_Mapping (s48_value Xdisplay, s48_value map) {
|
|
int i, n = S48_VECTOR_LENGTH(map);
|
|
unsigned char p[n];
|
|
int ret;
|
|
|
|
for (i = 0; i < n; i++)
|
|
p[i] = (int)s48_extract_integer(S48_VECTOR_REF(map, i));
|
|
|
|
ret = XSetPointerMapping (EXTRACT_DISPLAY(Xdisplay), p, n);
|
|
return (ret == MappingSuccess) ? S48_TRUE : S48_FALSE;
|
|
}
|
|
|
|
void s48_init_wm(void) {
|
|
S48_EXPORT_FUNCTION(Reparent_Window);
|
|
S48_EXPORT_FUNCTION(Install_Colormap);
|
|
S48_EXPORT_FUNCTION(Uninstall_Colormap);
|
|
S48_EXPORT_FUNCTION(List_Installed_Colormaps);
|
|
S48_EXPORT_FUNCTION(Set_Input_Focus);
|
|
S48_EXPORT_FUNCTION(Input_Focus);
|
|
S48_EXPORT_FUNCTION(General_Warp_Pointer);
|
|
S48_EXPORT_FUNCTION(Bell);
|
|
S48_EXPORT_FUNCTION(Set_Access_Control);
|
|
S48_EXPORT_FUNCTION(Change_Save_Set);
|
|
S48_EXPORT_FUNCTION(Set_Close_Down_Mode);
|
|
S48_EXPORT_FUNCTION(Get_Pointer_Mapping);
|
|
S48_EXPORT_FUNCTION(Set_Pointer_Mapping);
|
|
}
|