]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/ipc.c
Merge branch 'next'
[i3/i3] / i3bar / src / ipc.c
index fc8c6492d9b9759211142aa7450740ddf1225e5d..faab8e102890a84422b6fc8c5231d71c58c245b3 100644 (file)
@@ -84,6 +84,8 @@ void got_bar_config(char *reply) {
      * workspaces. Everything else (creating the bars, showing the right workspace-
      * buttons and more) is taken care of by the event-drivenness of the code */
     i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
+
+    free_colors(&(config.colors));
     parse_config_json(reply);
 
     /* Now we can actually use 'config', so let's subscribe to the appropriate
@@ -97,7 +99,6 @@ void got_bar_config(char *reply) {
 
     /* Resolve color strings to colorpixels and save them, then free the strings. */
     init_colors(&(config.colors));
-    free_colors(&(config.colors));
 
     /* The name of this function is actually misleading. Even if no command is
      * specified, this function initiates the watchers to listen on stdin and
@@ -138,10 +139,22 @@ void got_output_event(char *event) {
     }
 }
 
+/*
+ * Called, when a mode-event arrives (i3 changed binding mode).
+ *
+ */
+void got_mode_event(char *event) {
+    DLOG("Got Mode Event!\n");
+    parse_mode_json(event);
+    draw_bars(false);
+}
+
+
 /* Data-structure to easily call the reply-handlers later */
 handler_t event_handlers[] = {
     &got_workspace_event,
-    &got_output_event
+    &got_output_event,
+    &got_mode_event
 };
 
 /*
@@ -297,8 +310,8 @@ void destroy_connection(void) {
  */
 void subscribe_events(void) {
     if (config.disable_ws) {
-        i3_send_msg(I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[ \"output\" ]");
+        i3_send_msg(I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[ \"output\", \"mode\" ]");
     } else {
-        i3_send_msg(I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[ \"workspace\", \"output\" ]");
+        i3_send_msg(I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[ \"workspace\", \"output\", \"mode\" ]");
     }
 }