aboutsummaryrefslogtreecommitdiff
path: root/swaybar/i3bar.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-03-31 14:58:30 -0400
committerDrew DeVault <sir@cmpwn.com>2018-04-02 11:09:23 -0400
commit0cbd2a4f492b758f495af9f3ec4899dffe8d57d4 (patch)
tree24818f1a3c3d8c9ffe6bba61c2caa4685b7aba91 /swaybar/i3bar.c
parent333dbcbe72b6af95573e374b66ad6ab63f274299 (diff)
Send click events for i3bar blocks
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r--swaybar/i3bar.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index 41b71164..5e98c4aa 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -186,3 +186,25 @@ bool i3bar_handle_readable(struct status_line *status) {
state->buffer_index = cur - state->buffer;
return redraw;
}
+
+void i3bar_block_send_click(struct status_line *status,
+ struct i3bar_block *block, int x, int y, uint32_t button) {
+ wlr_log(L_DEBUG, "block %s clicked", block->name ? block->name : "(nil)");
+ if (!block->name || !status->i3bar_state.click_events) {
+ return;
+ }
+
+ struct json_object *event_json = json_object_new_object();
+ json_object_object_add(event_json, "name",
+ json_object_new_string(block->name));
+ if (block->instance) {
+ json_object_object_add(event_json, "instance",
+ json_object_new_string(block->instance));
+ }
+
+ json_object_object_add(event_json, "button", json_object_new_int(button));
+ json_object_object_add(event_json, "x", json_object_new_int(x));
+ json_object_object_add(event_json, "y", json_object_new_int(y));
+ dprintf(status->write_fd, "%s\n", json_object_to_json_string(event_json));
+ json_object_put(event_json);
+}