Add relative coordinates in JSON for i3bar click events (fixes #2767)

Add support for relative coordinates in i3bar click events

Rename {x,y}_rel to relative_{x,y}

Update i3bar-protocol doc to mention the added fields in click events
This commit is contained in:
Pallav Agarwal
2017-12-20 17:49:38 +05:30
parent eb227c2332
commit 161db6f17d
4 changed files with 26 additions and 4 deletions

View File

@ -596,7 +596,7 @@ void child_click_events_key(const char *key) {
* Generates a click event, if enabled.
*
*/
void send_block_clicked(int button, const char *name, const char *instance, int x, int y) {
void send_block_clicked(int button, const char *name, const char *instance, int x, int y, int x_rel, int y_rel, int width, int height) {
if (!child.click_events) {
return;
}
@ -624,6 +624,18 @@ void send_block_clicked(int button, const char *name, const char *instance, int
child_click_events_key("y");
yajl_gen_integer(gen, y);
child_click_events_key("relative_x");
yajl_gen_integer(gen, x_rel);
child_click_events_key("relative_y");
yajl_gen_integer(gen, y_rel);
child_click_events_key("width");
yajl_gen_integer(gen, width);
child_click_events_key("height");
yajl_gen_integer(gen, height);
yajl_gen_map_close(gen);
child_write_output();
}