]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/outputs.c
Ensure all *.[ch] files include config.h
[i3/i3] / i3bar / src / outputs.c
index d0d175ca07ad42fb7554a883c836f64f70a104ee..480c00be7dd90a1b9e500b3074e87888da64bcbc 100644 (file)
@@ -7,6 +7,8 @@
  * outputs.c: Maintaining the outputs list
  *
  */
+#include "common.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -15,8 +17,6 @@
 #include <yajl/yajl_parse.h>
 #include <yajl/yajl_version.h>
 
-#include "common.h"
-
 /* A datatype to pass through the callbacks to save the state */
 struct outputs_json_params {
     struct outputs_head *outputs;
@@ -144,10 +144,16 @@ static int outputs_start_map_cb(void *params_) {
     if (params->cur_key == NULL) {
         new_output = smalloc(sizeof(i3_output));
         new_output->name = NULL;
+        new_output->active = false;
+        new_output->primary = false;
+        new_output->visible = false;
         new_output->ws = 0,
+        new_output->statusline_width = 0;
+        new_output->statusline_short_text = false;
         memset(&new_output->rect, 0, sizeof(rect));
         memset(&new_output->bar, 0, sizeof(surface_t));
         memset(&new_output->buffer, 0, sizeof(surface_t));
+        memset(&new_output->statusline_buffer, 0, sizeof(surface_t));
 
         new_output->workspaces = smalloc(sizeof(struct ws_head));
         TAILQ_INIT(new_output->workspaces);
@@ -265,7 +271,7 @@ void parse_outputs_json(char *json) {
 
     state = yajl_parse(handle, (const unsigned char *)json, strlen(json));
 
-    /* FIXME: Propper errorhandling for JSON-parsing */
+    /* FIXME: Proper errorhandling for JSON-parsing */
     switch (state) {
         case yajl_status_ok:
             break;
@@ -296,3 +302,17 @@ i3_output *get_output_by_name(char *name) {
 
     return walk;
 }
+
+/*
+ * Returns true if the output has the currently focused workspace
+ *
+ */
+bool output_has_focus(i3_output *output) {
+    i3_ws *ws_walk;
+    TAILQ_FOREACH(ws_walk, output->workspaces, tailq) {
+        if (ws_walk->focused) {
+            return true;
+        }
+    }
+    return false;
+}