2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
2001-07-11 10:22:42 -04:00
|
|
|
#include "scheme48.h"
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value Sym_Now;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Should be used with care */
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Intern_Atom (s48_value Xdisplay, s48_value name){
|
|
|
|
Atom a = XInternAtom(EXTRACT_DISPLAY(Xdisplay), s48_extract_string(name), 0);
|
2001-07-11 10:49:34 -04:00
|
|
|
return ENTER_ATOM(a);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Find_Atom (s48_value Xdisplay, s48_value name){
|
|
|
|
Atom a = XInternAtom (EXTRACT_DISPLAY(Xdisplay), s48_extract_string(name), 1);
|
2001-07-11 10:49:34 -04:00
|
|
|
return ENTER_ATOM(a);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Atom_Name (s48_value Xdisplay, s48_value a) {
|
2001-05-08 10:21:00 -04:00
|
|
|
register char *s;
|
2001-07-11 10:22:42 -04:00
|
|
|
// not used: Disalbe_Interrupts
|
2001-07-11 10:49:34 -04:00
|
|
|
s = XGetAtomName (EXTRACT_DISPLAY(Xdisplay), a);
|
2001-07-11 10:22:42 -04:00
|
|
|
// not used: Enable_Interrupts
|
|
|
|
return s48_enter_string (s);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value List_Properties (s48_value Xwindow, x48_value Xdisplay){
|
|
|
|
int n, i;
|
|
|
|
Atom *ap;
|
2001-05-14 09:48:37 -04:00
|
|
|
s48_value v;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
2001-07-11 10:22:42 -04:00
|
|
|
//not used: Disable_Interrupts
|
|
|
|
ap = XListProperties (EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
EXTRACT_WINDOW(Xwindow), &n);
|
|
|
|
//not used: Enable_Interrupts
|
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-07-11 10:22:42 -04:00
|
|
|
S48_VECTOR_SET(v, i, s48_enter_integer((long) ap[i]))
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_GC_UNPROTECT;
|
2001-05-08 10:21:00 -04:00
|
|
|
XFree ((char *)ap);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Get_Property(s48_value Xwindow, s48_value Xdisplay, s48_value Xatom_prop,
|
|
|
|
s48_value Xatom_type, s48_value start, s48_value len,
|
|
|
|
s48_value deletep) {
|
|
|
|
Atom req_type = AnyPropertyType, actual_type_ret;
|
|
|
|
int format_ret, i;
|
|
|
|
unsigned long nitems_ret, bytes_left_ret;
|
|
|
|
unsigned char* prop_ret;
|
|
|
|
s48_value ret, x;
|
|
|
|
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
|
|
|
|
|
|
if (!S48_EQ_P(Xatom_type, S48_FALSE)){
|
|
|
|
req_type = s48_extract_integer(Xatom_type);
|
|
|
|
}
|
|
|
|
//not used: Disable_Interrupts
|
|
|
|
XGetWindowProperty (EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindow),
|
|
|
|
s48_extract_integer(Xatom_prop), s48_extract_integer (start),
|
|
|
|
s48_extract_integer (len), S48_EXTRACT_BOOLEAN(deletep),
|
|
|
|
req_type, &actual_type_ret, &format_ret, &nitems_ret,
|
|
|
|
&bytes_left_ret, &prop_ret);
|
|
|
|
|
|
|
|
S48_GC_PROTECT_2 (ret, v);
|
|
|
|
ret = s48_cons(s48_enter_integer(bytes_left_ret), S48_NULL);
|
|
|
|
if (nitems_ret){
|
|
|
|
if (format_ret == 8){
|
|
|
|
char d[nitems_ret+1];
|
|
|
|
bcopy((char *)data, d, (int)nitems_ret);
|
|
|
|
d[nitems_ret+1] = (char)0;
|
|
|
|
ret = s48_cons (s48_enter_string(d), ret);
|
|
|
|
}else{
|
|
|
|
s48_value v;
|
|
|
|
// Assumes short is 16 bits and int is 32 bits.
|
|
|
|
v = s48_make_vector (nitems_ret, S48_NULL);
|
|
|
|
for (i = 0; i < nitems_ret; i++){
|
|
|
|
x = s48_enter_integer (format_ret == 16 ?
|
|
|
|
*((short *)prop_ret + i) : *((int *)prop_ret + i));
|
|
|
|
S48_VECTOR_SET(v, i, x;)
|
|
|
|
}
|
|
|
|
ret = s48_cons(v, ret);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2001-07-11 10:22:42 -04:00
|
|
|
}else{
|
|
|
|
ret = (S48_NULL, ret);
|
|
|
|
}
|
|
|
|
ret = s48_cons(s48_enter_integer((long)format_ret), ret);
|
|
|
|
ret = s48_cons(s48_enter_integer((long)actual_type_ret), ret);
|
|
|
|
S48_GC_UNPROTECT;
|
|
|
|
return ret;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Change_Property(s48_value Xdisplay, s48_value Xwindow,
|
|
|
|
s48_value Xatom_prop, s48_value Xatom_type,
|
|
|
|
s48_value format, s48_value mode,
|
|
|
|
s48_value data){
|
|
|
|
int i, x, f, m, nitems;
|
|
|
|
char* buf;
|
|
|
|
m = Symbol_To_Bit (mode, Propmode_Syms);
|
|
|
|
f = (int)s48_extract_integer(format);
|
|
|
|
switch (f) {
|
|
|
|
case 8:
|
|
|
|
buf = s48_extract_string(data);
|
|
|
|
nitems = strlen(buf);
|
|
|
|
break;
|
|
|
|
case 16: case 32:
|
|
|
|
nitems = S48_VECTOR_LENGTH(data);
|
|
|
|
// Alloca (buf, char*, nitems * (f / sizeof (char)));
|
|
|
|
for (i = 0; i < nitems; i++) {
|
|
|
|
x = (int)s48_extract_integer(s48_VECTOR_REF(data, nitems));
|
|
|
|
if (f == 16) {
|
|
|
|
*((short *)buf + i) = x; /* Assumes short is 16 bits */
|
|
|
|
}else *((int *)buf + i) = x;
|
|
|
|
} /* and int is 32 bits. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
XChangeProperty (EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindow),
|
2001-07-11 10:49:34 -04:00
|
|
|
EXTRACT_ATOM(Xatom_prop), EXTRACT_ATOM(Xatom_type),
|
2001-07-11 10:22:42 -04:00
|
|
|
f, m, (unsigned char *)buf, nitems);
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
|
|
|
|
s48_value P_Delete_Property (s48_value Xdisplay, s48_value Xwindow,
|
|
|
|
s48_value Xatom_prop){
|
2001-07-11 10:49:34 -04:00
|
|
|
XDeleteProperty (EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindow),
|
|
|
|
EXTRACT_ATOM(Xatom_prop));
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Rotate_Properties (s48_value Xdisplay, s48_value Xwindow,
|
|
|
|
s48_value Xatom_vec, s48_value delta){
|
|
|
|
int n = S48_VECTOR_LENGTH(Xatom_vec), i;
|
|
|
|
Atom p[n];
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
p[i] = s48_extract_integer(S48_VECTOR_REF(Xatom_vec, i));
|
|
|
|
}
|
|
|
|
XRotateWindowProperties(EXTRACT_DISPLAY(Xdisplay), EXTRACT_WINDOW(Xwindwo),
|
|
|
|
p, n, (int)s48_extract_integer(delta));
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Set_Selection_Owner (s48_value Xdisplay, s48_value Xatom_s,
|
|
|
|
s48_value Xwindow_owner, s58_value time){
|
|
|
|
|
2001-07-11 10:49:34 -04:00
|
|
|
XSetSelectionOwner (EXTRACT_DISPLAY(Xdisplay), EXTRACT_ATOM(Xatom_s),
|
2001-07-11 10:22:42 -04:00
|
|
|
EXTRACT_WINDOW(Xwindow_owner), EXTRACT_TIME(time));
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
|
2001-07-11 10:49:34 -04:00
|
|
|
s48_value Get_Selection_Owner (s48_value Xdisplay, s48_value Xatom_s){
|
2001-07-11 10:22:42 -04:00
|
|
|
return ENTER_WINDOW (XGetSelectionOwner (EXTRACT_DISPLAY(Xdisplay),
|
2001-07-11 10:49:34 -04:00
|
|
|
EXTRACT_ATOM(Xatom_s)));
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2001-07-11 10:22:42 -04:00
|
|
|
|
|
|
|
|
|
|
|
s48_value Convert_Selection (s48_value Xdisplay, s48_value Xatom_s,
|
|
|
|
s48_value Xatom_t, s48_value Xatom_p,
|
|
|
|
s48_value Xwindow, s48_value time){
|
2001-07-11 10:49:34 -04:00
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
XConvertSelection(EXTRACT_DISPLAY(Xdisplay), EXTRACT_ATOM(Xatom_s),
|
|
|
|
EXTRACT_ATOM(Xatom_t), EXTRACT_ATOM(Xatom_p),
|
|
|
|
EXTRACT_WINDOW(Xwindow), EXTRACT_TIME(time));
|
|
|
|
return S48_UNSPECIFIC;
|
|
|
|
}
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-11 10:49:34 -04:00
|
|
|
viod s48_init_graphics(void) {
|
|
|
|
S48_EXPORT_FUNCTION(Intern_Atom);
|
|
|
|
S48_EXPORT_FUNCTION(Find_Atom);
|
|
|
|
S48_EXPORT_FUNCTION(Atom_Name);
|
|
|
|
S48_EXPORT_FUNCTION(List_Properties);
|
|
|
|
S48_EXPORT_FUNCTION(Get_Property);
|
|
|
|
S48_EXPORT_FUNCTION(Change_Property);
|
|
|
|
S48_EXPORT_FUNCTION(Delete_Property);
|
|
|
|
S48_EXPORT_FUNCTION(Rotate_Property);
|
|
|
|
S48_EXPORT_FUNCTION(Set_Selection_Owner);
|
|
|
|
S48_EXPORT_FUNCTION(Get_Selection_Owner);
|
|
|
|
S48_EXPORT_FUNCTION(Convert_Selection);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|