2012-08-12 12:18:43 +02:00
|
|
|
#undef I3__FILE__
|
|
|
|
#define I3__FILE__ "key_press.c"
|
2012-08-02 17:43:00 +02:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
|
|
|
*
|
|
|
|
* i3 - an improved dynamic tiling window manager
|
2013-01-26 09:55:38 +01:00
|
|
|
* © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE)
|
2012-08-02 17:43:00 +02:00
|
|
|
*
|
|
|
|
* key_press.c: key press handler
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
|
|
|
|
|
|
|
/*
|
2012-09-06 17:04:31 +02:00
|
|
|
* There was a KeyPress or KeyRelease (both events have the same fields). We
|
|
|
|
* compare this key code with our bindings table and pass the bound action to
|
|
|
|
* parse_command().
|
2012-08-02 17:43:00 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void handle_key_press(xcb_key_press_event_t *event) {
|
2012-09-06 17:04:31 +02:00
|
|
|
bool key_release = (event->response_type == XCB_KEY_RELEASE);
|
2012-08-02 17:43:00 +02:00
|
|
|
|
|
|
|
last_timestamp = event->time;
|
|
|
|
|
2012-09-06 17:04:31 +02:00
|
|
|
DLOG("%s %d, state raw = %d\n", (key_release ? "KeyRelease" : "KeyPress"), event->detail, event->state);
|
2012-08-02 17:43:00 +02:00
|
|
|
|
2014-05-02 16:22:40 +02:00
|
|
|
Binding *bind = get_binding_from_xcb_event((xcb_generic_event_t *)event);
|
|
|
|
|
|
|
|
/* if we couldn't find a binding, we are done */
|
|
|
|
if (bind == NULL)
|
|
|
|
return;
|
2012-08-02 17:43:00 +02:00
|
|
|
|
2014-06-17 15:34:13 +02:00
|
|
|
CommandResult *result = run_binding(bind, NULL);
|
2012-08-02 17:43:00 +02:00
|
|
|
|
2014-05-28 08:01:50 +02:00
|
|
|
if (result->needs_tree_render)
|
2012-08-02 17:43:00 +02:00
|
|
|
tree_render();
|
|
|
|
|
2014-05-28 08:01:50 +02:00
|
|
|
command_result_free(result);
|
2012-08-02 17:43:00 +02:00
|
|
|
}
|