summaryrefslogtreecommitdiffstats
path: root/swaybar/i3bar.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r--swaybar/i3bar.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index 3ea74e13..116c8f6e 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -259,8 +259,34 @@ bool i3bar_handle_readable(struct status_line *status) {
259 } 259 }
260} 260}
261 261
262static uint32_t event_to_x11_button(uint32_t event) {
263 switch (event) {
264 case BTN_LEFT:
265 return 1;
266 case BTN_MIDDLE:
267 return 2;
268 case BTN_RIGHT:
269 return 3;
270 case SWAY_SCROLL_UP:
271 return 4;
272 case SWAY_SCROLL_DOWN:
273 return 5;
274 case SWAY_SCROLL_LEFT:
275 return 6;
276 case SWAY_SCROLL_RIGHT:
277 return 7;
278 case BTN_SIDE:
279 return 8;
280 case BTN_EXTRA:
281 return 9;
282 default:
283 return 0;
284 }
285}
286
262enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, 287enum hotspot_event_handling i3bar_block_send_click(struct status_line *status,
263 struct i3bar_block *block, int x, int y, enum x11_button button) { 288 struct i3bar_block *block, int x, int y, int rx, int ry, int w, int h,
289 uint32_t button) {
264 wlr_log(WLR_DEBUG, "block %s clicked", block->name); 290 wlr_log(WLR_DEBUG, "block %s clicked", block->name);
265 if (!block->name || !status->click_events) { 291 if (!block->name || !status->click_events) {
266 return HOTSPOT_PROCESS; 292 return HOTSPOT_PROCESS;
@@ -274,9 +300,15 @@ enum hotspot_event_handling i3bar_block_send_click(struct status_line *status,
274 json_object_new_string(block->instance)); 300 json_object_new_string(block->instance));
275 } 301 }
276 302
277 json_object_object_add(event_json, "button", json_object_new_int(button)); 303 json_object_object_add(event_json, "button",
304 json_object_new_int(event_to_x11_button(button)));
305 json_object_object_add(event_json, "event", json_object_new_int(button));
278 json_object_object_add(event_json, "x", json_object_new_int(x)); 306 json_object_object_add(event_json, "x", json_object_new_int(x));
279 json_object_object_add(event_json, "y", json_object_new_int(y)); 307 json_object_object_add(event_json, "y", json_object_new_int(y));
308 json_object_object_add(event_json, "relative_x", json_object_new_int(rx));
309 json_object_object_add(event_json, "relative_y", json_object_new_int(ry));
310 json_object_object_add(event_json, "width", json_object_new_int(w));
311 json_object_object_add(event_json, "height", json_object_new_int(h));
280 if (dprintf(status->write_fd, "%s%s\n", status->clicked ? "," : "", 312 if (dprintf(status->write_fd, "%s%s\n", status->clicked ? "," : "",
281 json_object_to_json_string(event_json)) < 0) { 313 json_object_to_json_string(event_json)) < 0) {
282 status_error(status, "[failed to write click event]"); 314 status_error(status, "[failed to write click event]");