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
|
|
|
|
|
|
|
|
|
|
|
/* Should be used with care */
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Intern_Atom (s48_value Xdisplay, s48_value name){
|
|
|
|
Atom a = XInternAtom(SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
s48_extract_string(name), 0);
|
|
|
|
return SCX_ENTER_ATOM(a);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Find_Atom (s48_value Xdisplay, s48_value name){
|
|
|
|
Atom a = XInternAtom (SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
s48_extract_string(name), 1);
|
|
|
|
return SCX_ENTER_ATOM(a);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Atom_Name (s48_value Xdisplay, s48_value a) {
|
2002-02-25 08:10:11 -05:00
|
|
|
char* s;
|
2001-07-11 10:22:42 -04:00
|
|
|
// not used: Disalbe_Interrupts
|
2002-02-25 08:10:11 -05:00
|
|
|
s = XGetAtomName (SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
s48_extract_integer(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-31 10:51:21 -04:00
|
|
|
s48_value scx_List_Properties (s48_value Xwindow, s48_value Xdisplay){
|
2001-07-11 10:22:42 -04:00
|
|
|
int n, i;
|
|
|
|
Atom *ap;
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value v = S48_FALSE;
|
2001-05-14 09:48:37 -04:00
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
2001-07-11 10:22:42 -04:00
|
|
|
//not used: Disable_Interrupts
|
2001-07-31 10:51:21 -04:00
|
|
|
ap = XListProperties (SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_WINDOW(Xwindow), &n);
|
2001-07-11 10:22:42 -04:00
|
|
|
//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:59:28 -04:00
|
|
|
S48_VECTOR_SET(v, i, s48_enter_integer((long) ap[i]));
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2001-07-11 10:59:28 -04:00
|
|
|
S48_GC_UNPROTECT();
|
2001-05-08 10:21:00 -04:00
|
|
|
XFree ((char *)ap);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Get_Property(s48_value Xwindow, s48_value Xdisplay,
|
2002-03-17 10:50:41 -05:00
|
|
|
s48_value Xatom_prop,
|
|
|
|
s48_value Xatom_type, s48_value start,
|
|
|
|
s48_value len, s48_value deletep) {
|
|
|
|
// Assumes short is 16 bits and int is 32 bits!
|
|
|
|
|
|
|
|
Atom req_type = S48_FALSE_P(Xatom_prop) ? AnyPropertyType
|
|
|
|
: SCX_EXTRACT_ATOM(Xatom_type);
|
|
|
|
|
|
|
|
Atom actual_type_ret;
|
2001-07-11 10:22:42 -04:00
|
|
|
int format_ret, i;
|
|
|
|
unsigned long nitems_ret, bytes_left_ret;
|
2002-04-02 06:36:34 -05:00
|
|
|
unsigned char* prop_ret = NULL;
|
2001-07-11 10:22:42 -04:00
|
|
|
|
2002-03-17 10:50:41 -05:00
|
|
|
s48_value ret = S48_FALSE, x = S48_FALSE, v = S48_FALSE;
|
|
|
|
|
|
|
|
S48_DECLARE_GC_PROTECT(3);
|
2001-07-11 10:22:42 -04:00
|
|
|
|
|
|
|
//not used: Disable_Interrupts
|
2002-04-02 06:36:34 -05:00
|
|
|
if (XGetWindowProperty (SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_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) == Success) {
|
|
|
|
|
2002-03-17 10:50:41 -05:00
|
|
|
// Create the data as a vector
|
|
|
|
S48_GC_PROTECT_3 (ret, v, x);
|
|
|
|
|
|
|
|
v = s48_make_vector(nitems_ret, S48_FALSE);
|
|
|
|
for (i = 0; i < nitems_ret; i++) {
|
|
|
|
switch (format_ret) {
|
2002-04-02 06:36:34 -05:00
|
|
|
case 8: x = s48_enter_fixnum(((unsigned char*) prop_ret)[i]); break;
|
2002-03-17 10:50:41 -05:00
|
|
|
case 16: x = s48_enter_fixnum(((short*) prop_ret)[i]); break;
|
|
|
|
case 32: x = s48_enter_integer(((long*) prop_ret)[i]); break;
|
2001-07-11 10:22:42 -04:00
|
|
|
}
|
2002-03-17 10:50:41 -05:00
|
|
|
S48_VECTOR_SET(v, i, x);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2002-03-17 10:50:41 -05:00
|
|
|
|
|
|
|
ret = s48_cons(s48_enter_integer(bytes_left_ret), S48_NULL);
|
|
|
|
ret = s48_cons(v, ret);
|
|
|
|
ret = s48_cons(s48_enter_integer(format_ret), ret);
|
|
|
|
ret = s48_cons(SCX_ENTER_ATOM(actual_type_ret), ret);
|
|
|
|
|
|
|
|
S48_GC_UNPROTECT();
|
2002-04-02 06:36:34 -05:00
|
|
|
} else {
|
|
|
|
// Property does not exists
|
|
|
|
ret = S48_FALSE;
|
2001-07-11 10:22:42 -04:00
|
|
|
}
|
2002-03-17 10:50:41 -05:00
|
|
|
|
2002-04-02 06:36:34 -05:00
|
|
|
if (prop_ret != NULL)
|
|
|
|
XFree(prop_ret);
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
return ret;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Change_Property(s48_value Xdisplay, s48_value Xwindow,
|
2002-03-17 10:50:41 -05:00
|
|
|
s48_value Xatom_prop, s48_value Xatom_type,
|
|
|
|
s48_value format, s48_value mode,
|
|
|
|
s48_value data) {
|
|
|
|
long i, x;
|
|
|
|
int f = (int)s48_extract_integer(format);
|
|
|
|
int m = s48_extract_integer(mode);
|
|
|
|
int nitems = S48_VECTOR_LENGTH(data);
|
|
|
|
|
|
|
|
unsigned char buf[nitems * f];
|
|
|
|
|
|
|
|
for (i = 0; i < nitems; i++) {
|
|
|
|
x = s48_extract_integer(S48_VECTOR_REF(data, i));
|
|
|
|
switch (f) {
|
|
|
|
case 8: ((char*) buf)[i] = (char)x; break;
|
|
|
|
case 16: ((short*) buf)[i] = (short)x; break;
|
|
|
|
case 32: ((long*) buf)[i] = (long)x; break;
|
|
|
|
}
|
2001-07-11 10:22:42 -04:00
|
|
|
}
|
2002-03-17 10:50:41 -05:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
XChangeProperty (SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_WINDOW(Xwindow),
|
|
|
|
SCX_EXTRACT_ATOM(Xatom_prop), SCX_EXTRACT_ATOM(Xatom_type),
|
2002-03-17 10:50:41 -05:00
|
|
|
f, m, buf, nitems);
|
2001-07-11 10:22:42 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Delete_Property (s48_value Xdisplay, s48_value Xwindow,
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Xatom_prop){
|
2001-07-31 10:51:21 -04:00
|
|
|
XDeleteProperty (SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_WINDOW(Xwindow),
|
|
|
|
SCX_EXTRACT_ATOM(Xatom_prop));
|
2001-07-11 10:49:34 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Rotate_Properties (s48_value Xdisplay, s48_value Xwindow,
|
2001-07-11 10:22:42 -04:00
|
|
|
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));
|
|
|
|
}
|
2001-07-31 10:51:21 -04:00
|
|
|
XRotateWindowProperties(SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_WINDOW(Xwindow),
|
2001-07-11 10:22:42 -04:00
|
|
|
p, n, (int)s48_extract_integer(delta));
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Set_Selection_Owner (s48_value Xdisplay, s48_value Xatom_s,
|
2001-07-11 10:59:28 -04:00
|
|
|
s48_value Xwindow_owner, s48_value time){
|
2001-07-11 10:22:42 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
XSetSelectionOwner (SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_ATOM(Xatom_s),
|
|
|
|
SCX_EXTRACT_WINDOW(Xwindow_owner), SCX_EXTRACT_TIME(time));
|
2001-07-11 10:22:42 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-11 10:22:42 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Get_Selection_Owner (s48_value Xdisplay, s48_value Xatom_s){
|
2002-02-08 12:09:43 -05:00
|
|
|
return SCX_ENTER_WINDOW(XGetSelectionOwner(SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_ATOM(Xatom_s)));
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2001-07-11 10:22:42 -04:00
|
|
|
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Convert_Selection (s48_value Xdisplay, s48_value Xatom_s,
|
2001-07-11 10:22:42 -04:00
|
|
|
s48_value Xatom_t, s48_value Xatom_p,
|
|
|
|
s48_value Xwindow, s48_value time){
|
2001-07-11 10:49:34 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
XConvertSelection(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_ATOM(Xatom_s),
|
|
|
|
SCX_EXTRACT_ATOM(Xatom_t), SCX_EXTRACT_ATOM(Xatom_p),
|
|
|
|
SCX_EXTRACT_WINDOW(Xwindow), SCX_EXTRACT_TIME(time));
|
2001-07-11 10:22:42 -04:00
|
|
|
return S48_UNSPECIFIC;
|
|
|
|
}
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
void scx_init_property(void) {
|
|
|
|
S48_EXPORT_FUNCTION(scx_Intern_Atom);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Find_Atom);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Atom_Name);
|
|
|
|
S48_EXPORT_FUNCTION(scx_List_Properties);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Get_Property);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Change_Property);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Delete_Property);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Rotate_Properties);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Set_Selection_Owner);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Get_Selection_Owner);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Convert_Selection);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|