* Generates a click event, if enabled.
*
*/
-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);
+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, int mods);
*
*/
#include "common.h"
+#include "yajl_utils.h"
#include <stdlib.h>
#include <unistd.h>
#include <yajl/yajl_gen.h>
#include <paths.h>
+#include <xcb/xcb_keysyms.h>
+
/* Global variables for child_*() */
i3bar_child child;
}
}
-static void child_click_events_key(const char *key) {
- yajl_gen_string(gen, (const unsigned char *)key, strlen(key));
-}
-
/*
* Generates a click event, if enabled.
*
*/
-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) {
+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, int mods) {
if (!child.click_events) {
return;
}
yajl_gen_map_open(gen);
if (name) {
- child_click_events_key("name");
- yajl_gen_string(gen, (const unsigned char *)name, strlen(name));
+ ystr("name");
+ ystr(name);
}
if (instance) {
- child_click_events_key("instance");
- yajl_gen_string(gen, (const unsigned char *)instance, strlen(instance));
+ ystr("instance");
+ ystr(instance);
}
- child_click_events_key("button");
+ ystr("button");
yajl_gen_integer(gen, button);
- child_click_events_key("x");
+ ystr("modifiers");
+ yajl_gen_array_open(gen);
+ if (mods & XCB_MOD_MASK_SHIFT)
+ ystr("Shift");
+ if (mods & XCB_MOD_MASK_CONTROL)
+ ystr("Control");
+ if (mods & XCB_MOD_MASK_1)
+ ystr("Mod1");
+ if (mods & XCB_MOD_MASK_2)
+ ystr("Mod2");
+ if (mods & XCB_MOD_MASK_3)
+ ystr("Mod3");
+ if (mods & XCB_MOD_MASK_4)
+ ystr("Mod4");
+ if (mods & XCB_MOD_MASK_5)
+ ystr("Mod5");
+ yajl_gen_array_close(gen);
+
+ ystr("x");
yajl_gen_integer(gen, x);
- child_click_events_key("y");
+ ystr("y");
yajl_gen_integer(gen, y);
- child_click_events_key("relative_x");
+ ystr("relative_x");
yajl_gen_integer(gen, x_rel);
- child_click_events_key("relative_y");
+ ystr("relative_y");
yajl_gen_integer(gen, y_rel);
- child_click_events_key("width");
+ ystr("width");
yajl_gen_integer(gen, width);
- child_click_events_key("height");
+ ystr("height");
yajl_gen_integer(gen, height);
yajl_gen_map_close(gen);
const int relative_x = statusline_x - last_block_x;
if (relative_x >= 0 && (uint32_t)relative_x <= render->width) {
send_block_clicked(event->detail, block->name, block->instance,
- event->root_x, event->root_y, relative_x, event->event_y, render->width, bar_height);
+ event->root_x, event->root_y, relative_x, event->event_y, render->width, bar_height,
+ event->state);
return;
}