scx/c/xlib/util.c

50 lines
1.3 KiB
C
Raw Normal View History

2001-05-08 10:21:00 -04:00
#include "xlib.h"
s48_value scx_Get_Default(s48_value dpy, s48_value program,
s48_value option) {
2001-08-28 10:39:07 -04:00
char* ret;
if (ret = XGetDefault(scx_extract_display(dpy),
s48_extract_string(program),
s48_extract_string(option)))
2001-08-28 10:39:07 -04:00
return s48_enter_string(ret);
else return S48_FALSE;
2001-05-08 10:21:00 -04:00
}
s48_value scx_Resource_Manager_String(s48_value dpy) {
2001-08-28 10:39:07 -04:00
char* ret;
if (ret = XResourceManagerString (scx_extract_display(dpy)))
return s48_enter_string(ret);
else return S48_FALSE;
2001-05-08 10:21:00 -04:00
}
s48_value scx_Parse_Geometry(s48_value strg) {
2001-08-28 10:39:07 -04:00
s48_value ret;
int x, y, res;
unsigned int w, h;
S48_DECLARE_GC_PROTECT(1);
res = XParseGeometry (s48_extract_string(strg), &x, &y, &w, &h);
ret = s48_make_vector(6, S48_FALSE);
2001-08-28 10:39:07 -04:00
S48_GC_PROTECT_1(ret);
if (res & XNegative) S48_VECTOR_SET(ret, 0, S48_TRUE);
if (res & YNegative) S48_VECTOR_SET(ret, 1, S48_TRUE);
if (res & XValue) S48_VECTOR_SET(ret, 2, s48_enter_integer(x));
if (res & YValue) S48_VECTOR_SET(ret, 3, s48_enter_integer(y));
if (res & WidthValue) S48_VECTOR_SET(ret, 4, s48_enter_integer(w));
if (res & HeightValue) S48_VECTOR_SET(ret, 5, s48_enter_integer(h));
2001-08-28 10:39:07 -04:00
S48_GC_UNPROTECT();
2001-08-28 10:39:07 -04:00
return ret;
2001-05-08 10:21:00 -04:00
}
2001-08-28 10:39:07 -04:00
// scx_Parse_Color is in colormap.c
void scx_init_util(void) {
S48_EXPORT_FUNCTION(scx_Get_Default);
S48_EXPORT_FUNCTION(scx_Resource_Manager_String);
S48_EXPORT_FUNCTION(scx_Parse_Geometry);
2001-05-08 10:21:00 -04:00
}