summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-31 13:07:22 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-04-02 11:09:23 -0400
commitee85c918317ec6a685a999db46f692c7d13cdf2a (patch)
tree34afb98bc7fccb8ea6d215c710579e62a459cb62 /include
parentMerge pull request #1684 from swaywm/follow-warp (diff)
downloadsway-ee85c918317ec6a685a999db46f692c7d13cdf2a.tar.gz
sway-ee85c918317ec6a685a999db46f692c7d13cdf2a.tar.zst
sway-ee85c918317ec6a685a999db46f692c7d13cdf2a.zip
Demarcate i3bar JSON into individual updates
Diffstat (limited to 'include')
-rw-r--r--include/swaybar/status_line.h49
1 files changed, 47 insertions, 2 deletions
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h
index 6c595df0..3b93e28f 100644
--- a/include/swaybar/status_line.h
+++ b/include/swaybar/status_line.h
@@ -7,10 +7,52 @@
7 7
8enum status_protocol { 8enum status_protocol {
9 PROTOCOL_UNDEF, 9 PROTOCOL_UNDEF,
10 PROTOCOL_ERROR,
10 PROTOCOL_TEXT, 11 PROTOCOL_TEXT,
11 PROTOCOL_I3BAR, 12 PROTOCOL_I3BAR,
12}; 13};
13 14
15struct text_protocol_state {
16 char *buffer;
17 size_t buffer_size;
18};
19
20enum json_node_type {
21 JSON_NODE_UNKNOWN,
22 JSON_NODE_ARRAY,
23 JSON_NODE_STRING,
24};
25
26struct i3bar_protocol_state {
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];
35};
36
37struct i3bar_block {
38 struct wl_list link;
39 char *full_text, *short_text, *align;
40 bool urgent;
41 uint32_t color;
42 int min_width;
43 char *name, *instance;
44 bool separator;
45 int separator_block_width;
46 bool markup;
47 // Airblader features
48 uint32_t background;
49 uint32_t border;
50 int border_top;
51 int border_bottom;
52 int border_left;
53 int border_right;
54};
55
14struct status_line { 56struct status_line {
15 pid_t pid; 57 pid_t pid;
16 int read_fd, write_fd; 58 int read_fd, write_fd;
@@ -18,13 +60,16 @@ struct status_line {
18 60
19 enum status_protocol protocol; 61 enum status_protocol protocol;
20 const char *text; 62 const char *text;
63 struct wl_list blocks; // i3bar_block::link
21 64
22 char *buffer; 65 struct text_protocol_state text_state;
23 size_t buffer_size; 66 struct i3bar_protocol_state i3bar_state;
24}; 67};
25 68
26struct status_line *status_line_init(char *cmd); 69struct status_line *status_line_init(char *cmd);
27void status_line_free(struct status_line *status); 70void status_line_free(struct status_line *status);
28bool handle_status_readable(struct status_line *status); 71bool handle_status_readable(struct status_line *status);
72int i3bar_readable(struct status_line *status);
73void status_error(struct status_line *status, const char *text);
29 74
30#endif 75#endif