[Xcb-commit] event wm
Jamey Sharp
jamey at kemper.freedesktop.org
Mon Jan 28 14:35:57 PST 2008
event/events.c | 12 +++++++++++-
event/xcb_event.h | 3 ++-
wm/xcbwm-test.c | 4 ++--
3 files changed, 15 insertions(+), 4 deletions(-)
New commits:
commit 66728b2d13f3eee94230038c8f8eb236c20b9525
Author: Arnaud Fontaine <arnaud at andesi.org>
Date: Mon Jan 28 14:26:05 2008 -0800
Add xcb_poll_for_event_loop and rename xcb_event_loop to match.
I'm currently porting Awesome[0] from Xlib to XCB as a school project for
my bachelor. I discussed with Vincent about adding a non-blocking
xcb_event_loop on IRC because I had to write one for Awesome and wondered
if this kind of function could be added to xcb-util.
[0] http://awesome.naquadah.org
Signed-off-by: Jamey Sharp <jamey at minilop.net>
diff --git a/event/events.c b/event/events.c
index 2900bd3..354346a 100644
--- a/event/events.c
+++ b/event/events.c
@@ -62,7 +62,7 @@ static int handle_event(xcb_event_handlers_t *evenths, xcb_generic_event_t *even
return 0;
}
-void xcb_event_loop(xcb_event_handlers_t *evenths)
+void xcb_wait_for_event_loop(xcb_event_handlers_t *evenths)
{
xcb_generic_event_t *event;
while((event = xcb_wait_for_event(evenths->c)))
@@ -72,6 +72,16 @@ void xcb_event_loop(xcb_event_handlers_t *evenths)
}
}
+void xcb_poll_for_event_loop(xcb_event_handlers_t *evenths)
+{
+ xcb_generic_event_t *event;
+ while ((event = xcb_poll_for_event(evenths->c)))
+ {
+ handle_event(evenths, event);
+ free(event);
+ }
+}
+
static void set_handler(xcb_generic_event_handler_t handler, void *data, xcb_event_handler_t *place)
{
xcb_event_handler_t eventh = { handler, data };
diff --git a/event/xcb_event.h b/event/xcb_event.h
index deb7ba8..9122893 100644
--- a/event/xcb_event.h
+++ b/event/xcb_event.h
@@ -14,7 +14,8 @@ xcb_event_handlers_t *xcb_alloc_event_handlers(xcb_connection_t *c);
void xcb_free_event_handlers(xcb_event_handlers_t *evenths);
xcb_connection_t *xcb_get_xcb_connection(xcb_event_handlers_t *evenths);
-void xcb_event_loop(xcb_event_handlers_t *evenths);
+void xcb_wait_for_event_loop(xcb_event_handlers_t *evenths);
+void xcb_poll_for_event_loop(xcb_event_handlers_t *evenths);
typedef int (*xcb_generic_event_handler_t)(void *data, xcb_connection_t *c, xcb_generic_event_t *event);
typedef int (*xcb_generic_error_handler_t)(void *data, xcb_connection_t *c, xcb_generic_error_t *error);
diff --git a/wm/xcbwm-test.c b/wm/xcbwm-test.c
index 4d8be5d..c928d7a 100644
--- a/wm/xcbwm-test.c
+++ b/wm/xcbwm-test.c
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
if(TEST_THREADS)
{
- pthread_create(&event_thread, 0, (void *(*)(void *))xcb_event_loop, evenths);
+ pthread_create(&event_thread, 0, (void *(*)(void *))xcb_wait_for_event_loop, evenths);
}
root = xcb_aux_get_screen(c, screen_nbr)->root;
@@ -223,7 +223,7 @@ int main(int argc, char **argv)
if(TEST_THREADS)
pthread_join(event_thread, 0);
else
- xcb_event_loop(evenths);
+ xcb_wait_for_event_loop(evenths);
exit(0);
/*NOTREACHED*/
More information about the xcb-commit
mailing list