let you make an xevent listener for all windows
authorDana Jansens <danakj@orodu.net>
Sat, 28 Jul 2007 20:14:57 +0000 (16:14 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 20 Jan 2008 06:36:56 +0000 (01:36 -0500)
obt/xevent.c
obt/xevent.h

index e770dda..9732c8f 100644 (file)
@@ -85,7 +85,6 @@ void xevent_set_handler(ObtXEventHandler *h, gint type, Window win,
 {
     ObtXEventBinding *b;
 
 {
     ObtXEventBinding *b;
 
-    g_assert(win);
     g_assert(func);
 
     /* make sure we have a spot for the event */
     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;
 
     ObtXEventHandler *h;
     ObtXEventBinding *b;
 
+    h = data;
+
     if (e->type < h->num_event_types) {
     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);
     }
         b = g_hash_table_lookup(h->bindings[e->xany.type], &e->xany.window);
         if (b) b->func(e, b->data);
     }
index 4402ef0..a93a1a6 100644 (file)
@@ -37,6 +37,7 @@ void              xevent_unref(ObtXEventHandler *h);
 void              xevent_register(ObtXEventHandler *h,
                                   struct _ObtMainLoop *loop);
 
 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);
 
 void xevent_set_handler(ObtXEventHandler *h, gint type, Window win,
                         ObtXEventCallback func, gpointer data);