225 lines
6.6 KiB
C
225 lines
6.6 KiB
C
#include "xlib.h"
|
|
#include "scheme48.h"
|
|
|
|
// Open_Display(name) name should be a string or S48_FALSE (=> Null)
|
|
s48_value Open_Display (s48_value name) {
|
|
char* cname = (char*)0;
|
|
if (!S48_FALSE_P(name))
|
|
cname = s48_extract_string(name);
|
|
|
|
return ENTER_DISPLAY(XOpenDisplay(cname));
|
|
}
|
|
|
|
// Close_Display( Xdisplay ) Xdisplay should be a pointer to the X-lib struct
|
|
// cast into a Scheme-Integer.
|
|
s48_value Close_Display(s48_value Xdisplay) {
|
|
XCloseDisplay(EXTRACT_DISPLAY(Xdisplay));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
// The following procedure mainly wrap a corresponding XLib macro without
|
|
// underscores...
|
|
s48_value Display_Default_Root_Window(s48_value Xdisplay) {
|
|
Window wnd = DefaultRootWindow(EXTRACT_DISPLAY(Xdisplay));
|
|
return ENTER_WINDOW(wnd);
|
|
}
|
|
|
|
s48_value Display_Default_Colormap(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
Colormap cmp = DefaultColormap(dpy, DefaultScreen(dpy));
|
|
return ENTER_COLORMAP(cmp);
|
|
}
|
|
|
|
s48_value Display_Default_Gcontext(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
GC gc = DefaultGC(dpy, DefaultScreen(dpy));
|
|
return ENTER_GCONTEXT(gc);
|
|
}
|
|
|
|
s48_value Display_Default_Depth(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
int depth = DefaultDepth(dpy, DefaultScreen(dpy));
|
|
return s48_enter_integer(depth);
|
|
}
|
|
|
|
s48_value Display_Default_Screen_Number(s48_value Xdisplay) {
|
|
return s48_enter_integer(DefaultScreen(EXTRACT_DISPLAY(Xdisplay)));
|
|
}
|
|
|
|
s48_value Display_Cells(s48_value Xdisplay, s48_value ScrNum) {
|
|
int num = (int)s48_extract_integer(ScrNum);
|
|
return s48_enter_integer(DisplayCells(EXTRACT_DISPLAY(Xdisplay), num));
|
|
}
|
|
|
|
s48_value Display_Planes(s48_value Xdisplay, s48_value ScrNum) {
|
|
int num = (int)s48_extract_integer(ScrNum);
|
|
return s48_enter_integer(DisplayPlanes(EXTRACT_DISPLAY(Xdisplay), num));
|
|
}
|
|
|
|
s48_value Display_String(s48_value Xdisplay) {
|
|
char* s = DisplayString(EXTRACT_DISPLAY(Xdisplay));
|
|
return s48_enter_string(s);
|
|
}
|
|
|
|
s48_value Display_Vendor(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
char* s = ServerVendor(dpy);
|
|
int i = VendorRelease(dpy);
|
|
return s48_cons( s48_enter_string(s),
|
|
s48_enter_integer(i) );
|
|
}
|
|
|
|
s48_value Display_Protocol_Version(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
int maj = ProtocolVersion(dpy);
|
|
int min = ProtocolRevision(dpy);
|
|
return s48_cons( s48_enter_integer(maj),
|
|
s48_enter_integer(min) );
|
|
}
|
|
|
|
s48_value Display_Screen_Count(s48_value Xdisplay) {
|
|
int cnt = ScreenCount(EXTRACT_DISPLAY(Xdisplay));
|
|
return s48_enter_integer(cnt);
|
|
}
|
|
|
|
|
|
s48_value Display_Image_Byte_Order(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
return Bits_To_Symbols( (unsigned long)ImageByteOrder(dpy),
|
|
0, Byte_Order_Syms );
|
|
}
|
|
|
|
s48_value Display_Bitmap_Unit(s48_value Xdisplay) {
|
|
int bu = BitmapUnit(EXTRACT_DISPLAY(Xdisplay));
|
|
return s48_enter_integer(bu);
|
|
}
|
|
|
|
s48_value Display_Bitmap_Bit_Order(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
return Bits_To_Symbols( (unsigned long)BitmapBitOrder(dpy),
|
|
0, Byte_Order_Syms );
|
|
}
|
|
|
|
s48_value Display_Bitmap_Pad(s48_value Xdisplay) {
|
|
int bp = BitmapPad(EXTRACT_DISPLAY(Xdisplay));
|
|
return s48_enter_integer(bp);
|
|
}
|
|
|
|
s48_value Display_Width(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
return s48_enter_integer(DisplayWidth(dpy, DefaultScreen(dpy)));
|
|
}
|
|
|
|
s48_value Display_Height(s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
return s48_enter_integer(DisplayHeight(dpy, DefaultScreen(dpy)));
|
|
}
|
|
|
|
s48_value Display_Width_Mm (s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
return s48_enter_integer(DisplayWidthMM(dpy, DefaultScreen(dpy)));
|
|
}
|
|
|
|
s48_value Display_Height_Mm (s48_value Xdisplay) {
|
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
|
return s48_enter_integer(DisplayHeightMM(dpy, DefaultScreen(dpy)));
|
|
}
|
|
|
|
s48_value Display_Motion_Buffer_Size(s48_value Xdisplay) {
|
|
int mbs = XDisplayMotionBufferSize(EXTRACT_DISPLAY(Xdisplay));
|
|
return s48_enter_integer(mbs);
|
|
}
|
|
|
|
s48_value Display_Flush_Output (s48_value Xdisplay) {
|
|
XFlush (EXTRACT_DISPLAY(Xdisplay));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value Display_Wait_Output (s48_value Xdisplay, s48_value discard) {
|
|
XSync (EXTRACT_DISPLAY(Xdisplay), !S48_FALSE_P(discard));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value No_Op (s48_value Xdisplay) {
|
|
XNoOp(EXTRACT_DISPLAY(Xdisplay));
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
s48_value List_Depths (s48_value Xdisplay, s48_value scr) {
|
|
int i, num;
|
|
int* p;
|
|
s48_value ret;
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
p = XListDepths(EXTRACT_DISPLAY(Xdisplay), s48_extract_integer(scr), &num);
|
|
if (!p)
|
|
ret = S48_FALSE;
|
|
else {
|
|
S48_GC_PROTECT_1(ret);
|
|
ret = s48_make_vector(num, S48_NULL);
|
|
for (i = 0; i < num; i++)
|
|
S48_VECTOR_SET(ret, i, s48_enter_integer(p[i]));
|
|
XFree((char *)p);
|
|
}
|
|
|
|
S48_GC_UNPROTECT();
|
|
return ret;
|
|
}
|
|
|
|
s48_value List_Pixmap_Formats (s48_value Xdisplay) {
|
|
int num, i;
|
|
XPixmapFormatValues* p;
|
|
s48_value ret, t;
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
|
|
p = XListPixmapFormats(EXTRACT_DISPLAY(Xdisplay), &num);
|
|
|
|
if (!p)
|
|
ret = S48_FALSE;
|
|
else {
|
|
S48_GC_PROTECT_2(ret, t);
|
|
ret = s48_make_vector (num, S48_FALSE);
|
|
for (i = 0; i < num; i++) {
|
|
t = s48_cons(s48_enter_integer(p[i].depth),
|
|
s48_cons(s48_enter_integer(p[i].bits_per_pixel),
|
|
s48_cons(s48_enter_integer(p[i].scanline_pad),
|
|
S48_NULL)));
|
|
S48_VECTOR_SET(ret, i, t);
|
|
}
|
|
XFree ((char *)p);
|
|
}
|
|
|
|
S48_GC_UNPROTECT();
|
|
return ret;
|
|
}
|
|
|
|
void s48_init_display(void) {
|
|
S48_EXPORT_FUNCTION(Open_Display);
|
|
S48_EXPORT_FUNCTION(Close_Display);
|
|
S48_EXPORT_FUNCTION(Display_Default_Root_Window);
|
|
S48_EXPORT_FUNCTION(Display_Default_Colormap);
|
|
S48_EXPORT_FUNCTION(Display_Default_Gcontext);
|
|
S48_EXPORT_FUNCTION(Display_Default_Depth);
|
|
S48_EXPORT_FUNCTION(Display_Default_Screen_Number);
|
|
S48_EXPORT_FUNCTION(Display_Cells);
|
|
S48_EXPORT_FUNCTION(Display_Planes);
|
|
S48_EXPORT_FUNCTION(Display_String);
|
|
S48_EXPORT_FUNCTION(Display_Vendor);
|
|
S48_EXPORT_FUNCTION(Display_Protocol_Version);
|
|
S48_EXPORT_FUNCTION(Display_Screen_Count);
|
|
S48_EXPORT_FUNCTION(Display_Image_Byte_Order);
|
|
S48_EXPORT_FUNCTION(Display_Bitmap_Unit);
|
|
S48_EXPORT_FUNCTION(Display_Bitmap_Bit_Order);
|
|
S48_EXPORT_FUNCTION(Display_Bitmap_Pad);
|
|
S48_EXPORT_FUNCTION(Display_Width);
|
|
S48_EXPORT_FUNCTION(Display_Height);
|
|
S48_EXPORT_FUNCTION(Display_Width_Mm);
|
|
S48_EXPORT_FUNCTION(Display_Height_Mm);
|
|
S48_EXPORT_FUNCTION(Display_Motion_Buffer_Size);
|
|
S48_EXPORT_FUNCTION(Display_Flush_Output);
|
|
S48_EXPORT_FUNCTION(Display_Wait_Output);
|
|
S48_EXPORT_FUNCTION(No_Op);
|
|
S48_EXPORT_FUNCTION(List_Depths);
|
|
S48_EXPORT_FUNCTION(List_Pixmap_Formats);
|
|
}
|