i3
key_press.c
Go to the documentation of this file.
1 #undef I3__FILE__
2 #define I3__FILE__ "key_press.c"
3 /*
4  * vim:ts=4:sw=4:expandtab
5  *
6  * i3 - an improved dynamic tiling window manager
7  * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE)
8  *
9  * key_press.c: key press handler
10  *
11  */
12 #include "all.h"
13 
14 /*
15  * There was a KeyPress or KeyRelease (both events have the same fields). We
16  * compare this key code with our bindings table and pass the bound action to
17  * parse_command().
18  *
19  */
20 void handle_key_press(xcb_key_press_event_t *event) {
21  bool key_release = (event->response_type == XCB_KEY_RELEASE);
22 
23  last_timestamp = event->time;
24 
25  DLOG("%s %d, state raw = %d\n", (key_release ? "KeyRelease" : "KeyPress"), event->detail, event->state);
26 
27  Binding *bind = get_binding_from_xcb_event((xcb_generic_event_t *)event);
28 
29  /* if we couldn't find a binding, we are done */
30  if (bind == NULL)
31  return;
32 
33  CommandResult *result = run_binding(bind);
34 
35  if (result->needs_tree_render)
36  tree_render();
37 
38  command_result_free(result);
39 }
void handle_key_press(xcb_key_press_event_t *event)
There was a key press.
Definition: key_press.c:20
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Definition: tree.c:507
CommandResult * run_binding(Binding *bind)
Runs the given binding and handles parse errors.
Definition: bindings.c:387
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
Definition: main.c:57
void command_result_free(CommandResult *result)
Frees a CommandResult.
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
Definition: data.h:231
#define DLOG(fmt,...)
Definition: libi3.h:86
A struct that contains useful information about the result of a command as a whole (e...
Binding * get_binding_from_xcb_event(xcb_generic_event_t *event)
Returns a pointer to the Binding that matches the given xcb event or NULL if no such binding exists...
Definition: bindings.c:192