From 8439c393d8c1dfb7db5cebd57d2e1e084e60234a Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 28 Jul 2007 16:14:57 -0400 Subject: [PATCH] let you make an xevent listener for all windows --- obt/xevent.c | 9 +++++++-- obt/xevent.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/obt/xevent.c b/obt/xevent.c index e770ddae..9732c8f9 100644 --- a/obt/xevent.c +++ b/obt/xevent.c @@ -85,7 +85,6 @@ void xevent_set_handler(ObtXEventHandler *h, gint type, Window win, { ObtXEventBinding *b; - g_assert(win); g_assert(func); /* make sure we have a spot for the event */ @@ -119,8 +118,14 @@ static void xevent_handler(const XEvent *e, gpointer data) ObtXEventHandler *h; ObtXEventBinding *b; + h = data; + if (e->type < h->num_event_types) { - h = data; + const gint all = OBT_XEVENT_ALL_WINDOWS; + /* run the all_windows handler first */ + b = g_hash_table_lookup(h->bindings[e->xany.type], &all); + if (b) b->func(e, b->data); + /* then run the per-window handler */ b = g_hash_table_lookup(h->bindings[e->xany.type], &e->xany.window); if (b) b->func(e, b->data); } diff --git a/obt/xevent.h b/obt/xevent.h index 4402ef0e..a93a1a61 100644 --- a/obt/xevent.h +++ b/obt/xevent.h @@ -37,6 +37,7 @@ void xevent_unref(ObtXEventHandler *h); void xevent_register(ObtXEventHandler *h, struct _ObtMainLoop *loop); +#define OBT_XEVENT_ALL_WINDOWS None void xevent_set_handler(ObtXEventHandler *h, gint type, Window win, ObtXEventCallback func, gpointer data); -- 2.45.2