aboutsummaryrefslogtreecommitdiffstats
path: root/include/swaybar/status_line.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/swaybar/status_line.h')
-rw-r--r--include/swaybar/status_line.h78
1 files changed, 47 insertions, 31 deletions
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h
index 0664ddee..3538f49c 100644
--- a/include/swaybar/status_line.h
+++ b/include/swaybar/status_line.h
@@ -1,25 +1,44 @@
1#ifndef _SWAYBAR_STATUS_LINE_H 1#ifndef _SWAYBAR_STATUS_LINE_H
2#define _SWAYBAR_STATUS_LINE_H 2#define _SWAYBAR_STATUS_LINE_H
3
4#include <stdint.h> 3#include <stdint.h>
4#include <stdio.h>
5#include <stdbool.h> 5#include <stdbool.h>
6
7#include "list.h"
8#include "bar.h" 6#include "bar.h"
9 7
10typedef enum {UNDEF, TEXT, I3BAR} command_protocol; 8enum status_protocol {
9 PROTOCOL_UNDEF,
10 PROTOCOL_ERROR,
11 PROTOCOL_TEXT,
12 PROTOCOL_I3BAR,
13};
14
15struct text_protocol_state {
16 char *buffer;
17 size_t buffer_size;
18};
11 19
12struct status_line { 20enum json_node_type {
13 list_t *block_line; 21 JSON_NODE_UNKNOWN,
14 const char *text_line; 22 JSON_NODE_ARRAY,
15 command_protocol protocol; 23 JSON_NODE_STRING,
24};
25
26struct i3bar_protocol_state {
16 bool click_events; 27 bool click_events;
28 char *buffer;
29 size_t buffer_size;
30 size_t buffer_index;
31 const char *current_node;
32 bool escape;
33 size_t depth;
34 enum json_node_type nodes[16];
17}; 35};
18 36
19struct status_block { 37struct i3bar_block {
38 struct wl_list link;
20 char *full_text, *short_text, *align; 39 char *full_text, *short_text, *align;
21 bool urgent; 40 bool urgent;
22 uint32_t color; 41 uint32_t *color;
23 int min_width; 42 int min_width;
24 char *name, *instance; 43 char *name, *instance;
25 bool separator; 44 bool separator;
@@ -32,30 +51,27 @@ struct status_block {
32 int border_bottom; 51 int border_bottom;
33 int border_left; 52 int border_left;
34 int border_right; 53 int border_right;
35
36 // Set during rendering
37 int x;
38 int width;
39}; 54};
40 55
41/** 56struct status_line {
42 * Initialize status line struct. 57 pid_t pid;
43 */ 58 int read_fd, write_fd;
44struct status_line *init_status_line(); 59 FILE *read, *write;
45 60
46/** 61 enum status_protocol protocol;
47 * handle status line activity. 62 const char *text;
48 */ 63 struct wl_list blocks; // i3bar_block::link
49bool handle_status_line(struct bar *bar);
50 64
51/** 65 struct text_protocol_state text_state;
52 * Handle mouse clicks. 66 struct i3bar_protocol_state i3bar_state;
53 */ 67};
54bool status_line_mouse_event(struct bar *bar, int x, int y, uint32_t button);
55 68
56/** 69struct status_line *status_line_init(char *cmd);
57 * Free status line struct. 70void status_error(struct status_line *status, const char *text);
58 */ 71bool status_handle_readable(struct status_line *status);
59void free_status_line(struct status_line *line); 72void status_line_free(struct status_line *status);
73bool i3bar_handle_readable(struct status_line *status);
74void i3bar_block_send_click(struct status_line *status,
75 struct i3bar_block *block, int x, int y, uint32_t button);
60 76
61#endif /* _SWAYBAR_STATUS_LINE_H */ 77#endif