2003-03-10 21:47:38 -05:00
|
|
|
/* Copyright 2001-2003 by Norbert Freudemann, David Frese */
|
2001-09-20 10:41:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
#include "xlib.h"
|
2001-09-20 10:41:01 -04:00
|
|
|
|
2003-04-25 14:52:58 -04:00
|
|
|
s48_value scx_visual_class_binding = S48_FALSE;
|
|
|
|
#define scx_extract_visual_class(x) \
|
|
|
|
S48_EXTRACT_ENUM(x, scx_visual_class_binding)
|
|
|
|
s48_value scx_visual_classes_binding = S48_FALSE;
|
|
|
|
#define scx_enter_visual_class(x) S48_ENTER_ENUM(x, scx_visual_classes_binding)
|
2002-02-08 12:09:43 -05:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_enter_visual(Visual* vis) {
|
|
|
|
s48_value v = s48_make_record(scx_visual);
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
S48_GC_PROTECT_1(v);
|
|
|
|
S48_RECORD_SET(v, 0, S48_ENTER_POINTER(vis));
|
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
return v;
|
|
|
|
}
|
2002-02-08 12:09:43 -05:00
|
|
|
|
2003-04-25 14:52:58 -04:00
|
|
|
s48_value scx_visual_info_binding = S48_FALSE;
|
2001-09-20 10:41:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_enter_visual_info(XVisualInfo* vi) {
|
2003-04-25 14:52:58 -04:00
|
|
|
s48_value v = s48_make_record(scx_visual_info_binding);
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
S48_GC_PROTECT_1(v);
|
|
|
|
S48_RECORD_SET(v, 0, scx_enter_visual(vi->visual));
|
|
|
|
S48_RECORD_SET(v, 1, scx_enter_visualid(vi->visualid));
|
|
|
|
S48_RECORD_SET(v, 2, s48_enter_integer(vi->screen));
|
|
|
|
S48_RECORD_SET(v, 3, s48_enter_integer(vi->depth));
|
|
|
|
S48_RECORD_SET(v, 4, scx_enter_visual_class(vi->class));
|
|
|
|
S48_RECORD_SET(v, 5, s48_enter_integer(vi->red_mask));
|
|
|
|
S48_RECORD_SET(v, 6, s48_enter_integer(vi->green_mask));
|
|
|
|
S48_RECORD_SET(v, 7, s48_enter_integer(vi->blue_mask));
|
|
|
|
S48_RECORD_SET(v, 8, s48_enter_integer(vi->bits_per_rgb));
|
|
|
|
S48_RECORD_SET(v, 9, s48_enter_integer(vi->colormap_size));
|
2001-09-20 10:41:01 -04:00
|
|
|
S48_GC_UNPROTECT();
|
2003-03-10 21:47:38 -05:00
|
|
|
return v;
|
2001-09-20 10:41:01 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
unsigned int scx_extract_visual_info(s48_value v, XVisualInfo* vi) {
|
|
|
|
unsigned long mask = 0;
|
2003-04-25 14:52:58 -04:00
|
|
|
s48_check_record_type(v, scx_visual_info_binding);
|
2003-03-10 21:47:38 -05:00
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 0)))
|
|
|
|
vi->visual = scx_extract_visual(S48_RECORD_REF(v, 0));
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 1))) {
|
|
|
|
vi->visualid = scx_extract_visualid(S48_RECORD_REF(v, 1));
|
|
|
|
mask |= VisualIDMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 2))) {
|
|
|
|
vi->screen = s48_extract_integer(S48_RECORD_REF(v, 2));
|
|
|
|
mask |= VisualScreenMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 3))) {
|
|
|
|
vi->depth = s48_extract_integer(S48_RECORD_REF(v, 4));
|
|
|
|
mask |= VisualDepthMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 4))) {
|
|
|
|
vi->class = scx_extract_visual_class(S48_RECORD_REF(v, 5));
|
|
|
|
mask |= VisualClassMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 5))) {
|
|
|
|
vi->red_mask = s48_extract_integer(S48_RECORD_REF(v, 6));
|
|
|
|
mask |= VisualRedMaskMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 6))) {
|
|
|
|
vi->green_mask = s48_extract_integer(S48_RECORD_REF(v, 7));
|
|
|
|
mask |= VisualGreenMaskMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 7))) {
|
|
|
|
vi->blue_mask = s48_extract_integer(S48_RECORD_REF(v, 8));
|
|
|
|
mask |= VisualBlueMaskMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 8))) {
|
|
|
|
vi->bits_per_rgb = s48_extract_integer(S48_RECORD_REF(v, 9));
|
|
|
|
mask |= VisualBitsPerRGBMask;
|
|
|
|
}
|
|
|
|
if (!S48_FALSE_P(S48_RECORD_REF(v, 9))) {
|
|
|
|
vi->colormap_size = s48_extract_integer(S48_RECORD_REF(v, 10));
|
|
|
|
mask |= VisualColormapSizeMask;
|
|
|
|
}
|
2002-02-08 12:09:43 -05:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Get_Visual_Info(s48_value display, s48_value template) {
|
|
|
|
XVisualInfo templ;
|
|
|
|
unsigned long mask = scx_extract_visual_info(template, &templ);
|
|
|
|
XVisualInfo* vis;
|
|
|
|
int n, i;
|
|
|
|
s48_value l = S48_NULL;
|
2001-09-20 10:41:01 -04:00
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
vis = XGetVisualInfo(scx_extract_display(display),
|
|
|
|
mask, &templ, &n);
|
2001-09-20 10:41:01 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_GC_PROTECT_1(l);
|
|
|
|
for (i = n-1; i >= 0; i--)
|
|
|
|
l = s48_cons(scx_enter_visual_info(&vis[i]), l);
|
2001-09-20 10:41:01 -04:00
|
|
|
S48_GC_UNPROTECT();
|
2003-03-10 21:47:38 -05:00
|
|
|
return l;
|
2001-09-20 10:41:01 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Match_Visual_Info(s48_value display, s48_value scrnum,
|
2001-09-20 10:41:01 -04:00
|
|
|
s48_value depth, s48_value class) {
|
2003-03-10 21:47:38 -05:00
|
|
|
XVisualInfo vi;
|
|
|
|
Status r = XMatchVisualInfo(scx_extract_display(display),
|
|
|
|
s48_extract_integer(scrnum),
|
|
|
|
s48_extract_integer(depth),
|
|
|
|
scx_extract_visual_class(class),
|
|
|
|
&vi);
|
|
|
|
if (!r)
|
2001-09-20 10:41:01 -04:00
|
|
|
return S48_FALSE;
|
2003-03-10 21:47:38 -05:00
|
|
|
else
|
|
|
|
return scx_enter_visual_info(&vi);
|
|
|
|
}
|
|
|
|
|
|
|
|
s48_value scx_VisualIDFromVisual(s48_value visual) {
|
|
|
|
return s48_enter_integer(XVisualIDFromVisual(scx_extract_visual(visual)));
|
|
|
|
}
|
2001-09-20 10:41:01 -04:00
|
|
|
|
|
|
|
void scx_init_visual(void) {
|
2003-04-25 14:52:58 -04:00
|
|
|
SCX_PRO_IMP(scx_visual_class_binding, "scx-visual-class");
|
|
|
|
SCX_PRO_IMP(scx_visual_classes_binding, "scx-visual-classes");
|
|
|
|
SCX_PRO_IMP(scx_visual_info_binding, "scx-visual-info");
|
|
|
|
|
2001-09-20 10:41:01 -04:00
|
|
|
S48_EXPORT_FUNCTION(scx_Get_Visual_Info);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Match_Visual_Info);
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_EXPORT_FUNCTION(scx_VisualIDFromVisual);
|
2001-09-20 10:41:01 -04:00
|
|
|
}
|