+void child_click_events_initialize(void) {
+ if (!child.click_events_init) {
+ yajl_gen_array_open(gen);
+ child_write_output();
+ child.click_events_init = true;
+ }
+}
+
+void child_click_events_key(const char *key) {
+ yajl_gen_string(gen, (const unsigned char *)key, strlen(key));
+}
+
+/*
+ * Generates a click event, if enabled.
+ *
+ */
+void send_block_clicked(int button, const char *name, const char *instance, int x, int y) {
+ if (child.click_events) {
+ child_click_events_initialize();
+
+ yajl_gen_map_open(gen);
+
+ if (name) {
+ child_click_events_key("name");
+ yajl_gen_string(gen, (const unsigned char *)name, strlen(name));
+ }
+
+ if (instance) {
+ child_click_events_key("instance");
+ yajl_gen_string(gen, (const unsigned char *)instance, strlen(instance));
+ }
+
+ child_click_events_key("button");
+ yajl_gen_integer(gen, button);
+
+ child_click_events_key("x");
+ yajl_gen_integer(gen, x);
+
+ child_click_events_key("y");
+ yajl_gen_integer(gen, y);
+
+ yajl_gen_map_close(gen);
+ child_write_output();
+ }
+}
+