fixed gc protection
This commit is contained in:
parent
0afc105e6c
commit
a678b14752
129
c/xlib/client.c
129
c/xlib/client.c
|
@ -1,56 +1,59 @@
|
|||
#include "xlib.h"
|
||||
|
||||
s48_value scx_Iconify_Window(s48_value display, s48_value w, s48_value scr) {
|
||||
S48_DECLARE_GC_PROTECT_3(display, w, scr);
|
||||
if (!XIconifyWindow(scx_extract_display(display),
|
||||
scx_extract_window(w),
|
||||
s48_extract_integer(scr)))
|
||||
return S48_FALSE;
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_Withdraw_Window(s48_value display, s48_value w, s48_value scr) {
|
||||
S48_DECLARE_GC_PROTECT_3(display, w, scr);
|
||||
if (!XWithdrawWindow(scx_extract_display(display),
|
||||
scx_extract_window(w),
|
||||
s48_extract_integer(scr)))
|
||||
return S48_FALSE;
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_Reconfigure_Wm_Window(s48_value dpy, s48_value w, s48_value scr,
|
||||
s48_value conf) {
|
||||
XWindowChanges WC;
|
||||
unsigned long mask = scx_extract_window_changes(conf, &WC);
|
||||
unsigned long mask;
|
||||
S48_DECLARE_GC_PROTECT_4(dpy, w, scr, conf);
|
||||
mask = scx_extract_window_changes(conf, &WC);
|
||||
|
||||
if (!XReconfigureWMWindow(scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
s48_extract_integer(scr),
|
||||
mask, &WC))
|
||||
return S48_FALSE;
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_Get_Wm_Command(s48_value dpy, s48_value w) {
|
||||
int i, ac;
|
||||
char** av;
|
||||
s48_value ret = S48_NULL;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, w, ret);
|
||||
|
||||
if (!XGetCommand (scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
&av, &ac))
|
||||
return S48_FALSE;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
|
||||
S48_GC_PROTECT_1(ret);
|
||||
for (i = ac-1; i >= 0; i--)
|
||||
ret = s48_cons(s48_enter_string(av[i]), ret);
|
||||
S48_GC_UNPROTECT();
|
||||
if (av != NULL) XFreeStringList(av);
|
||||
return ret;
|
||||
S48_GC_RETURN(ret);
|
||||
}
|
||||
|
||||
s48_value scx_Set_Wm_Command(s48_value dpy, s48_value w, s48_value cmd) {
|
||||
int i, n = s48_list_length(cmd);
|
||||
char *argv[n];
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, w, cmd);
|
||||
for (i = 0; i < n; i++) {
|
||||
argv[i] = s48_extract_string(S48_CAR(cmd));
|
||||
cmd = S48_CDR(cmd);
|
||||
|
@ -58,30 +61,29 @@ s48_value scx_Set_Wm_Command(s48_value dpy, s48_value w, s48_value cmd) {
|
|||
XSetCommand(scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
argv, n);
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_Get_Wm_Protocols(s48_value display, s48_value w) {
|
||||
Atom *p;
|
||||
int i, n;
|
||||
s48_value ret = S48_NULL;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
S48_DECLARE_GC_PROTECT_3(display, w, ret);
|
||||
|
||||
if (!XGetWMProtocols (scx_extract_display(display),
|
||||
scx_extract_window(w), &p, &n))
|
||||
return S48_FALSE;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
|
||||
S48_GC_PROTECT_1(ret);
|
||||
for (i = n-1; i >= 0; i--)
|
||||
ret = s48_cons(scx_enter_atom(p[i]), ret);
|
||||
S48_GC_UNPROTECT();
|
||||
XFree((char *)p);
|
||||
return ret;
|
||||
S48_GC_RETURN(ret);
|
||||
}
|
||||
|
||||
s48_value scx_Set_Wm_Protocols (s48_value display, s48_value w, s48_value v) {
|
||||
int i, n = s48_list_length(v);
|
||||
Atom p[n];
|
||||
S48_DECLARE_GC_PROTECT_3(display, w, v);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
p[i] = scx_extract_atom(S48_CAR(v));
|
||||
|
@ -91,40 +93,38 @@ s48_value scx_Set_Wm_Protocols (s48_value display, s48_value w, s48_value v) {
|
|||
if (!XSetWMProtocols (scx_extract_display(display),
|
||||
scx_extract_window(w),
|
||||
p, n))
|
||||
return S48_FALSE;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_Get_Wm_Class (s48_value display, s48_value w) {
|
||||
s48_value ret, x;
|
||||
s48_value ret = S48_FALSE, x = S48_FALSE;
|
||||
XClassHint c;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
S48_DECLARE_GC_PROTECT_4(display, w, ret, x);
|
||||
|
||||
c.res_name = c.res_class = 0;
|
||||
if (!XGetClassHint(scx_extract_display(display),
|
||||
scx_extract_window(w), &c))
|
||||
return S48_FALSE;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
|
||||
ret = s48_cons(S48_FALSE, S48_FALSE);
|
||||
S48_GC_PROTECT_1(ret);
|
||||
S48_SET_CAR(ret, s48_enter_string(c.res_name));
|
||||
S48_SET_CDR(ret, s48_enter_string(c.res_class));
|
||||
ret = s48_enter_string(c.res_class);
|
||||
ret = s48_cons(s48_enter_string(c.res_name), ret);
|
||||
XFree(c.res_name);
|
||||
XFree(c.res_class);
|
||||
S48_GC_UNPROTECT();
|
||||
return ret;
|
||||
S48_GC_RETURN(ret);
|
||||
}
|
||||
|
||||
s48_value scx_Set_Wm_Class(s48_value dpy, s48_value w, s48_value name,
|
||||
s48_value class) {
|
||||
XClassHint c;
|
||||
S48_DECLARE_GC_PROTECT_4(dpy, w, name, class);
|
||||
c.res_name = s48_extract_string(name);
|
||||
c.res_class = s48_extract_string(class);
|
||||
XSetClassHint(scx_extract_display(dpy),
|
||||
scx_extract_window(dpy),
|
||||
&c);
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_initial_state_binding = S48_FALSE;
|
||||
|
@ -141,8 +141,7 @@ s48_value scx_wm_hints_binding = S48_FALSE;
|
|||
|
||||
s48_value scx_enter_wm_hint_alist(XWMHints* p) {
|
||||
s48_value res = S48_NULL, t = S48_FALSE;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
S48_GC_PROTECT_2(res, t);
|
||||
S48_DECLARE_GC_PROTECT_2(res, t);
|
||||
if (p->flags & InputHint) {
|
||||
t = scx_enter_wm_hint(0); t = s48_cons(t, S48_ENTER_BOOLEAN(p->input));
|
||||
res = s48_cons(t, res);
|
||||
|
@ -182,15 +181,16 @@ s48_value scx_enter_wm_hint_alist(XWMHints* p) {
|
|||
t = s48_cons(t, S48_ENTER_BOOLEAN(p->flags & XUrgencyHint));
|
||||
res = s48_cons(t, res);
|
||||
|
||||
S48_GC_UNPROTECT();
|
||||
return res;
|
||||
S48_GC_RETURN(res);
|
||||
}
|
||||
|
||||
void scx_extract_wm_hint_alist(s48_value alist, XWMHints* p) {
|
||||
s48_value v = S48_FALSE;
|
||||
S48_DECLARE_GC_PROTECT_2(alist, v);
|
||||
p->flags = 0;
|
||||
while (alist != S48_NULL) {
|
||||
int h = scx_extract_wm_hint(S48_CAR(S48_CAR(alist)));
|
||||
s48_value v = S48_CDR(S48_CAR(alist));
|
||||
v = S48_CDR(S48_CAR(alist));
|
||||
p->flags |= (1L << h);
|
||||
switch (1L << h) {
|
||||
case InputHint:
|
||||
|
@ -222,70 +222,77 @@ void scx_extract_wm_hint_alist(s48_value alist, XWMHints* p) {
|
|||
}
|
||||
alist = S48_CDR(alist);
|
||||
}
|
||||
S48_GC_UNPROTECT();
|
||||
}
|
||||
|
||||
s48_value scx_Get_Wm_Hints(s48_value dpy, s48_value w) {
|
||||
XWMHints* p;
|
||||
s48_value res = S48_NULL;
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, w, res);
|
||||
|
||||
p = XGetWMHints(scx_extract_display(dpy),
|
||||
scx_extract_window(w));
|
||||
if (p) {
|
||||
res = scx_enter_wm_hint_alist(p);
|
||||
XFree(p);
|
||||
} else
|
||||
return S48_FALSE;
|
||||
return res;
|
||||
if (p == NULL)
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
res = scx_enter_wm_hint_alist(p);
|
||||
XFree(p);
|
||||
S48_GC_RETURN(res);
|
||||
}
|
||||
|
||||
s48_value scx_Set_Wm_Hints (s48_value dpy, s48_value w, s48_value hints) {
|
||||
XWMHints WMH;
|
||||
scx_extract_wm_hint_alist(hints, &WMH);
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, w, hints);
|
||||
|
||||
XSetWMHints(scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
&WMH);
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_Get_Transient_For(s48_value dpy, s48_value w) {
|
||||
Window win;
|
||||
S48_DECLARE_GC_PROTECT_2(dpy, w);
|
||||
if (!XGetTransientForHint(scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
&win))
|
||||
return S48_FALSE;
|
||||
return scx_enter_window(win);
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
S48_GC_RETURN(scx_enter_window(win));
|
||||
}
|
||||
|
||||
s48_value scx_Set_Transient_For(s48_value dpy, s48_value w, s48_value pw) {
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, w, pw);
|
||||
XSetTransientForHint(scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
scx_extract_window(pw));
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_Get_Text_Property(s48_value dpy, s48_value w, s48_value a) {
|
||||
XTextProperty ret;
|
||||
s48_value res = S48_FALSE;
|
||||
S48_DECLARE_GC_PROTECT_4(dpy, w, a, res);
|
||||
if (!XGetTextProperty (scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
&ret,
|
||||
scx_extract_atom(a)))
|
||||
return S48_FALSE;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
res = scx_enter_property(ret.encoding, ret.format, ret.value, ret.nitems);
|
||||
XFree(ret.value);
|
||||
return res;
|
||||
S48_GC_RETURN(res);
|
||||
}
|
||||
|
||||
s48_value scx_Set_Text_Property(s48_value dpy, s48_value w, s48_value prop,
|
||||
s48_value a) {
|
||||
XTextProperty p;
|
||||
S48_DECLARE_GC_PROTECT_4(dpy, w, prop, a);
|
||||
scx_extract_property(prop, &p.encoding, &p.format,
|
||||
(char**)&p.value,
|
||||
(int*)&p.nitems);
|
||||
XSetTextProperty(scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
&p, scx_extract_atom(a));
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_size_hint_binding = S48_FALSE;
|
||||
|
@ -347,10 +354,12 @@ s48_value scx_enter_size_hint_alist(XSizeHints* sh) {
|
|||
}
|
||||
|
||||
void scx_extract_size_hint_alist(s48_value l, XSizeHints* sh) {
|
||||
s48_value v = S48_FALSE;
|
||||
S48_DECLARE_GC_PROTECT_2(l, v);
|
||||
sh->flags = 0;
|
||||
for (; l != S48_NULL; l = S48_CDR(l)) {
|
||||
int m = scx_extract_size_hint(S48_CAR(S48_CAR(l)));
|
||||
s48_value v = S48_CDR(S48_CAR(l));
|
||||
v = S48_CDR(S48_CAR(l));
|
||||
sh->flags |= (1L << m);
|
||||
switch (1L << m) {
|
||||
case USPosition: case PPosition:
|
||||
|
@ -388,28 +397,31 @@ void scx_extract_size_hint_alist(s48_value l, XSizeHints* sh) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
S48_GC_UNPROTECT();
|
||||
}
|
||||
|
||||
s48_value scx_Get_Wm_Normal_Hints(s48_value dpy, s48_value win) {
|
||||
XSizeHints SH;
|
||||
long supplied_by_user;
|
||||
S48_DECLARE_GC_PROTECT_2(dpy, win);
|
||||
if (!XGetWMNormalHints(scx_extract_display(dpy),
|
||||
scx_extract_window(win),
|
||||
&SH, &supplied_by_user))
|
||||
return S48_FALSE;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
/* ignoring supplied_by_user ... ?! */
|
||||
return scx_enter_size_hint_alist(&SH);
|
||||
S48_GC_RETURN(scx_enter_size_hint_alist(&SH));
|
||||
}
|
||||
|
||||
s48_value scx_Set_Wm_Normal_Hints(s48_value dpy, s48_value win,
|
||||
s48_value hints) {
|
||||
XSizeHints SH;
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, win, hints);
|
||||
scx_extract_size_hint_alist(hints, &SH);
|
||||
|
||||
XSetWMNormalHints(scx_extract_display(dpy),
|
||||
scx_extract_window(win),
|
||||
&SH);
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
s48_value scx_icon_size_binding = S48_FALSE;
|
||||
|
@ -429,6 +441,7 @@ s48_value scx_enter_icon_size(XIconSize* is) {
|
|||
}
|
||||
|
||||
void scx_extract_icon_size(s48_value r, XIconSize* is) {
|
||||
S48_DECLARE_GC_PROTECT_1(r);
|
||||
s48_check_record_type(r, scx_icon_size_binding);
|
||||
is->min_width = s48_extract_integer(S48_RECORD_REF(r, 0));
|
||||
is->min_height = s48_extract_integer(S48_RECORD_REF(r, 1));
|
||||
|
@ -436,30 +449,30 @@ void scx_extract_icon_size(s48_value r, XIconSize* is) {
|
|||
is->max_height = s48_extract_integer(S48_RECORD_REF(r, 3));
|
||||
is->width_inc = s48_extract_integer(S48_RECORD_REF(r, 4));
|
||||
is->height_inc = s48_extract_integer(S48_RECORD_REF(r, 5));
|
||||
S48_GC_UNPROTECT();
|
||||
}
|
||||
|
||||
s48_value scx_Get_Icon_Sizes(s48_value dpy, s48_value w) {
|
||||
XIconSize *p;
|
||||
int i, n;
|
||||
s48_value v = S48_NULL;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, w, v);
|
||||
|
||||
if (!XGetIconSizes (scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
&p, &n))
|
||||
return S48_FALSE;
|
||||
S48_GC_RETURN(S48_FALSE);
|
||||
|
||||
S48_GC_PROTECT_1(v);
|
||||
for (i = n-1; i >= 0; i--)
|
||||
v = s48_cons(scx_enter_icon_size(&p[i]), v);
|
||||
S48_GC_UNPROTECT();
|
||||
XFree((char *)p);
|
||||
return v;
|
||||
S48_GC_RETURN(v);
|
||||
}
|
||||
|
||||
s48_value scx_Set_Icon_Sizes(s48_value dpy, s48_value w, s48_value v) {
|
||||
int i, n = s48_list_length(v);
|
||||
XIconSize p[n];
|
||||
S48_DECLARE_GC_PROTECT_3(dpy, w, v);
|
||||
for (i = 0; i < n; i++) {
|
||||
scx_extract_icon_size(S48_CAR(v), &p[i]);
|
||||
v = S48_CDR(v);
|
||||
|
@ -467,7 +480,7 @@ s48_value scx_Set_Icon_Sizes(s48_value dpy, s48_value w, s48_value v) {
|
|||
XSetIconSizes(scx_extract_display(dpy),
|
||||
scx_extract_window(w),
|
||||
p, n);
|
||||
return S48_UNSPECIFIC;
|
||||
S48_GC_RETURN(S48_UNSPECIFIC);
|
||||
}
|
||||
|
||||
scx_init_client() {
|
||||
|
|
|
@ -22,6 +22,19 @@
|
|||
|
||||
#include <scheme48.h>
|
||||
|
||||
#define S48_DECLARE_GC_PROTECT_1(v0) \
|
||||
S48_DECLARE_GC_PROTECT(1); S48_GC_PROTECT_1(v0)
|
||||
#define S48_DECLARE_GC_PROTECT_2(v0, v1) \
|
||||
S48_DECLARE_GC_PROTECT(2); S48_GC_PROTECT_2(v0, v1)
|
||||
#define S48_DECLARE_GC_PROTECT_3(v0, v1, v2) \
|
||||
S48_DECLARE_GC_PROTECT(3); S48_GC_PROTECT_3(v0, v1, v2)
|
||||
#define S48_DECLARE_GC_PROTECT_4(v0, v1, v2, v3) \
|
||||
S48_DECLARE_GC_PROTECT(4); S48_GC_PROTECT_4(v0, v1, v2, v3)
|
||||
#define S48_DECLARE_GC_PROTECT_5(v0, v1, v2, v3, v4) \
|
||||
S48_DECLARE_GC_PROTECT(5); S48_GC_PROTECT_5(v0, v1, v2, v3, v4)
|
||||
|
||||
#define S48_GC_RETURN(v) do { S48_GC_UNPROTECT(); return(v); } while(0)
|
||||
|
||||
#define S48_NULL_P(x) S48_EQ(x, S48_NULL)
|
||||
|
||||
#define S48_INTEGER_P(x) (S48_FIXNUM_P(x) || S48_BIGNUM_P(x))
|
||||
|
|
Loading…
Reference in New Issue