]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/parse_json_header.c
Merge branch 'master' into next
[i3/i3] / i3bar / src / parse_json_header.c
index 80ec5af8f78d4de61bda169e442b5552ac57631e..86afab3a2b64cd0f280837eb55912f6e36223f0d 100644 (file)
@@ -31,6 +31,7 @@ static enum {
     KEY_VERSION,
     KEY_STOP_SIGNAL,
     KEY_CONT_SIGNAL,
+    KEY_CLICK_EVENTS,
     NO_KEY
 } current_key;
 
@@ -54,6 +55,21 @@ static int header_integer(void *ctx, long val) {
         default:
             break;
     }
+
+    return 1;
+}
+
+static int header_boolean(void *ctx, int val) {
+    i3bar_child *child = ctx;
+
+    switch (current_key) {
+        case KEY_CLICK_EVENTS:
+            child->click_events = val;
+            break;
+        default:
+            break;
+    }
+
     return 1;
 }
 
@@ -71,24 +87,12 @@ static int header_map_key(void *ctx, const unsigned char *stringval, unsigned in
         current_key = KEY_STOP_SIGNAL;
     } else if (CHECK_KEY("cont_signal")) {
         current_key = KEY_CONT_SIGNAL;
+    } else if (CHECK_KEY("click_events")) {
+        current_key = KEY_CLICK_EVENTS;
     }
     return 1;
 }
 
-static yajl_callbacks version_callbacks = {
-    NULL, /* null */
-    NULL, /* boolean */
-    &header_integer,
-    NULL, /* double */
-    NULL, /* number */
-    NULL, /* string */
-    NULL, /* start_map */
-    &header_map_key,
-    NULL, /* end_map */
-    NULL, /* start_array */
-    NULL /* end_array */
-};
-
 static void child_init(i3bar_child *child) {
     child->version = 0;
     child->stop_signal = SIGSTOP;
@@ -104,6 +108,12 @@ static void child_init(i3bar_child *child) {
  *
  */
 void parse_json_header(i3bar_child *child, const unsigned char *buffer, int length, unsigned int *consumed) {
+    static yajl_callbacks version_callbacks = {
+        .yajl_boolean = header_boolean,
+        .yajl_integer = header_integer,
+        .yajl_map_key = &header_map_key,
+    };
+
     child_init(child);
 
     current_key = NO_KEY;