2003-03-10 21:47:38 -05:00
|
|
|
/* Copyright 2001-2003 by Norbert Freudemann, David Frese */
|
2002-02-25 08:10:11 -05:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
#include "xlib.h"
|
2002-02-25 08:10:11 -05:00
|
|
|
|
2003-04-25 14:52:58 -04:00
|
|
|
s48_value scx_queued_mode_binding = S48_FALSE;
|
|
|
|
#define scx_extract_queued_mode(x) S48_EXTRACT_ENUM(x, scx_queued_mode_binding)
|
2002-02-25 08:10:11 -05:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Events_Queued(s48_value display, s48_value mode) {
|
|
|
|
int r = XEventsQueued(scx_extract_display(display),
|
|
|
|
scx_extract_queued_mode(mode));
|
|
|
|
return s48_enter_integer(r);
|
2002-02-25 08:10:11 -05:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Events_Pending(s48_value display) {
|
|
|
|
return s48_enter_integer(XPending(scx_extract_display(display)));
|
2002-02-25 08:10:11 -05:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Next_Event(s48_value display) {
|
2001-07-09 09:39:59 -04:00
|
|
|
XEvent e;
|
2003-03-10 21:47:38 -05:00
|
|
|
XNextEvent(scx_extract_display(display), &e);
|
2001-07-31 10:51:21 -04:00
|
|
|
return scx_enter_event(&e);
|
2001-07-09 09:39:59 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Peek_Event(s48_value display) {
|
2001-07-09 09:39:59 -04:00
|
|
|
XEvent e;
|
2003-03-10 21:47:38 -05:00
|
|
|
XPeekEvent(scx_extract_display(display), &e);
|
2001-07-31 10:51:21 -04:00
|
|
|
return scx_enter_event(&e);
|
2001-07-09 09:39:59 -04:00
|
|
|
}
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Get_Motion_Events(s48_value display, s48_value window,
|
|
|
|
s48_value from, s48_value to) {
|
2001-07-19 11:32:59 -04:00
|
|
|
int n,i;
|
2003-03-10 21:47:38 -05:00
|
|
|
XTimeCoord *p = XGetMotionEvents(scx_extract_display(display),
|
|
|
|
scx_extract_window(window),
|
|
|
|
scx_extract_time(from),
|
|
|
|
scx_extract_time(to),
|
2001-07-19 11:32:59 -04:00
|
|
|
&n);
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value l = S48_NULL, t = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
2002-02-04 08:40:22 -05:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_GC_PROTECT_2(l, t);
|
|
|
|
for (i = n-1; i >= 0; i--) {
|
|
|
|
t = s48_cons(s48_enter_fixnum(p[i].x), s48_enter_fixnum(p[i].y));
|
|
|
|
t = s48_cons(scx_enter_time(p[i].time), t);
|
|
|
|
l = s48_cons(t, l);
|
2001-07-19 11:32:59 -04:00
|
|
|
}
|
|
|
|
XFree((char*)p);
|
2002-02-04 08:40:22 -05:00
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
return l;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
2001-07-09 09:39:59 -04:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value scx_Send_Event(s48_value display, s48_value window,
|
|
|
|
s48_value propagate,
|
|
|
|
s48_value event_mask, s48_value event) {
|
|
|
|
XEvent e;
|
2003-04-17 10:53:27 -04:00
|
|
|
Status r;
|
2003-03-10 21:47:38 -05:00
|
|
|
scx_extract_event(event, &e);
|
|
|
|
|
2003-04-17 10:53:27 -04:00
|
|
|
r = XSendEvent(scx_extract_display(display),
|
|
|
|
scx_extract_window(window),
|
|
|
|
S48_EXTRACT_BOOLEAN(propagate),
|
|
|
|
scx_extract_event_mask(event_mask),
|
|
|
|
&e);
|
2003-03-10 21:47:38 -05:00
|
|
|
return r ? S48_TRUE : S48_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
s48_value scx_add_pending_channel(channel) {
|
2001-12-04 09:18:57 -05:00
|
|
|
int socket_fd;
|
|
|
|
S48_CHECK_CHANNEL(channel);
|
|
|
|
socket_fd = S48_UNSAFE_EXTRACT_FIXNUM(S48_UNSAFE_CHANNEL_OS_INDEX(channel));
|
|
|
|
|
2003-04-17 10:53:27 -04:00
|
|
|
if (! s48_add_pending_fd(socket_fd, 1)) /* 1 for: yes, is input */
|
2001-12-04 09:18:57 -05:00
|
|
|
s48_raise_out_of_memory_error();
|
|
|
|
|
|
|
|
return S48_UNSPECIFIC;
|
|
|
|
}
|
2003-03-10 21:47:38 -05:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
void scx_init_event(void) {
|
2003-04-25 14:52:58 -04:00
|
|
|
SCX_PRO_IMP(scx_queued_mode_binding, "scx-queued-mode");
|
|
|
|
|
2002-03-17 10:44:45 -05:00
|
|
|
S48_EXPORT_FUNCTION(scx_Events_Queued);
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_EXPORT_FUNCTION(scx_Events_Pending);
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_EXPORT_FUNCTION(scx_Next_Event);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Peek_Event);
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_EXPORT_FUNCTION(scx_Get_Motion_Events);
|
2003-03-10 21:47:38 -05:00
|
|
|
S48_EXPORT_FUNCTION(scx_Send_Event);
|
2001-12-04 09:18:57 -05:00
|
|
|
S48_EXPORT_FUNCTION(scx_add_pending_channel);
|
2001-07-09 09:39:59 -04:00
|
|
|
}
|