summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-09-18 22:52:36 -0400
committerLibravatar GitHub <noreply@github.com>2018-09-18 22:52:36 -0400
commitcdce604d8e166ae905b394306fece4e7f035cedd (patch)
treefbbd9612c860fb60bfdee882346f843668b1b8fa /include
parentMerge pull request #2652 from emersion/swaybar-output-names (diff)
parentswaybar: only free tokener when using i3bar protocol (diff)
downloadsway-cdce604d8e166ae905b394306fece4e7f035cedd.tar.gz
sway-cdce604d8e166ae905b394306fece4e7f035cedd.tar.zst
sway-cdce604d8e166ae905b394306fece4e7f035cedd.zip
Merge pull request #2640 from ianyfan/swaybar
Overhaul swaybar protocol handling (+fixes)
Diffstat (limited to 'include')
-rw-r--r--include/swaybar/event_loop.h4
-rw-r--r--include/swaybar/status_line.h32
2 files changed, 10 insertions, 26 deletions
diff --git a/include/swaybar/event_loop.h b/include/swaybar/event_loop.h
index 99f6ed36..47be5b79 100644
--- a/include/swaybar/event_loop.h
+++ b/include/swaybar/event_loop.h
@@ -19,8 +19,8 @@ bool remove_event(int fd);
19bool remove_timer(timer_t timer); 19bool remove_timer(timer_t timer);
20 20
21// Blocks and returns after sending callbacks 21// Blocks and returns after sending callbacks
22void event_loop_poll(); 22void event_loop_poll(void);
23 23
24void init_event_loop(); 24void init_event_loop(void);
25 25
26#endif 26#endif
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h
index 150267cd..d3eabdf6 100644
--- a/include/swaybar/status_line.h
+++ b/include/swaybar/status_line.h
@@ -1,5 +1,6 @@
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#include <json-c/json.h>
3#include <stdint.h> 4#include <stdint.h>
4#include <stdio.h> 5#include <stdio.h>
5#include <stdbool.h> 6#include <stdbool.h>
@@ -12,28 +13,6 @@ enum status_protocol {
12 PROTOCOL_I3BAR, 13 PROTOCOL_I3BAR,
13}; 14};
14 15
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 { 16struct i3bar_block {
38 struct wl_list link; 17 struct wl_list link;
39 int ref_count; 18 int ref_count;
@@ -63,8 +42,13 @@ struct status_line {
63 const char *text; 42 const char *text;
64 struct wl_list blocks; // i3bar_block::link 43 struct wl_list blocks; // i3bar_block::link
65 44
66 struct text_protocol_state text_state; 45 bool click_events;
67 struct i3bar_protocol_state i3bar_state; 46 char *buffer;
47 size_t buffer_size;
48 size_t buffer_index;
49 bool started;
50 bool expecting_comma;
51 json_tokener *tokener;
68}; 52};
69 53
70struct status_line *status_line_init(char *cmd); 54struct status_line *status_line_init(char *cmd);