112 lines
3.1 KiB
C
112 lines
3.1 KiB
C
|
#include "xlib.h"
|
||
|
|
||
|
s48_value Enter_Visual_Info(XVisualInfo* vi) {
|
||
|
s48_value t = s48_make_vector(10, S48_FALSE);
|
||
|
S48_DECLARE_GC_PROTECT(1);
|
||
|
|
||
|
S48_GC_PROTECT_1(t);
|
||
|
|
||
|
S48_VECTOR_SET(t, 0, SCX_ENTER_VISUAL(vi->visual));
|
||
|
S48_VECTOR_SET(t, 1, s48_enter_integer(vi->visualid));
|
||
|
S48_VECTOR_SET(t, 2, s48_enter_integer(vi->screen));
|
||
|
S48_VECTOR_SET(t, 3, s48_enter_integer(vi->depth));
|
||
|
S48_VECTOR_SET(t, 4, Bit_To_Symbol(vi->class, Visual_Class_Syms));
|
||
|
S48_VECTOR_SET(t, 5, s48_enter_integer(vi->red_mask));
|
||
|
S48_VECTOR_SET(t, 6, s48_enter_integer(vi->green_mask));
|
||
|
S48_VECTOR_SET(t, 7, s48_enter_integer(vi->blue_mask));
|
||
|
S48_VECTOR_SET(t, 8, s48_enter_integer(vi->colormap_size));
|
||
|
S48_VECTOR_SET(t, 9, s48_enter_integer(vi->bits_per_rgb));
|
||
|
|
||
|
S48_GC_UNPROTECT();
|
||
|
return t;
|
||
|
}
|
||
|
|
||
|
s48_value scx_Get_Visual_Info(s48_value Xdisplay, s48_value v) {
|
||
|
XVisualInfo template;
|
||
|
XVisualInfo* visualList;
|
||
|
int visualsMatch, i;
|
||
|
long mask = VisualNoMask;
|
||
|
s48_value res = S48_FALSE;
|
||
|
S48_DECLARE_GC_PROTECT(1);
|
||
|
|
||
|
for (i=1; i<10; i++) {
|
||
|
s48_value val = S48_VECTOR_REF(v, i);
|
||
|
if (!S48_FALSE_P(val)) {
|
||
|
switch (i) {
|
||
|
// 0 = visual is not allowed here.
|
||
|
case 1: {
|
||
|
template.visualid = s48_extract_integer(val);
|
||
|
mask |= VisualIDMask;
|
||
|
} break;
|
||
|
case 2: {
|
||
|
template.screen = s48_extract_integer(val);
|
||
|
mask |= VisualScreenMask;
|
||
|
} break;
|
||
|
case 3: {
|
||
|
template.depth = s48_extract_integer(val);
|
||
|
mask |= VisualDepthMask;
|
||
|
} break;
|
||
|
case 4: {
|
||
|
template.class = Symbol_To_Bit(val, Visual_Class_Syms);
|
||
|
mask |= VisualClassMask;
|
||
|
} break;
|
||
|
case 5: {
|
||
|
template.red_mask = s48_extract_integer(val);
|
||
|
mask |= VisualRedMaskMask;
|
||
|
} break;
|
||
|
case 6: {
|
||
|
template.green_mask = s48_extract_integer(val);
|
||
|
mask |= VisualGreenMaskMask;
|
||
|
} break;
|
||
|
case 7: {
|
||
|
template.blue_mask = s48_extract_integer(val);
|
||
|
mask |= VisualBlueMaskMask;
|
||
|
} break;
|
||
|
case 8: {
|
||
|
template.colormap_size = s48_extract_integer(val);
|
||
|
mask |= VisualColormapSizeMask;
|
||
|
} break;
|
||
|
case 9: {
|
||
|
template.bits_per_rgb = s48_extract_integer(val);
|
||
|
mask |= VisualBitsPerRGBMask;
|
||
|
} break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
visualList = XGetVisualInfo( SCX_EXTRACT_DISPLAY(Xdisplay),
|
||
|
mask, &template, &visualsMatch);
|
||
|
|
||
|
res = s48_make_vector(visualsMatch, S48_FALSE);
|
||
|
S48_GC_PROTECT_1(res);
|
||
|
|
||
|
for (i=0; i<visualsMatch; i++)
|
||
|
S48_VECTOR_SET(res, i, Enter_Visual_Info(&visualList[i]));
|
||
|
|
||
|
S48_GC_UNPROTECT();
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
s48_value scx_Visual_ID(s48_value Xvisual) {
|
||
|
return s48_enter_integer(XVisualIDFromVisual(SCX_EXTRACT_VISUAL(Xvisual)));
|
||
|
}
|
||
|
|
||
|
s48_value scx_Match_Visual_Info(s48_value Xdisplay, s48_value scrnum,
|
||
|
s48_value depth, s48_value class) {
|
||
|
XVisualInfo r;
|
||
|
if (XMatchVisualInfo(SCX_EXTRACT_DISPLAY(Xdisplay),
|
||
|
s48_extract_integer(scrnum),
|
||
|
s48_extract_integer(depth),
|
||
|
Symbol_To_Bit(class, Visual_Class_Syms),
|
||
|
&r))
|
||
|
return Enter_Visual_Info(&r);
|
||
|
else
|
||
|
return S48_FALSE;
|
||
|
}
|
||
|
|
||
|
void scx_init_visual(void) {
|
||
|
S48_EXPORT_FUNCTION(scx_Get_Visual_Info);
|
||
|
S48_EXPORT_FUNCTION(scx_Visual_ID);
|
||
|
S48_EXPORT_FUNCTION(scx_Match_Visual_Info);
|
||
|
}
|