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);
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
static struct CommandResult command_output
Binding * get_binding(uint16_t modifiers, bool key_release, xcb_keycode_t keycode)
Returns a pointer to the Binding with the specified modifiers and keycode or NULL if no such binding ...
static int current_nesting_level
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
void handle_key_press(xcb_key_press_event_t *event)
There was a key press.
struct CommandResult * parse_command(const char *input)
static bool command_failed
char * command
Command, like in command mode.
static int json_start_map(void *ctx)
static int json_end_map(void *ctx)
char * pattern
The pattern/name used to load the font.
int sasprintf(char **strp, const char *fmt,...)
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory avail...
static int json_map_key(void *ctx, const unsigned char *stringval, unsigned int stringlen)
static bool parse_error_key
pid_t command_error_nagbar_pid
void start_nagbar(pid_t *nagbar_pid, char *argv[])
Starts an i3-nagbar instance with the given parameters.
static int json_boolean(void *ctx, int boolval)
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
static yajl_callbacks command_error_callbacks
unsigned int xcb_numlock_mask