]> git.sur5r.net Git - i3/i3/commitdiff
Implement cleaning up the list of ignored events
authorMichael Stapelberg <michael+x200@stapelberg.de>
Wed, 11 Mar 2009 19:06:30 +0000 (20:06 +0100)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Wed, 11 Mar 2009 19:06:30 +0000 (20:06 +0100)
src/handlers.c

index e80ae8ac572c3dda8592fd718ba83a26223fd796..0a7b520b6c1b2b06962bcbd80999a8650aa37297 100644 (file)
@@ -35,7 +35,7 @@
 /* After mapping/unmapping windows, a notify event is generated. However, we don’t want it,
    since it’d trigger an infinite loop of switching between the different windows when
    changing workspaces */
-SLIST_HEAD(ignore_head, Ignore_Event) ignore_events;
+static SLIST_HEAD(ignore_head, Ignore_Event) ignore_events;
 
 static void add_ignore_event(const int sequence) {
         struct Ignore_Event *event = smalloc(sizeof(struct Ignore_Event));
@@ -54,7 +54,17 @@ static void add_ignore_event(const int sequence) {
  */
 static bool event_is_ignored(const int sequence) {
         struct Ignore_Event *event;
-        /* TODO: cleanup this list */
+        time_t now = time(NULL);
+        for (event = SLIST_FIRST(&ignore_events); event != SLIST_END(&ignore_events);) {
+                if ((now - event->added) > 5) {
+                        LOG("Entry is older than five seconds, cleaning up\n");
+                        struct Ignore_Event *save = event;
+                        event = SLIST_NEXT(event, ignore_events);
+                        SLIST_REMOVE(&ignore_events, save, Ignore_Event, ignore_events);
+                        free(save);
+                } else event = SLIST_NEXT(event, ignore_events);
+        }
+
         SLIST_FOREACH(event, &ignore_events, ignore_events) {
                 if (event->sequence == sequence) {
                         LOG("Ignoring event (sequence %d)\n", sequence);