diff options
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r-- | swaybar/i3bar.c | 22 |
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) { | |||
186 | state->buffer_index = cur - state->buffer; | 186 | state->buffer_index = cur - state->buffer; |
187 | return redraw; | 187 | return redraw; |
188 | } | 188 | } |
189 | |||
190 | void i3bar_block_send_click(struct status_line *status, | ||
191 | struct i3bar_block *block, int x, int y, uint32_t button) { | ||
192 | wlr_log(L_DEBUG, "block %s clicked", block->name ? block->name : "(nil)"); | ||
193 | if (!block->name || !status->i3bar_state.click_events) { | ||
194 | return; | ||
195 | } | ||
196 | |||
197 | struct json_object *event_json = json_object_new_object(); | ||
198 | json_object_object_add(event_json, "name", | ||
199 | json_object_new_string(block->name)); | ||
200 | if (block->instance) { | ||
201 | json_object_object_add(event_json, "instance", | ||
202 | json_object_new_string(block->instance)); | ||
203 | } | ||
204 | |||
205 | json_object_object_add(event_json, "button", json_object_new_int(button)); | ||
206 | json_object_object_add(event_json, "x", json_object_new_int(x)); | ||
207 | json_object_object_add(event_json, "y", json_object_new_int(y)); | ||
208 | dprintf(status->write_fd, "%s\n", json_object_to_json_string(event_json)); | ||
209 | json_object_put(event_json); | ||
210 | } | ||