2 #define I3__FILE__ "key_press.c"
12 #include <sys/types.h>
34 static int json_map_key(
void *ctx,
const unsigned char *stringval,
size_t stringlen) {
36 static int json_map_key(
void *ctx,
const unsigned char *stringval,
unsigned int stringlen) {
39 strncmp((
const char*)stringval,
"parse_error", strlen(
"parse_error")) == 0);
74 bool key_release = (
event->response_type == XCB_KEY_RELEASE);
78 DLOG(
"%s %d, state raw = %d\n", (key_release ?
"KeyRelease" :
"KeyPress"), event->detail, event->state);
81 uint16_t state_filtered =
event->state & ~(
xcb_numlock_mask | XCB_MOD_MASK_LOCK);
82 DLOG(
"(removed numlock, state = %d)\n", state_filtered);
85 state_filtered &= 0xFF;
86 DLOG(
"(removed upper 8 bits, state = %d)\n", state_filtered);
91 DLOG(
"(checked mode_switch, state %d)\n", state_filtered);
102 DLOG(
"no match, new state_filtered = %d\n", state_filtered);
103 if ((bind =
get_binding(state_filtered, key_release, event->detail)) == NULL) {
109 DLOG(
"Could not lookup key binding (modifiers %d, keycode %d)\n",
110 state_filtered, event->detail);
124 const unsigned char *reply;
127 yajl_handle handle = yajl_alloc(&command_error_callbacks, NULL, NULL);
130 yajl_parser_config parse_conf = { 0, 0 };
132 yajl_handle handle = yajl_alloc(&command_error_callbacks, &parse_conf, NULL, NULL);
134 yajl_gen_get_buf(command_output->
json_gen, &reply, &length);
139 yajl_status
state = yajl_parse(handle, reply, length);
140 if (state != yajl_status_ok) {
141 ELOG(
"Could not parse my own reply. That's weird. reply is %.*s\n", (
int)length, reply);
153 "The configured command for this shortcut could not be run successfully.",
166 yajl_gen_free(command_output->
json_gen);