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) {
|
2003-05-04 11:19:39 -04:00
|
|
|
int r;
|
2003-05-02 09:33:34 -04:00
|
|
|
S48_DECLARE_GC_PROTECT_2(display, mode);
|
2003-05-04 11:19:39 -04:00
|
|
|
r = XEventsQueued(scx_extract_display(display),
|
|
|
|
scx_extract_queued_mode(mode));
|
2003-05-02 09:33:34 -04:00
|
|
|
S48_GC_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-05-02 09:33:34 -04:00
|
|
|
XTimeCoord* p;
|
2003-03-10 21:47:38 -05:00
|
|
|
s48_value l = S48_NULL, t = S48_FALSE;
|
2003-05-02 09:33:34 -04:00
|
|
|
S48_DECLARE_GC_PROTECT_6(display, window, from, to, l, t);
|
|
|
|
p = XGetMotionEvents(scx_extract_display(display),
|
|
|
|
scx_extract_window(window),
|
|
|
|
scx_extract_time(from),
|
|
|
|
scx_extract_time(to),
|
|
|
|
&n);
|
2002-02-04 08:40:22 -05:00
|
|
|
|
2003-03-10 21:47:38 -05:00
|
|
|
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
|
|
|
|
2003-05-02 09:33:34 -04:00
|
|
|
S48_GC_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-05-02 09:33:34 -04:00
|
|
|
S48_DECLARE_GC_PROTECT_5(display, window, propagate, event_mask, event);
|
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-05-02 09:33:34 -04:00
|
|
|
S48_GC_RETURN(r ? S48_TRUE : S48_FALSE);
|
2001-12-04 09:18:57 -05:00
|
|
|
}
|
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-07-09 09:39:59 -04:00
|
|
|
}
|