#include "xlib.h" #include "scheme48.h" #define ECAST(name, type) type* name = (type*)e #define sidx 5 #define SET(i, v) S48_VECTOR_SET(r, i, v) #define SETSIZE(i) r = s48_make_vector(sidx+i, S48_FALSE) s48_value scx_enter_event(XEvent* e) { s48_value r = S48_FALSE; s48_value temp = S48_FALSE; int i; S48_DECLARE_GC_PROTECT(2); S48_GC_PROTECT_2(r, temp); switch (e->type) { case KeyPress : case KeyRelease : case ButtonPress : case ButtonRelease : case MotionNotify : { ECAST(q, XKeyEvent); SETSIZE(10); // all equal in the beginning SET(sidx+0, SCX_ENTER_WINDOW(q->root)); SET(sidx+1, SCX_ENTER_WINDOW(q->subwindow)); SET(sidx+2, SCX_ENTER_TIME(q->time)); SET(sidx+3, s48_enter_fixnum(q->x)); SET(sidx+4, s48_enter_fixnum(q->y)); SET(sidx+5, s48_enter_fixnum(q->x_root)); SET(sidx+6, s48_enter_fixnum(q->y_root)); SET(sidx+7, s48_enter_fixnum(q->state)); // now they are different switch (e->type) { case KeyPress : case KeyRelease : { SET(sidx+8, s48_enter_fixnum(q->keycode)); SET(sidx+9, S48_ENTER_BOOLEAN(q->same_screen)); } break; case ButtonPress : case ButtonRelease : { ECAST(q, XButtonEvent); SET(sidx+8, s48_enter_integer(q->button)); SET(sidx+9, S48_ENTER_BOOLEAN(q->same_screen)); } break; case MotionNotify : { ECAST(q, XMotionEvent); SET(sidx+8, s48_enter_fixnum(q->is_hint)); SET(sidx+9, S48_ENTER_BOOLEAN(q->same_screen)); } break; } } break; case EnterNotify : case LeaveNotify : { ECAST(q, XCrossingEvent); SETSIZE(12); SET(sidx+0, SCX_ENTER_WINDOW(q->root)); SET(sidx+1, SCX_ENTER_WINDOW(q->subwindow)); SET(sidx+2, SCX_ENTER_TIME(q->time)); SET(sidx+3, s48_enter_fixnum(q->x)); SET(sidx+4, s48_enter_fixnum(q->y)); SET(sidx+5, s48_enter_fixnum(q->x_root)); SET(sidx+6, s48_enter_fixnum(q->y_root)); SET(sidx+7, s48_enter_integer(q->mode)); SET(sidx+8, s48_enter_integer(q->detail)); SET(sidx+9, S48_ENTER_BOOLEAN(q->same_screen)); SET(sidx+10, S48_ENTER_BOOLEAN(q->focus)); // Elk does this; but why not State_Syms?? SET(sidx+11, s48_enter_integer(q->state)); } break; case FocusIn : case FocusOut : { ECAST(q, XFocusChangeEvent); SETSIZE(2); SET(sidx+0, s48_enter_integer(q->mode)); SET(sidx+1, s48_enter_integer(q->detail)); } break; case KeymapNotify : { ECAST(q, XKeymapEvent); SETSIZE(1); temp = s48_make_vector(32*8, s48_enter_integer(0)); for (i=0; i < 32; i++) { int j; char b = q->key_vector[i]; for (j = 0; j < 8; j++) S48_VECTOR_SET(temp, i*8 + j, (b & (1 << j)) ? 1 : 0); } SET(sidx+0, temp); } break; case Expose : { ECAST(q, XExposeEvent); SETSIZE(5); SET(sidx+0, s48_enter_fixnum(q->x)); SET(sidx+1, s48_enter_fixnum(q->y)); SET(sidx+2, s48_enter_fixnum(q->width)); SET(sidx+3, s48_enter_fixnum(q->height)); SET(sidx+4, s48_enter_fixnum(q->count)); } break; case GraphicsExpose : { ECAST(q, XGraphicsExposeEvent); SETSIZE(7); // the ->window member is only a drawable here! ?? SET(sidx+0, s48_enter_fixnum(q->x)); SET(sidx+1, s48_enter_fixnum(q->y)); SET(sidx+2, s48_enter_fixnum(q->width)); SET(sidx+3, s48_enter_fixnum(q->height)); SET(sidx+4, s48_enter_fixnum(q->count)); SET(sidx+5, s48_enter_integer(q->major_code)); SET(sidx+6, s48_enter_integer(q->minor_code)); } break; case NoExpose : { ECAST(q, XNoExposeEvent); SETSIZE(2); SET(sidx+0, s48_enter_integer(q->major_code)); SET(sidx+1, s48_enter_integer(q->minor_code)); } break; case VisibilityNotify : { ECAST(q, XVisibilityEvent); SETSIZE(1); SET(sidx+0, s48_enter_integer(q->state)); } break; case CreateNotify : { ECAST(q, XCreateWindowEvent); SETSIZE(7); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, s48_enter_fixnum(q->x)); SET(sidx+2, s48_enter_fixnum(q->y)); SET(sidx+3, s48_enter_fixnum(q->width)); SET(sidx+4, s48_enter_fixnum(q->height)); SET(sidx+5, s48_enter_fixnum(q->border_width)); SET(sidx+6, S48_ENTER_BOOLEAN(q->override_redirect)); } break; case DestroyNotify : { ECAST(q, XDestroyWindowEvent); SETSIZE(1); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); } break; case UnmapNotify : { ECAST(q, XUnmapEvent); SETSIZE(2); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, S48_ENTER_BOOLEAN(q->from_configure)); } break; case MapNotify : { ECAST(q, XMapEvent); SETSIZE(2); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, S48_ENTER_BOOLEAN(q->override_redirect)); } break; case MapRequest : { ECAST(q, XMapRequestEvent); SETSIZE(1); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); } break; case ReparentNotify : { ECAST(q, XReparentEvent); SETSIZE(5); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, SCX_ENTER_WINDOW(q->parent)); SET(sidx+2, s48_enter_fixnum(q->x)); SET(sidx+3, s48_enter_fixnum(q->y)); SET(sidx+4, S48_ENTER_BOOLEAN(q->override_redirect)); } break; case ConfigureNotify : { ECAST(q, XConfigureEvent); SETSIZE(8); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, s48_enter_fixnum(q->x)); SET(sidx+2, s48_enter_fixnum(q->y)); SET(sidx+3, s48_enter_fixnum(q->width)); SET(sidx+4, s48_enter_fixnum(q->height)); SET(sidx+5, s48_enter_fixnum(q->border_width)); SET(sidx+6, SCX_ENTER_WINDOW(q->above)); SET(sidx+7, S48_ENTER_BOOLEAN(q->override_redirect)); } break; case ConfigureRequest : { ECAST(q, XConfigureRequestEvent); SETSIZE(9); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, s48_enter_fixnum(q->x)); SET(sidx+2, s48_enter_fixnum(q->y)); SET(sidx+3, s48_enter_fixnum(q->width)); SET(sidx+4, s48_enter_fixnum(q->height)); SET(sidx+5, s48_enter_fixnum(q->border_width)); SET(sidx+6, SCX_ENTER_WINDOW(q->above)); SET(sidx+7, s48_enter_integer(q->detail)); SET(sidx+8, s48_enter_integer(q->value_mask)); } break; case GravityNotify : { ECAST(q, XGravityEvent); SETSIZE(3); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, s48_enter_fixnum(q->x)); SET(sidx+2, s48_enter_fixnum(q->y)); } break; case ResizeRequest : { ECAST(q, XResizeRequestEvent); SETSIZE(2); SET(sidx+0, s48_enter_fixnum(q->width)); SET(sidx+1, s48_enter_fixnum(q->height)); } break; case CirculateRequest : { ECAST(q, XCirculateEvent); SETSIZE(2); SET(sidx+0, SCX_ENTER_WINDOW(q->window)); SET(sidx+1, s48_enter_integer(q->place)); } break; case PropertyNotify : { ECAST(q, XPropertyEvent); SETSIZE(3); SET(sidx+0, SCX_ENTER_ATOM(q->atom)); SET(sidx+1, SCX_ENTER_TIME(q->time)); SET(sidx+2, s48_enter_integer(q->state)); } break; case SelectionClear : { ECAST(q, XSelectionClearEvent); SETSIZE(2); SET(sidx+0, SCX_ENTER_ATOM(q->selection)); SET(sidx+1, SCX_ENTER_TIME(q->time)); } break; case SelectionRequest : { ECAST(q, XSelectionRequestEvent); SETSIZE(5); SET(sidx+0, SCX_ENTER_WINDOW(q->requestor)); SET(sidx+1, SCX_ENTER_ATOM(q->selection)); SET(sidx+2, SCX_ENTER_ATOM(q->target)); SET(sidx+3, SCX_ENTER_ATOM(q->property)); SET(sidx+4, SCX_ENTER_TIME(q->time)); } break; case SelectionNotify : { ECAST(q, XSelectionEvent); SETSIZE(4); SET(sidx+0, SCX_ENTER_ATOM(q->selection)); SET(sidx+1, SCX_ENTER_ATOM(q->target)); SET(sidx+2, SCX_ENTER_ATOM(q->property)); SET(sidx+3, SCX_ENTER_TIME(q->time)); } break; case ColormapNotify : { ECAST(q, XColormapEvent); SETSIZE(3); SET(sidx+0, SCX_ENTER_COLORMAP(q->colormap)); SET(sidx+1, S48_ENTER_BOOLEAN(q->new)); SET(sidx+2, s48_enter_integer(q->state)); } break; case ClientMessage : { ECAST(q, XClientMessageEvent); SETSIZE(3); SET(sidx+0, SCX_ENTER_ATOM(q->message_type)); SET(sidx+1, s48_enter_integer(q->format)); switch (q->format) { case 8 : { temp = s48_make_string(20, (char)0); for (i=0; i < 20; i++) S48_STRING_SET(temp, i, q->data.b[i]); } break; case 16 : { temp = s48_make_vector(10, S48_FALSE); for (i=0; i < 10; i++) S48_VECTOR_SET(temp, i, s48_enter_fixnum(q->data.s[i])); } break; case 32 : { temp = s48_make_vector(5, S48_FALSE); for (i=0; i < 5; i++) S48_VECTOR_SET(temp, i, s48_enter_integer(q->data.l[i])); } break; default : temp = s48_enter_integer(q->format); //?? } SET(sidx+2, temp); } break; case MappingNotify : { ECAST(q, XMappingEvent); SETSIZE(3); SET(sidx+0, s48_enter_integer(q->request)); SET(sidx+1, s48_enter_integer(q->first_keycode)); SET(sidx+2, s48_enter_fixnum(q->count)); } break; default: { SETSIZE(0); } break; } // switch end // XAnyEvent entries { ECAST(q, XAnyEvent); SET(0, s48_enter_integer(q->type)); SET(1, s48_enter_integer(q->serial)); SET(2, S48_ENTER_BOOLEAN(q->send_event)); SET(3, SCX_ENTER_DISPLAY(q->display)); SET(4, SCX_ENTER_WINDOW(q->window)); } // more?? S48_GC_UNPROTECT(); return r; } #define REF(i) S48_VECTOR_REF(v, i) XEvent scx_extract_event(s48_value type, s48_value v) { XEvent e; e.xany.type = s48_extract_integer(REF(0)); e.xany.serial = s48_extract_integer(REF(1)); e.xany.send_event = S48_EXTRACT_BOOLEAN(REF(2)); e.xany.display = SCX_EXTRACT_DISPLAY(REF(3)); switch (s48_extract_integer(type)) { case KeyPress: case KeyRelease: { e.xkey.window = SCX_EXTRACT_WINDOW(REF(4)); e.xkey.root = SCX_EXTRACT_WINDOW(REF(5)); e.xkey.subwindow = SCX_EXTRACT_WINDOW(REF(6)); e.xkey.time = SCX_EXTRACT_TIME(REF(7)); e.xkey.x = s48_extract_integer(REF(8)); e.xkey.y = s48_extract_integer(REF(9)); e.xkey.x_root = s48_extract_integer(REF(10)); e.xkey.y_root = s48_extract_integer(REF(11)); e.xkey.state = s48_extract_integer(REF(12)); e.xkey.keycode = s48_extract_integer(REF(13)); e.xkey.same_screen = S48_EXTRACT_BOOLEAN(REF(14)); } break; case ButtonPress: case ButtonRelease: { e.xbutton.window = SCX_EXTRACT_WINDOW(REF(4)); e.xbutton.root = SCX_EXTRACT_WINDOW(REF(5)); e.xbutton.subwindow = SCX_EXTRACT_WINDOW(REF(6)); e.xbutton.time = SCX_EXTRACT_TIME(REF(7)); e.xbutton.x = s48_extract_integer(REF(8)); e.xbutton.y = s48_extract_integer(REF(9)); e.xbutton.x_root = s48_extract_integer(REF(10)); e.xbutton.y_root = s48_extract_integer(REF(11)); e.xbutton.state = s48_extract_integer(REF(12)); e.xbutton.button = s48_extract_integer(REF(13)); e.xbutton.same_screen = S48_EXTRACT_BOOLEAN(REF(14)); } break; case MotionNotify: { e.xmotion.window = SCX_EXTRACT_WINDOW(REF(4)); e.xmotion.root = SCX_EXTRACT_WINDOW(REF(5)); e.xmotion.subwindow = SCX_EXTRACT_WINDOW(REF(6)); e.xmotion.time = SCX_EXTRACT_TIME(REF(7)); e.xmotion.x = s48_extract_integer(REF(8)); e.xmotion.y = s48_extract_integer(REF(9)); e.xmotion.x_root = s48_extract_integer(REF(10)); e.xmotion.y_root = s48_extract_integer(REF(11)); e.xmotion.state = s48_extract_integer(REF(12)); e.xmotion.is_hint = s48_extract_integer(REF(13)); e.xmotion.same_screen = S48_EXTRACT_BOOLEAN(REF(14)); } break; case EnterNotify: case LeaveNotify: { e.xcrossing.window = SCX_EXTRACT_WINDOW(REF(4)); e.xcrossing.root = SCX_EXTRACT_WINDOW(REF(5)); e.xcrossing.subwindow = SCX_EXTRACT_WINDOW(REF(6)); e.xcrossing.time = SCX_EXTRACT_TIME(REF(7)); e.xcrossing.x = s48_extract_integer(REF(8)); e.xcrossing.y = s48_extract_integer(REF(9)); e.xcrossing.x_root = s48_extract_integer(REF(10)); e.xcrossing.y_root = s48_extract_integer(REF(11)); e.xcrossing.mode = s48_extract_integer(REF(12)); e.xcrossing.detail = s48_extract_integer(REF(13)); e.xcrossing.same_screen = S48_EXTRACT_BOOLEAN(REF(14)); e.xcrossing.focus = S48_EXTRACT_BOOLEAN(REF(15)); e.xcrossing.state = s48_extract_integer(REF(16)); } break; case Expose: { e.xexpose.window = SCX_EXTRACT_WINDOW(REF(4)); e.xexpose.x = s48_extract_integer(REF(5)); e.xexpose.y = s48_extract_integer(REF(6)); e.xexpose.width = s48_extract_integer(REF(7)); e.xexpose.height = s48_extract_integer(REF(8)); e.xexpose.count = s48_extract_integer(REF(9)); } break; case GraphicsExpose: { e.xgraphicsexpose.drawable = SCX_EXTRACT_WINDOW(REF(4)); e.xgraphicsexpose.x = s48_extract_integer(REF(5)); e.xgraphicsexpose.y = s48_extract_integer(REF(6)); e.xgraphicsexpose.width = s48_extract_integer(REF(7)); e.xgraphicsexpose.height = s48_extract_integer(REF(8)); e.xgraphicsexpose.count = s48_extract_integer(REF(9)); e.xgraphicsexpose.major_code = s48_extract_integer(REF(10)); e.xgraphicsexpose.minor_code = s48_extract_integer(REF(11)); } break; case NoExpose: { e.xnoexpose.drawable = SCX_EXTRACT_WINDOW(REF(4)); e.xnoexpose.major_code = s48_extract_integer(REF(5)); e.xnoexpose.minor_code = s48_extract_integer(REF(6)); } break; case VisibilityNotify: { e.xvisibility.window = SCX_EXTRACT_WINDOW(REF(4)); e.xvisibility.state = s48_extract_integer(REF(5)); } break; case CreateNotify: { e.xcreatewindow.window = SCX_EXTRACT_WINDOW(REF(4)); e.xcreatewindow.x = s48_extract_integer(REF(5)); e.xcreatewindow.y = s48_extract_integer(REF(6)); e.xcreatewindow.width = s48_extract_integer(REF(7)); e.xcreatewindow.height = s48_extract_integer(REF(8)); e.xcreatewindow.border_width = s48_extract_integer(REF(9)); e.xcreatewindow.override_redirect = S48_EXTRACT_BOOLEAN(REF(10)); } break; case DestroyNotify: { e.xdestroywindow.event = SCX_EXTRACT_WINDOW(REF(4)); e.xdestroywindow.window = SCX_EXTRACT_WINDOW(REF(5)); } break; case UnmapNotify: { e.xunmap.event = SCX_EXTRACT_WINDOW(REF(4)); e.xunmap.window = SCX_EXTRACT_WINDOW(REF(5)); e.xunmap.from_configure = S48_EXTRACT_BOOLEAN(REF(6)); } break; case MapNotify: { e.xmap.event = SCX_EXTRACT_WINDOW(REF(4)); e.xmap.window = SCX_EXTRACT_WINDOW(REF(5)); e.xmap.override_redirect = S48_EXTRACT_BOOLEAN(REF(6)); } break; case MapRequest: { e.xmaprequest.window = SCX_EXTRACT_WINDOW(REF(4)); e.xmaprequest.parent = SCX_EXTRACT_WINDOW(REF(5)); } break; case ReparentNotify: { e.xreparent.event = SCX_EXTRACT_WINDOW(REF(4)); e.xreparent.window = SCX_EXTRACT_WINDOW(REF(5)); e.xreparent.parent = SCX_EXTRACT_WINDOW(REF(6)); e.xreparent.x = s48_extract_integer(REF(7)); e.xreparent.y = s48_extract_integer(REF(8)); e.xreparent.override_redirect = S48_EXTRACT_BOOLEAN(REF(9)); } break; case ConfigureNotify: { e.xconfigure.event = SCX_EXTRACT_WINDOW(REF(4)); e.xconfigure.window = SCX_EXTRACT_WINDOW(REF(5)); e.xconfigure.x = s48_extract_integer(REF(6)); e.xconfigure.y = s48_extract_integer(REF(7)); e.xconfigure.width = s48_extract_integer(REF(8)); e.xconfigure.height = s48_extract_integer(REF(9)); e.xconfigure.border_width = s48_extract_integer(REF(10)); e.xconfigure.above = SCX_EXTRACT_WINDOW(REF(11)); e.xconfigure.override_redirect = S48_EXTRACT_BOOLEAN(REF(12)); } break; case GravityNotify: { e.xgravity.event = SCX_EXTRACT_WINDOW(REF(4)); e.xgravity.window = SCX_EXTRACT_WINDOW(REF(5)); e.xgravity.x = s48_extract_integer(REF(6)); e.xgravity.y = s48_extract_integer(REF(7)); } break; case ResizeRequest: { e.xresizerequest.window = SCX_EXTRACT_WINDOW(REF(4)); e.xresizerequest.width = s48_extract_integer(REF(5)); e.xresizerequest.height = s48_extract_integer(REF(6)); } break; case ConfigureRequest: { e.xconfigurerequest.parent = SCX_EXTRACT_WINDOW(REF(4)); e.xconfigurerequest.window = SCX_EXTRACT_WINDOW(REF(5)); { XWindowChanges WC; unsigned long mask = Changes_To_XWindowChanges(REF(6), &WC); e.xconfigurerequest.x = WC.x; e.xconfigurerequest.y = WC.y; e.xconfigurerequest.width = WC.width; e.xconfigurerequest.height = WC.height; e.xconfigurerequest.border_width = WC.border_width; e.xconfigurerequest.above = WC.sibling; e.xconfigurerequest.detail = WC.stack_mode; e.xconfigurerequest.value_mask = mask; } } break; case CirculateNotify: { e.xcirculate.event = SCX_EXTRACT_WINDOW(REF(4)); e.xcirculate.window = SCX_EXTRACT_WINDOW(REF(5)); e.xcirculate.place = s48_extract_integer(REF(6)); } break; case CirculateRequest: { e.xcirculaterequest.parent = SCX_EXTRACT_WINDOW(REF(4)); e.xcirculaterequest.window = SCX_EXTRACT_WINDOW(REF(5)); e.xcirculaterequest.place = s48_extract_integer(REF(6)); } break; case PropertyNotify: { e.xproperty.window = SCX_EXTRACT_WINDOW(REF(4)); e.xproperty.atom = SCX_EXTRACT_ATOM(REF(5)); e.xproperty.time = SCX_EXTRACT_TIME(REF(6)); e.xproperty.state = s48_extract_integer(REF(7)); } break; case SelectionClear: { e.xselectionclear.window = SCX_EXTRACT_WINDOW(REF(4)); e.xselectionclear.selection = SCX_EXTRACT_ATOM(REF(5)); e.xselectionclear.time = SCX_EXTRACT_TIME(REF(6)); } break; case SelectionRequest: { e.xselectionrequest.owner = SCX_EXTRACT_WINDOW(REF(4)); e.xselectionrequest.requestor = SCX_EXTRACT_WINDOW(REF(5)); e.xselectionrequest.selection = SCX_EXTRACT_ATOM(REF(6)); e.xselectionrequest.target = SCX_EXTRACT_ATOM(REF(7)); e.xselectionrequest.property = SCX_EXTRACT_ATOM(REF(8)); e.xselectionrequest.time = SCX_EXTRACT_TIME(REF(9)); } break; case SelectionNotify: { e.xselection.requestor = SCX_EXTRACT_WINDOW(REF(4)); e.xselection.selection = SCX_EXTRACT_ATOM(REF(5)); e.xselection.target = SCX_EXTRACT_ATOM(REF(6)); e.xselection.property = SCX_EXTRACT_ATOM(REF(7)); e.xselection.time = SCX_EXTRACT_TIME(REF(8)); } break; case ColormapNotify: { e.xcolormap.window = SCX_EXTRACT_WINDOW(REF(4)); e.xcolormap.colormap = SCX_EXTRACT_COLORMAP(REF(5)); e.xcolormap.new = S48_EXTRACT_BOOLEAN(REF(6)); e.xcolormap.state = s48_extract_integer(REF(7)); } break; case ClientMessage: { e.xclient.window = SCX_EXTRACT_WINDOW(REF(4)); e.xclient.message_type = SCX_EXTRACT_ATOM(REF(5)); e.xclient.format = s48_extract_integer(REF(6)); { s48_value data = REF(7); int i; for (i = 0; i < S48_VECTOR_LENGTH(data); i++) { switch (e.xclient.format) { case 8: if (i < 20) e.xclient.data.b[i] = (char)s48_extract_integer(S48_VECTOR_REF(data, i)); case 16: if (i < 10) e.xclient.data.s[i] = (short)s48_extract_integer(S48_VECTOR_REF(data, i)); case 32: if (i < 5) e.xclient.data.l[i] = (long)s48_extract_integer(S48_VECTOR_REF(data, i)); } } } } break; case MappingNotify: { e.xmapping.window = SCX_EXTRACT_WINDOW(REF(4)); e.xmapping.request = s48_extract_integer(REF(5)); e.xmapping.first_keycode = s48_extract_integer(REF(6)); e.xmapping.count = s48_extract_integer(REF(7)); } break; // Error Event... case KeymapNotify: { e.xkeymap.window = (Window)0; // not used. { s48_value bits = REF(4); int j, bn; char b; for (bn = 0; bn < 32; bn++) { b = 0; for (j = 0; j < 8; j++) b = b | ((char)S48_VECTOR_REF(bits, bn*8 + j) << j); e.xkeymap.key_vector[bn] = b; } } } break; // default ?? } // switch. return e; } s48_value scx_Send_Event(s48_value Xdisplay, s48_value Xwindow, s48_value propagate, s48_value event_mask, s48_value vector, s48_value type) { XEvent e = scx_extract_event(type, vector); Status r = XSendEvent(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_WINDOW(Xwindow), S48_EXTRACT_BOOLEAN(propagate), s48_extract_integer(event_mask), &e); return r ? S48_TRUE : S48_FALSE; } s48_value scx_Next_Event(s48_value Xdisplay) { XEvent e; XNextEvent(SCX_EXTRACT_DISPLAY(Xdisplay), &e); return scx_enter_event(&e); } s48_value scx_Peek_Event(s48_value Xdisplay) { XEvent e; XPeekEvent(SCX_EXTRACT_DISPLAY(Xdisplay), &e); return scx_enter_event(&e); } s48_value scx_Events_Pending(s48_value Xdisplay) { return s48_enter_integer(XPending(SCX_EXTRACT_DISPLAY(Xdisplay))); } s48_value scx_Get_Motion_Events(s48_value Xdisplay, s48_value Xwindow, s48_value from, s48_value to) { int n,i; XTimeCoord *p = XGetMotionEvents(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_WINDOW(Xwindow), SCX_EXTRACT_TIME(from), SCX_EXTRACT_TIME(to), &n); s48_value v = s48_make_vector(n, S48_FALSE); s48_value l = S48_NULL; s48_value t = S48_FALSE; S48_DECLARE_GC_PROTECT(3); S48_GC_PROTECT_3(v, l, t); for (i = 0; i < n; i++) { t = s48_enter_fixnum(p[i].y); l = s48_cons(t, S48_NULL); t = s48_enter_fixnum(p[i].x); l = s48_cons(t, l); t = SCX_ENTER_TIME(p[i].time); l = s48_cons(t, l); S48_VECTOR_SET(v, i, l); } XFree((char*)p); S48_GC_UNPROTECT(); return v; } s48_value scx_add_pending_channel (channel){ int socket_fd; S48_CHECK_CHANNEL(channel); socket_fd = S48_UNSAFE_EXTRACT_FIXNUM(S48_UNSAFE_CHANNEL_OS_INDEX(channel)); if (! s48_add_pending_fd(socket_fd, 1)) // 1 for: yes, is input s48_raise_out_of_memory_error(); return S48_UNSPECIFIC; } void scx_init_event(void) { S48_EXPORT_FUNCTION(scx_Send_Event); S48_EXPORT_FUNCTION(scx_Next_Event); S48_EXPORT_FUNCTION(scx_Peek_Event); S48_EXPORT_FUNCTION(scx_Events_Pending); S48_EXPORT_FUNCTION(scx_Get_Motion_Events); S48_EXPORT_FUNCTION(scx_add_pending_channel); }