diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-10-02 14:04:48 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-10-02 14:05:51 +0100 |
commit | 65593f49bc1e9061e93b6ca1bb9ca5b8b9314721 (patch) | |
tree | c2c92b7a400a669b7232b825bb73ddbe980f2802 | |
parent | Merge pull request #2745 from RyanDwyer/fix-focus-inactive-on-destroy (diff) | |
download | sway-65593f49bc1e9061e93b6ca1bb9ca5b8b9314721.tar.gz sway-65593f49bc1e9061e93b6ca1bb9ca5b8b9314721.tar.zst sway-65593f49bc1e9061e93b6ca1bb9ca5b8b9314721.zip |
swaybar: add leading comma to click event JSON
-rw-r--r-- | include/swaybar/status_line.h | 1 | ||||
-rw-r--r-- | swaybar/i3bar.c | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h index e6c7dac2..ca88b0c5 100644 --- a/include/swaybar/status_line.h +++ b/include/swaybar/status_line.h | |||
@@ -23,6 +23,7 @@ struct status_line { | |||
23 | struct wl_list blocks; // i3bar_block::link | 23 | struct wl_list blocks; // i3bar_block::link |
24 | 24 | ||
25 | bool click_events; | 25 | bool click_events; |
26 | bool clicked; | ||
26 | char *buffer; | 27 | char *buffer; |
27 | size_t buffer_size; | 28 | size_t buffer_size; |
28 | size_t buffer_index; | 29 | size_t buffer_index; |
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index 8e9b038b..1d754808 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c | |||
@@ -260,7 +260,7 @@ bool i3bar_handle_readable(struct status_line *status) { | |||
260 | 260 | ||
261 | enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, | 261 | enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, |
262 | struct i3bar_block *block, int x, int y, enum x11_button button) { | 262 | struct i3bar_block *block, int x, int y, enum x11_button button) { |
263 | wlr_log(WLR_DEBUG, "block %s clicked", block->name ? block->name : "(nil)"); | 263 | wlr_log(WLR_DEBUG, "block %s clicked", block->name); |
264 | if (!block->name || !status->click_events) { | 264 | if (!block->name || !status->click_events) { |
265 | return HOTSPOT_PROCESS; | 265 | return HOTSPOT_PROCESS; |
266 | } | 266 | } |
@@ -276,10 +276,11 @@ enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, | |||
276 | json_object_object_add(event_json, "button", json_object_new_int(button)); | 276 | json_object_object_add(event_json, "button", json_object_new_int(button)); |
277 | json_object_object_add(event_json, "x", json_object_new_int(x)); | 277 | json_object_object_add(event_json, "x", json_object_new_int(x)); |
278 | json_object_object_add(event_json, "y", json_object_new_int(y)); | 278 | json_object_object_add(event_json, "y", json_object_new_int(y)); |
279 | if (dprintf(status->write_fd, "%s,\n", | 279 | if (dprintf(status->write_fd, "%s%s\n", status->clicked ? "," : "", |
280 | json_object_to_json_string(event_json)) < 0) { | 280 | json_object_to_json_string(event_json)) < 0) { |
281 | status_error(status, "[failed to write click event]"); | 281 | status_error(status, "[failed to write click event]"); |
282 | } | 282 | } |
283 | status->clicked = true; | ||
283 | json_object_put(event_json); | 284 | json_object_put(event_json); |
284 | return HOTSPOT_IGNORE; | 285 | return HOTSPOT_IGNORE; |
285 | } | 286 | } |