2003-03-10 21:47:38 -05:00
|
|
|
/* Copyright 2001-2003 by Norbert Freudemann, David Frese */
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
#include "xlib.h"
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_enter_screenformat(ScreenFormat* sf) {
|
|
|
|
s48_value res =
|
|
|
|
s48_make_record(s48_get_imported_binding("scx-screen-format"));
|
2002-02-08 12:09:43 -05:00
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_GC_PROTECT_1(res);
|
|
|
|
S48_RECORD_SET(res, 0, s48_enter_integer(sf->depth));
|
|
|
|
S48_RECORD_SET(res, 1, s48_enter_integer(sf->bits_per_pixel));
|
|
|
|
S48_RECORD_SET(res, 2, s48_enter_integer(sf->scanline_pad));
|
2002-02-08 12:09:43 -05:00
|
|
|
S48_GC_UNPROTECT();
|
2003-03-10 21:47:38 -05:00
|
|
|
return res;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-13 08:47:17 -05:00
|
|
|
s48_value scx_screen_list = S48_NULL;
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_enter_screen(Screen* scr) {
|
2003-03-13 08:47:17 -05:00
|
|
|
s48_value s = scx_struct_cache_ref(scr, scx_screen_list);
|
|
|
|
if (s == S48_FALSE) {
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
s = s48_make_record(scx_screen);
|
|
|
|
S48_GC_PROTECT_1(s);
|
2003-03-25 13:27:18 -05:00
|
|
|
scx_struct_cache_set(scr, &scx_screen_list, s);
|
|
|
|
|
2003-03-13 08:47:17 -05:00
|
|
|
S48_RECORD_SET(s, 0, s48_enter_integer((long)scr));
|
|
|
|
S48_RECORD_SET(s, 1, scx_enter_display(DisplayOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 2, scx_enter_window(RootWindowOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 3, s48_enter_integer(WidthOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 4, s48_enter_integer(HeightOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 5, s48_enter_integer(WidthMMOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 6, s48_enter_integer(HeightMMOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 7, s48_enter_integer(XScreenNumberOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 8, s48_enter_integer(DefaultDepthOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 9, scx_enter_visual(DefaultVisualOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 10, scx_enter_gc(DefaultGCOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 11, scx_enter_colormap(DefaultColormapOfScreen(scr)));
|
2003-03-25 13:27:18 -05:00
|
|
|
S48_RECORD_SET(s, 12, scx_enter_pixel(WhitePixelOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 13, scx_enter_pixel(BlackPixelOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 14, s48_enter_integer(MaxCmapsOfScreen(scr)));
|
|
|
|
S48_RECORD_SET(s, 15, s48_enter_integer(MinCmapsOfScreen(scr)));
|
2003-03-13 08:47:17 -05:00
|
|
|
S48_RECORD_SET(s, 16, scx_enter_backing_store(DoesBackingStore(scr)));
|
|
|
|
S48_RECORD_SET(s, 17, S48_ENTER_BOOLEAN(DoesSaveUnders(scr)));
|
|
|
|
S48_RECORD_SET(s, 18, scx_enter_event_mask(EventMaskOfScreen(scr)));
|
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
}
|
2003-03-10 21:47:38 -05:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
s48_value scx_display_list = S48_NULL;
|
|
|
|
|
|
|
|
static int scx_after_function_wrapper(Display* dpy) {
|
|
|
|
s48_value display = scx_enter_display(dpy);
|
2003-03-25 13:27:18 -05:00
|
|
|
s48_value fun = S48_SHARED_BINDING_REF(
|
|
|
|
s48_get_imported_binding("scx-general-after-function"));
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_call_scheme(fun, 1, display);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
s48_value scx_enter_display(Display* dpy) {
|
|
|
|
s48_value d = scx_struct_cache_ref(dpy, scx_display_list);
|
|
|
|
if (d == S48_FALSE) {
|
|
|
|
int i;
|
|
|
|
s48_value l = S48_NULL;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
|
|
d = s48_make_record(scx_display);
|
|
|
|
S48_GC_PROTECT_2(d, l);
|
|
|
|
|
2003-04-17 10:53:27 -04:00
|
|
|
/* have to do this first, because screens want to reference their
|
|
|
|
display */
|
2003-03-10 21:47:38 -05:00
|
|
|
scx_struct_cache_set(dpy, &scx_display_list, d);
|
|
|
|
|
|
|
|
S48_RECORD_SET(d, 0, s48_enter_integer((long)dpy));
|
|
|
|
S48_RECORD_SET(d, 1, s48_enter_integer(ConnectionNumber(dpy)));
|
|
|
|
S48_RECORD_SET(d, 2, s48_enter_integer(ProtocolVersion(dpy)));
|
|
|
|
S48_RECORD_SET(d, 3, s48_enter_integer(ProtocolRevision(dpy)));
|
|
|
|
S48_RECORD_SET(d, 4, s48_enter_string(ServerVendor(dpy)));
|
|
|
|
S48_RECORD_SET(d, 5, scx_enter_byte_order(ImageByteOrder(dpy)));
|
|
|
|
S48_RECORD_SET(d, 6, s48_enter_integer(BitmapUnit(dpy)));
|
|
|
|
S48_RECORD_SET(d, 7, scx_enter_bit_order(BitmapBitOrder(dpy)));
|
|
|
|
S48_RECORD_SET(d, 8, s48_enter_integer(BitmapPad(dpy)));
|
|
|
|
S48_RECORD_SET(d, 9, s48_enter_integer(VendorRelease(dpy)));
|
|
|
|
S48_RECORD_SET(d, 10, s48_enter_integer(QLength(dpy)));
|
|
|
|
S48_RECORD_SET(d, 11, s48_enter_string(DisplayString(dpy)));
|
2003-03-13 08:47:17 -05:00
|
|
|
S48_RECORD_SET(d, 12,
|
|
|
|
scx_enter_screen(ScreenOfDisplay(dpy, DefaultScreen(dpy))));
|
2003-03-10 21:47:38 -05:00
|
|
|
for (i = ScreenCount(dpy)-1; i >= 0; i--)
|
|
|
|
l = s48_cons(scx_enter_screen(ScreenOfDisplay(dpy, i)), l);
|
|
|
|
S48_RECORD_SET(d, 13, l);
|
2003-03-25 13:27:18 -05:00
|
|
|
S48_RECORD_SET(d, 14, S48_FALSE);
|
2003-03-10 21:47:38 -05:00
|
|
|
XSetAfterFunction(dpy, &scx_after_function_wrapper);
|
2003-04-17 10:53:27 -04:00
|
|
|
S48_RECORD_SET(d, 15, S48_FALSE);
|
2003-03-25 13:27:18 -05:00
|
|
|
s48_call_scheme(S48_SHARED_BINDING_REF(s48_get_imported_binding(
|
|
|
|
"scx-initialize-display")), 1, d);
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
}
|
|
|
|
return d;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Open_Display (s48_value name) {
|
|
|
|
Display* res = XOpenDisplay(s48_extract_string(name));
|
|
|
|
if (res == NULL)
|
|
|
|
return S48_FALSE;
|
|
|
|
else
|
|
|
|
return scx_enter_display(res);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Close_Display(s48_value display) {
|
|
|
|
XCloseDisplay(scx_extract_display(display));
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Display_Last_Request_Read(s48_value display) {
|
|
|
|
Display* d = scx_extract_display(display);
|
|
|
|
return s48_enter_integer(LastKnownRequestProcessed(d));
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Next_Request(s48_value display) {
|
|
|
|
Display* d = scx_extract_display(display);
|
|
|
|
return s48_enter_integer(NextRequest(d));
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Display_Flush(s48_value display) {
|
|
|
|
XFlush(scx_extract_display(display));
|
2001-05-21 11:33:32 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Display_Sync(s48_value display, s48_value discard) {
|
|
|
|
XSync(scx_extract_display(display), S48_EXTRACT_BOOLEAN(discard));
|
2001-05-21 11:33:32 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_No_Op(s48_value display) {
|
|
|
|
XNoOp(scx_extract_display(display));
|
2001-05-21 11:33:32 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Display_Select_Input(s48_value display, s48_value window,
|
2001-10-09 11:33:45 -04:00
|
|
|
s48_value event_mask) {
|
2003-03-10 21:47:38 -05:00
|
|
|
XSelectInput(scx_extract_display(display),
|
|
|
|
scx_extract_window(window),
|
|
|
|
scx_extract_event_mask(event_mask));
|
2002-02-25 08:10:11 -05:00
|
|
|
return S48_UNSPECIFIC;
|
2001-10-09 11:33:45 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
void scx_init_display(void) {
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_GC_PROTECT_GLOBAL(scx_display_list);
|
2003-03-13 08:47:17 -05:00
|
|
|
S48_GC_PROTECT_GLOBAL(scx_screen_list);
|
2001-08-29 10:52:44 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_EXPORT_FUNCTION(scx_Open_Display);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Close_Display);
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_EXPORT_FUNCTION(scx_Display_Last_Request_Read);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Next_Request);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Display_Flush);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Display_Sync);
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_EXPORT_FUNCTION(scx_No_Op);
|
2001-10-09 11:33:45 -04:00
|
|
|
S48_EXPORT_FUNCTION(scx_Display_Select_Input);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|