i3
bindings.c
Go to the documentation of this file.
1/*
2 * vim:ts=4:sw=4:expandtab
3 *
4 * i3 - an improved dynamic tiling window manager
5 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6 *
7 * bindings.c: Functions for configuring, finding and, running bindings.
8 */
9#include "all.h"
10
11#include <math.h>
12
13#include <xkbcommon/xkbcommon-x11.h>
14#include <xkbcommon/xkbcommon.h>
15
16static struct xkb_context *xkb_context;
17static struct xkb_keymap *xkb_keymap;
18
20
21/*
22 * The name of the default mode.
23 *
24 */
25const char *DEFAULT_BINDING_MODE = "default";
26
27/*
28 * Returns the mode specified by `name` or creates a new mode and adds it to
29 * the list of modes.
30 *
31 */
32static struct Mode *mode_from_name(const char *name, bool pango_markup) {
33 struct Mode *mode;
34
35 /* Try to find the mode in the list of modes and return it */
36 SLIST_FOREACH (mode, &modes, modes) {
37 if (strcmp(mode->name, name) == 0) {
38 return mode;
39 }
40 }
41
42 /* If the mode was not found, create a new one */
43 mode = scalloc(1, sizeof(struct Mode));
44 mode->name = sstrdup(name);
46 mode->bindings = scalloc(1, sizeof(struct bindings_head));
47 TAILQ_INIT(mode->bindings);
49
50 return mode;
51}
52
53/*
54 * Adds a binding from config parameters given as strings and returns a
55 * pointer to the binding structure. Returns NULL if the input code could not
56 * be parsed.
57 *
58 */
59Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code,
60 const char *release, const char *border, const char *whole_window,
61 const char *exclude_titlebar, const char *command, const char *modename,
62 bool pango_markup) {
63 Binding *new_binding = scalloc(1, sizeof(Binding));
64 DLOG("Binding %p bindtype %s, modifiers %s, input code %s, release %s\n", new_binding, bindtype, modifiers, input_code, release);
65 new_binding->release = (release != NULL ? B_UPON_KEYRELEASE : B_UPON_KEYPRESS);
66 new_binding->border = (border != NULL);
67 new_binding->whole_window = (whole_window != NULL);
68 new_binding->exclude_titlebar = (exclude_titlebar != NULL);
69 if (strcmp(bindtype, "bindsym") == 0) {
70 new_binding->input_type = (strncasecmp(input_code, "button", (sizeof("button") - 1)) == 0
71 ? B_MOUSE
72 : B_KEYBOARD);
73
74 new_binding->symbol = sstrdup(input_code);
75 } else {
76 long keycode;
77 if (!parse_long(input_code, &keycode, 10)) {
78 ELOG("Could not parse \"%s\" as an input code, ignoring this binding.\n", input_code);
79 FREE(new_binding);
80 return NULL;
81 }
82
83 new_binding->keycode = keycode;
84 new_binding->input_type = B_KEYBOARD;
85 }
86 new_binding->command = sstrdup(command);
87 new_binding->event_state_mask = event_state_from_str(modifiers);
88 int group_bits_set = 0;
89 if ((new_binding->event_state_mask >> 16) & I3_XKB_GROUP_MASK_1)
90 group_bits_set++;
91 if ((new_binding->event_state_mask >> 16) & I3_XKB_GROUP_MASK_2)
92 group_bits_set++;
93 if ((new_binding->event_state_mask >> 16) & I3_XKB_GROUP_MASK_3)
94 group_bits_set++;
95 if ((new_binding->event_state_mask >> 16) & I3_XKB_GROUP_MASK_4)
96 group_bits_set++;
97 if (group_bits_set > 1)
98 ELOG("Keybinding has more than one Group specified, but your X server is always in precisely one group. The keybinding can never trigger.\n");
99
100 struct Mode *mode = mode_from_name(modename, pango_markup);
101 TAILQ_INSERT_TAIL(mode->bindings, new_binding, bindings);
102
103 TAILQ_INIT(&(new_binding->keycodes_head));
104
105 return new_binding;
106}
107
108static bool binding_in_current_group(const Binding *bind) {
109 /* If no bits are set, the binding should be installed in every group. */
110 if ((bind->event_state_mask >> 16) == I3_XKB_GROUP_MASK_ANY)
111 return true;
112 switch (xkb_current_group) {
113 case XCB_XKB_GROUP_1:
114 return ((bind->event_state_mask >> 16) & I3_XKB_GROUP_MASK_1);
115 case XCB_XKB_GROUP_2:
116 return ((bind->event_state_mask >> 16) & I3_XKB_GROUP_MASK_2);
117 case XCB_XKB_GROUP_3:
118 return ((bind->event_state_mask >> 16) & I3_XKB_GROUP_MASK_3);
119 case XCB_XKB_GROUP_4:
120 return ((bind->event_state_mask >> 16) & I3_XKB_GROUP_MASK_4);
121 default:
122 ELOG("BUG: xkb_current_group (= %d) outside of [XCB_XKB_GROUP_1..XCB_XKB_GROUP_4]\n", xkb_current_group);
123 return false;
124 }
125}
126
127static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint32_t keycode) {
128 /* Grab the key in all combinations */
129#define GRAB_KEY(modifier) \
130 do { \
131 xcb_grab_key(conn, 0, root, modifier, keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); \
132 } while (0)
133 const int mods = (bind->event_state_mask & 0xFFFF);
134 DLOG("Binding %p Grabbing keycode %d with event state mask 0x%x (mods 0x%x)\n",
135 bind, keycode, bind->event_state_mask, mods);
136 GRAB_KEY(mods);
137 /* Also bind the key with active NumLock */
139 /* Also bind the key with active CapsLock */
140 GRAB_KEY(mods | XCB_MOD_MASK_LOCK);
141 /* Also bind the key with active NumLock+CapsLock */
142 GRAB_KEY(mods | xcb_numlock_mask | XCB_MOD_MASK_LOCK);
143}
144
145/*
146 * Grab the bound keys (tell X to send us keypress events for those keycodes)
147 *
148 */
149void grab_all_keys(xcb_connection_t *conn) {
150 Binding *bind;
152 if (bind->input_type != B_KEYBOARD)
153 continue;
154
155 if (!binding_in_current_group(bind))
156 continue;
157
158 /* The easy case: the user specified a keycode directly. */
159 if (bind->keycode > 0) {
161 continue;
162 }
163
164 struct Binding_Keycode *binding_keycode;
165 TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
166 const int keycode = binding_keycode->keycode;
167 const int mods = (binding_keycode->modifiers & 0xFFFF);
168 DLOG("Binding %p Grabbing keycode %d with mods %d\n", bind, keycode, mods);
169 xcb_grab_key(conn, 0, root, mods, keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
170 }
171 }
172}
173
174/*
175 * Release the button grabs on all managed windows and regrab them,
176 * reevaluating which buttons need to be grabbed.
177 *
178 */
179void regrab_all_buttons(xcb_connection_t *conn) {
180 int *buttons = bindings_get_buttons_to_grab();
181 xcb_grab_server(conn);
182
183 Con *con;
185 if (con->window == NULL)
186 continue;
187
188 xcb_ungrab_button(conn, XCB_BUTTON_INDEX_ANY, con->window->id, XCB_BUTTON_MASK_ANY);
189 xcb_grab_buttons(conn, con->window->id, buttons);
190 }
191
192 FREE(buttons);
193 xcb_ungrab_server(conn);
194}
195
196/*
197 * Returns a pointer to the Binding with the specified modifiers and
198 * keycode or NULL if no such binding exists.
199 *
200 */
201static Binding *get_binding(i3_event_state_mask_t state_filtered, bool is_release, uint16_t input_code, input_type_t input_type) {
202 Binding *bind;
203 Binding *result = NULL;
204
205 if (!is_release) {
206 /* On a press event, we first reset all B_UPON_KEYRELEASE_IGNORE_MODS
207 * bindings back to B_UPON_KEYRELEASE */
209 if (bind->input_type != input_type)
210 continue;
211 if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
212 bind->release = B_UPON_KEYRELEASE;
213 }
214 }
215
216 const uint32_t xkb_group_state = (state_filtered & 0xFFFF0000);
217 const uint32_t modifiers_state = (state_filtered & 0x0000FFFF);
219 if (bind->input_type != input_type) {
220 continue;
221 }
222
223 const uint32_t xkb_group_mask = (bind->event_state_mask & 0xFFFF0000);
224 const bool groups_match = ((xkb_group_state & xkb_group_mask) == xkb_group_mask);
225 if (!groups_match) {
226 DLOG("skipping binding %p because XKB groups do not match\n", bind);
227 continue;
228 }
229
230 /* For keyboard bindings where a symbol was specified by the user, we
231 * need to look in the array of translated keycodes for the event’s
232 * keycode */
233 bool found_keycode = false;
234 if (input_type == B_KEYBOARD && bind->symbol != NULL) {
235 xcb_keycode_t input_keycode = (xcb_keycode_t)input_code;
236 struct Binding_Keycode *binding_keycode;
237 TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
238 const uint32_t modifiers_mask = (binding_keycode->modifiers & 0x0000FFFF);
239 const bool mods_match = (modifiers_mask == modifiers_state);
240 DLOG("binding_keycode->modifiers = %d, modifiers_mask = %d, modifiers_state = %d, mods_match = %s\n",
241 binding_keycode->modifiers, modifiers_mask, modifiers_state, (mods_match ? "yes" : "no"));
242 if (binding_keycode->keycode == input_keycode &&
243 (mods_match || (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS && is_release))) {
244 found_keycode = true;
245 break;
246 }
247 }
248 } else {
249 /* This case is easier: The user specified a keycode */
250 if (bind->keycode != input_code) {
251 continue;
252 }
253
254 struct Binding_Keycode *binding_keycode;
255 TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
256 const uint32_t modifiers_mask = (binding_keycode->modifiers & 0x0000FFFF);
257 const bool mods_match = (modifiers_mask == modifiers_state);
258 DLOG("binding_keycode->modifiers = %d, modifiers_mask = %d, modifiers_state = %d, mods_match = %s\n",
259 binding_keycode->modifiers, modifiers_mask, modifiers_state, (mods_match ? "yes" : "no"));
260 if (mods_match || (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS && is_release)) {
261 found_keycode = true;
262 break;
263 }
264 }
265 }
266 if (!found_keycode) {
267 continue;
268 }
269
270 /* If this binding is a release binding, it matches the key which the
271 * user pressed. We therefore mark it as B_UPON_KEYRELEASE_IGNORE_MODS
272 * for later, so that the user can release the modifiers before the
273 * actual key or button and the release event will still be matched. */
274 if (bind->release == B_UPON_KEYRELEASE && !is_release) {
275 bind->release = B_UPON_KEYRELEASE_IGNORE_MODS;
276 DLOG("marked bind %p as B_UPON_KEYRELEASE_IGNORE_MODS\n", bind);
277 if (result) {
278 break;
279 }
280 continue;
281 }
282
283 /* Check if the binding is for a press or a release event */
284 if ((bind->release == B_UPON_KEYPRESS && is_release)) {
285 continue;
286 }
287
288 if (is_release) {
289 return bind;
290 } else if (!result) {
291 /* Continue looping to mark needed B_UPON_KEYRELEASE_IGNORE_MODS. */
292 result = bind;
293 }
294 }
295
296 return result;
297}
298
299/*
300 * Returns a pointer to the Binding that matches the given xcb button or key
301 * event or NULL if no such binding exists.
302 *
303 */
304Binding *get_binding_from_xcb_event(xcb_generic_event_t *event) {
305 const bool is_release = (event->response_type == XCB_KEY_RELEASE ||
306 event->response_type == XCB_BUTTON_RELEASE);
307
308 const input_type_t input_type = ((event->response_type == XCB_BUTTON_RELEASE ||
309 event->response_type == XCB_BUTTON_PRESS)
310 ? B_MOUSE
311 : B_KEYBOARD);
312
313 const uint16_t event_state = ((xcb_key_press_event_t *)event)->state;
314 const uint16_t event_detail = ((xcb_key_press_event_t *)event)->detail;
315
316 /* Remove the CapsLock bit */
317 i3_event_state_mask_t state_filtered = event_state & ~XCB_MOD_MASK_LOCK;
318 DLOG("(removed capslock, state = 0x%x)\n", state_filtered);
319 /* Transform the keyboard_group from bit 13 and bit 14 into an
320 * i3_xkb_group_mask_t, so that get_binding() can just bitwise AND the
321 * configured bindings against |state_filtered|.
322 *
323 * These bits are only set because we set the XKB client flags
324 * XCB_XKB_PER_CLIENT_FLAG_GRABS_USE_XKB_STATE and
325 * XCB_XKB_PER_CLIENT_FLAG_LOOKUP_STATE_WHEN_GRABBED. See also doc/kbproto
326 * section 2.2.2:
327 * https://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#Computing_A_State_Field_from_an_XKB_State */
328 switch ((event_state & 0x6000) >> 13) {
329 case XCB_XKB_GROUP_1:
330 state_filtered |= (I3_XKB_GROUP_MASK_1 << 16);
331 break;
332 case XCB_XKB_GROUP_2:
333 state_filtered |= (I3_XKB_GROUP_MASK_2 << 16);
334 break;
335 case XCB_XKB_GROUP_3:
336 state_filtered |= (I3_XKB_GROUP_MASK_3 << 16);
337 break;
338 case XCB_XKB_GROUP_4:
339 state_filtered |= (I3_XKB_GROUP_MASK_4 << 16);
340 break;
341 }
342 state_filtered &= ~0x6000;
343 DLOG("(transformed keyboard group, state = 0x%x)\n", state_filtered);
344 return get_binding(state_filtered, is_release, event_detail, input_type);
345}
346
347struct resolve {
348 /* The binding which we are resolving. */
350
351 /* |bind|’s keysym (translated to xkb_keysym_t), e.g. XKB_KEY_R. */
352 xkb_keysym_t keysym;
353
354 /* The xkb state built from the user-provided modifiers and group. */
356
357 /* Like |xkb_state|, just without the shift modifier, if shift was specified. */
359
360 /* Like |xkb_state|, but with NumLock. */
362
363 /* Like |xkb_state|, but with NumLock, just without the shift modifier, if shift was specified. */
365};
366
367#define ADD_TRANSLATED_KEY(code, mods) \
368 do { \
369 struct Binding_Keycode *binding_keycode = smalloc(sizeof(struct Binding_Keycode)); \
370 binding_keycode->modifiers = (mods); \
371 binding_keycode->keycode = (code); \
372 TAILQ_INSERT_TAIL(&(bind->keycodes_head), binding_keycode, keycodes); \
373 } while (0)
374
375/*
376 * add_keycode_if_matches is called for each keycode in the keymap and will add
377 * the keycode to |data->bind| if the keycode can result in the keysym
378 * |data->resolving|.
379 *
380 */
381static void add_keycode_if_matches(struct xkb_keymap *keymap, xkb_keycode_t key, void *data) {
382 const struct resolve *resolving = data;
383 struct xkb_state *numlock_state = resolving->xkb_state_numlock;
384 xkb_keysym_t sym = xkb_state_key_get_one_sym(resolving->xkb_state, key);
385 if (sym != resolving->keysym) {
386 /* Check if Shift was specified, and try resolving the symbol without
387 * shift, so that “bindsym $mod+Shift+a nop” actually works. */
388 const xkb_layout_index_t layout = xkb_state_key_get_layout(resolving->xkb_state, key);
389 if (layout == XKB_LAYOUT_INVALID)
390 return;
391 if (xkb_state_key_get_level(resolving->xkb_state, key, layout) > 1)
392 return;
393 /* Skip the Shift fallback for keypad keys, otherwise one cannot bind
394 * KP_1 independent of KP_End. */
395 if (sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_Equal)
396 return;
397 numlock_state = resolving->xkb_state_numlock_no_shift;
398 sym = xkb_state_key_get_one_sym(resolving->xkb_state_no_shift, key);
399 if (sym != resolving->keysym)
400 return;
401 }
402 Binding *bind = resolving->bind;
403
405
406 /* Also bind the key with active CapsLock */
407 ADD_TRANSLATED_KEY(key, bind->event_state_mask | XCB_MOD_MASK_LOCK);
408
409 /* If this binding is not explicitly for NumLock, check whether we need to
410 * add a fallback. */
412 /* Check whether the keycode results in the same keysym when NumLock is
413 * active. If so, grab the key with NumLock as well, so that users don’t
414 * need to duplicate every key binding with an additional Mod2 specified.
415 */
416 xkb_keysym_t sym_numlock = xkb_state_key_get_one_sym(numlock_state, key);
417 if (sym_numlock == resolving->keysym) {
418 /* Also bind the key with active NumLock */
420
421 /* Also bind the key with active NumLock+CapsLock */
422 ADD_TRANSLATED_KEY(key, bind->event_state_mask | xcb_numlock_mask | XCB_MOD_MASK_LOCK);
423 } else {
424 DLOG("Skipping automatic numlock fallback, key %d resolves to 0x%x with numlock\n",
425 key, sym_numlock);
426 }
427 }
428}
429
430/*
431 * Translates keysymbols to keycodes for all bindings which use keysyms.
432 *
433 */
435 struct xkb_state *dummy_state = NULL;
436 struct xkb_state *dummy_state_no_shift = NULL;
437 struct xkb_state *dummy_state_numlock = NULL;
438 struct xkb_state *dummy_state_numlock_no_shift = NULL;
439 bool has_errors = false;
440
441 if ((dummy_state = xkb_state_new(xkb_keymap)) == NULL ||
442 (dummy_state_no_shift = xkb_state_new(xkb_keymap)) == NULL ||
443 (dummy_state_numlock = xkb_state_new(xkb_keymap)) == NULL ||
444 (dummy_state_numlock_no_shift = xkb_state_new(xkb_keymap)) == NULL) {
445 ELOG("Could not create XKB state, cannot translate keysyms.\n");
446 goto out;
447 }
448
449 Binding *bind;
451 if (bind->input_type == B_MOUSE) {
452 long button;
453 if (!parse_long(bind->symbol + (sizeof("button") - 1), &button, 10)) {
454 ELOG("Could not translate string to button: \"%s\"\n", bind->symbol);
455 }
456
457 xcb_keycode_t key = button;
458 bind->keycode = key;
459 DLOG("Binding Mouse button, Keycode = %d\n", key);
460 }
461
462 xkb_layout_index_t group = XCB_XKB_GROUP_1;
463 if ((bind->event_state_mask >> 16) & I3_XKB_GROUP_MASK_2)
464 group = XCB_XKB_GROUP_2;
465 else if ((bind->event_state_mask >> 16) & I3_XKB_GROUP_MASK_3)
466 group = XCB_XKB_GROUP_3;
467 else if ((bind->event_state_mask >> 16) & I3_XKB_GROUP_MASK_4)
468 group = XCB_XKB_GROUP_4;
469
470 DLOG("Binding %p group = %d, event_state_mask = %d, &2 = %s, &3 = %s, &4 = %s\n",
471 bind,
472 group,
473 bind->event_state_mask,
474 (bind->event_state_mask & I3_XKB_GROUP_MASK_2) ? "yes" : "no",
475 (bind->event_state_mask & I3_XKB_GROUP_MASK_3) ? "yes" : "no",
476 (bind->event_state_mask & I3_XKB_GROUP_MASK_4) ? "yes" : "no");
477 (void)xkb_state_update_mask(
478 dummy_state,
479 (bind->event_state_mask & 0x1FFF) /* xkb_mod_mask_t base_mods, */,
480 0 /* xkb_mod_mask_t latched_mods, */,
481 0 /* xkb_mod_mask_t locked_mods, */,
482 0 /* xkb_layout_index_t base_group, */,
483 0 /* xkb_layout_index_t latched_group, */,
484 group /* xkb_layout_index_t locked_group, */);
485
486 (void)xkb_state_update_mask(
487 dummy_state_no_shift,
488 (bind->event_state_mask & 0x1FFF) ^ XCB_KEY_BUT_MASK_SHIFT /* xkb_mod_mask_t base_mods, */,
489 0 /* xkb_mod_mask_t latched_mods, */,
490 0 /* xkb_mod_mask_t locked_mods, */,
491 0 /* xkb_layout_index_t base_group, */,
492 0 /* xkb_layout_index_t latched_group, */,
493 group /* xkb_layout_index_t locked_group, */);
494
495 (void)xkb_state_update_mask(
496 dummy_state_numlock,
497 (bind->event_state_mask & 0x1FFF) | xcb_numlock_mask /* xkb_mod_mask_t base_mods, */,
498 0 /* xkb_mod_mask_t latched_mods, */,
499 0 /* xkb_mod_mask_t locked_mods, */,
500 0 /* xkb_layout_index_t base_group, */,
501 0 /* xkb_layout_index_t latched_group, */,
502 group /* xkb_layout_index_t locked_group, */);
503
504 (void)xkb_state_update_mask(
505 dummy_state_numlock_no_shift,
506 ((bind->event_state_mask & 0x1FFF) | xcb_numlock_mask) ^ XCB_KEY_BUT_MASK_SHIFT /* xkb_mod_mask_t base_mods, */,
507 0 /* xkb_mod_mask_t latched_mods, */,
508 0 /* xkb_mod_mask_t locked_mods, */,
509 0 /* xkb_layout_index_t base_group, */,
510 0 /* xkb_layout_index_t latched_group, */,
511 group /* xkb_layout_index_t locked_group, */);
512
513 if (bind->keycode > 0) {
514 /* We need to specify modifiers for the keycode binding (numlock
515 * fallback). */
516 while (!TAILQ_EMPTY(&(bind->keycodes_head))) {
517 struct Binding_Keycode *first = TAILQ_FIRST(&(bind->keycodes_head));
518 TAILQ_REMOVE(&(bind->keycodes_head), first, keycodes);
519 FREE(first);
520 }
521
523
524 /* Also bind the key with active CapsLock */
525 ADD_TRANSLATED_KEY(bind->keycode, bind->event_state_mask | XCB_MOD_MASK_LOCK);
526
527 /* If this binding is not explicitly for NumLock, check whether we need to
528 * add a fallback. */
530 /* Check whether the keycode results in the same keysym when NumLock is
531 * active. If so, grab the key with NumLock as well, so that users don’t
532 * need to duplicate every key binding with an additional Mod2 specified.
533 */
534 xkb_keysym_t sym = xkb_state_key_get_one_sym(dummy_state, bind->keycode);
535 xkb_keysym_t sym_numlock = xkb_state_key_get_one_sym(dummy_state_numlock, bind->keycode);
536 if (sym == sym_numlock) {
537 /* Also bind the key with active NumLock */
539
540 /* Also bind the key with active NumLock+CapsLock */
541 ADD_TRANSLATED_KEY(bind->keycode, bind->event_state_mask | xcb_numlock_mask | XCB_MOD_MASK_LOCK);
542 } else {
543 DLOG("Skipping automatic numlock fallback, key %d resolves to 0x%x with numlock\n",
544 bind->keycode, sym_numlock);
545 }
546 }
547
548 continue;
549 }
550
551 /* We need to translate the symbol to a keycode */
552 const xkb_keysym_t keysym = xkb_keysym_from_name(bind->symbol, XKB_KEYSYM_NO_FLAGS);
553 if (keysym == XKB_KEY_NoSymbol) {
554 ELOG("Could not translate string to key symbol: \"%s\"\n",
555 bind->symbol);
556 continue;
557 }
558
559 struct resolve resolving = {
560 .bind = bind,
561 .keysym = keysym,
562 .xkb_state = dummy_state,
563 .xkb_state_no_shift = dummy_state_no_shift,
564 .xkb_state_numlock = dummy_state_numlock,
565 .xkb_state_numlock_no_shift = dummy_state_numlock_no_shift,
566 };
567 while (!TAILQ_EMPTY(&(bind->keycodes_head))) {
568 struct Binding_Keycode *first = TAILQ_FIRST(&(bind->keycodes_head));
569 TAILQ_REMOVE(&(bind->keycodes_head), first, keycodes);
570 FREE(first);
571 }
572 xkb_keymap_key_for_each(xkb_keymap, add_keycode_if_matches, &resolving);
573 char *keycodes = sstrdup("");
574 int num_keycodes = 0;
575 struct Binding_Keycode *binding_keycode;
576 TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
577 char *tmp;
578 sasprintf(&tmp, "%s %d", keycodes, binding_keycode->keycode);
579 free(keycodes);
580 keycodes = tmp;
581 num_keycodes++;
582
583 /* check for duplicate bindings */
584 Binding *check;
586 if (check == bind)
587 continue;
588 if (check->symbol != NULL)
589 continue;
590 if (check->keycode != binding_keycode->keycode ||
591 check->event_state_mask != binding_keycode->modifiers ||
592 check->release != bind->release)
593 continue;
594 has_errors = true;
595 ELOG("Duplicate keybinding in config file:\n keysym = %s, keycode = %d, state_mask = 0x%x\n", bind->symbol, check->keycode, bind->event_state_mask);
596 }
597 }
598 DLOG("state=0x%x, cfg=\"%s\", sym=0x%x → keycodes%s (%d)\n",
599 bind->event_state_mask, bind->symbol, keysym, keycodes, num_keycodes);
600 free(keycodes);
601 }
602
603out:
604 xkb_state_unref(dummy_state);
605 xkb_state_unref(dummy_state_no_shift);
606 xkb_state_unref(dummy_state_numlock);
607 xkb_state_unref(dummy_state_numlock_no_shift);
608
609 if (has_errors) {
611 }
612}
613
614#undef ADD_TRANSLATED_KEY
615
616/*
617 * Switches the key bindings to the given mode, if the mode exists
618 *
619 */
620void switch_mode(const char *new_mode) {
621 struct Mode *mode;
622
623 DLOG("Switching to mode %s\n", new_mode);
624
625 SLIST_FOREACH (mode, &modes, modes) {
626 if (strcmp(mode->name, new_mode) != 0)
627 continue;
628
630 bindings = mode->bindings;
635
636 /* Reset all B_UPON_KEYRELEASE_IGNORE_MODS bindings to avoid possibly
637 * activating one of them. */
638 Binding *bind;
640 if (bind->release == B_UPON_KEYRELEASE_IGNORE_MODS)
641 bind->release = B_UPON_KEYRELEASE;
642 }
643
644 char *event_msg;
645 sasprintf(&event_msg, "{\"change\":\"%s\", \"pango_markup\":%s}",
646 mode->name, (mode->pango_markup ? "true" : "false"));
647
648 ipc_send_event("mode", I3_IPC_EVENT_MODE, event_msg);
649 FREE(event_msg);
650
651 return;
652 }
653
654 ELOG("Mode not found\n");
655}
656
657static int reorder_binding_cmp(const void *a, const void *b) {
658 Binding *first = *((Binding **)a);
659 Binding *second = *((Binding **)b);
660 if (first->event_state_mask < second->event_state_mask) {
661 return 1;
662 } else if (first->event_state_mask == second->event_state_mask) {
663 return 0;
664 } else {
665 return -1;
666 }
667}
668
669static void reorder_bindings_of_mode(struct Mode *mode) {
670 /* Copy the bindings into an array, so that we can use qsort(3). */
671 int n = 0;
672 Binding *current;
673 TAILQ_FOREACH (current, mode->bindings, bindings) {
674 n++;
675 }
676 Binding **tmp = scalloc(n, sizeof(Binding *));
677 n = 0;
678 TAILQ_FOREACH (current, mode->bindings, bindings) {
679 tmp[n++] = current;
680 }
681
682 qsort(tmp, n, sizeof(Binding *), reorder_binding_cmp);
683
684 struct bindings_head *reordered = scalloc(1, sizeof(struct bindings_head));
685 TAILQ_INIT(reordered);
686 for (int i = 0; i < n; i++) {
687 current = tmp[i];
688 TAILQ_REMOVE(mode->bindings, current, bindings);
689 TAILQ_INSERT_TAIL(reordered, current, bindings);
690 }
691 free(tmp);
692 assert(TAILQ_EMPTY(mode->bindings));
693 /* Free the old bindings_head, which is now empty. */
694 free(mode->bindings);
695 mode->bindings = reordered;
696}
697
698/*
699 * Reorders bindings by event_state_mask descendingly so that get_binding()
700 * correctly matches more specific bindings before more generic bindings. Take
701 * the following binding configuration as an example:
702 *
703 * bindsym n nop lower-case n pressed
704 * bindsym Shift+n nop upper-case n pressed
705 *
706 * Without reordering, the first binding’s event_state_mask of 0x0 would match
707 * the actual event_stat_mask of 0x1 and hence trigger instead of the second
708 * keybinding.
709 *
710 */
712 struct Mode *mode;
713 SLIST_FOREACH (mode, &modes, modes) {
714 const bool current_mode = (mode->bindings == bindings);
716 if (current_mode)
717 bindings = mode->bindings;
718 }
719}
720
721/*
722 * Returns true if a is a key binding for the same key as b.
723 *
724 */
725static bool binding_same_key(Binding *a, Binding *b) {
726 /* Check if the input types are different */
727 if (a->input_type != b->input_type) {
728 return false;
729 }
730
731 /* Check if one is using keysym while the other is using bindsym. */
732 if ((a->symbol == NULL && b->symbol != NULL) ||
733 (a->symbol != NULL && b->symbol == NULL)) {
734 return false;
735 }
736
737 /* If a is NULL, b has to be NULL, too (see previous conditional).
738 * If the keycodes differ, it can't be a duplicate. */
739 if (a->symbol != NULL &&
740 strcasecmp(a->symbol, b->symbol) != 0) {
741 return false;
742 }
743
744 /* Check if the keycodes or modifiers are different. If so, they
745 * can't be duplicate */
746 if (a->keycode != b->keycode ||
748 a->release != b->release) {
749 return false;
750 }
751
752 return true;
753}
754
755/*
756 * Checks for duplicate key bindings (the same keycode or keysym is configured
757 * more than once). If a duplicate binding is found, a message is printed to
758 * stderr and the has_errors variable is set to true, which will start
759 * i3-nagbar.
760 *
761 */
763 Binding *bind, *current;
764 TAILQ_FOREACH (current, bindings, bindings) {
766 /* Abort when we reach the current keybinding, only check the
767 * bindings before */
768 if (bind == current) {
769 break;
770 }
771
772 if (!binding_same_key(bind, current)) {
773 continue;
774 }
775
776 context->has_errors = true;
777 if (current->keycode != 0) {
778 ELOG("Duplicate keybinding in config file:\n state mask 0x%x with keycode %d, command \"%s\"\n",
779 current->event_state_mask, current->keycode, current->command);
780 } else {
781 ELOG("Duplicate keybinding in config file:\n state mask 0x%x with keysym %s, command \"%s\"\n",
782 current->event_state_mask, current->symbol, current->command);
783 }
784 }
785 }
786}
787
788/*
789 * Creates a dynamically allocated copy of bind.
790 */
792 Binding *ret = smalloc(sizeof(Binding));
793 *ret = *bind;
794 if (bind->symbol != NULL)
795 ret->symbol = sstrdup(bind->symbol);
796 if (bind->command != NULL)
797 ret->command = sstrdup(bind->command);
798 TAILQ_INIT(&(ret->keycodes_head));
799 struct Binding_Keycode *binding_keycode;
800 TAILQ_FOREACH (binding_keycode, &(bind->keycodes_head), keycodes) {
801 struct Binding_Keycode *ret_binding_keycode = smalloc(sizeof(struct Binding_Keycode));
802 *ret_binding_keycode = *binding_keycode;
803 TAILQ_INSERT_TAIL(&(ret->keycodes_head), ret_binding_keycode, keycodes);
804 }
805
806 return ret;
807}
808
809/*
810 * Frees the binding. If bind is null, it simply returns.
811 */
813 if (bind == NULL) {
814 return;
815 }
816
817 while (!TAILQ_EMPTY(&(bind->keycodes_head))) {
818 struct Binding_Keycode *first = TAILQ_FIRST(&(bind->keycodes_head));
819 TAILQ_REMOVE(&(bind->keycodes_head), first, keycodes);
820 FREE(first);
821 }
822
823 FREE(bind->symbol);
824 FREE(bind->command);
825 FREE(bind);
826}
827
828/*
829 * Runs the given binding and handles parse errors. If con is passed, it will
830 * execute the command binding with that container selected by criteria.
831 * Returns a CommandResult for running the binding's command. Free with
832 * command_result_free().
833 *
834 */
836 char *command;
837
838 /* We need to copy the binding and command since “reload” may be part of
839 * the command, and then the memory that bind points to may not contain the
840 * same data anymore. */
841 if (con == NULL)
842 command = sstrdup(bind->command);
843 else
844 sasprintf(&command, "[con_id=\"%p\"] %s", con, bind->command);
845
846 Binding *bind_cp = binding_copy(bind);
847 /* The "mode" command might change the current mode, so back it up to
848 * correctly produce an event later. */
849 char *modename = sstrdup(current_binding_mode);
850
851 CommandResult *result = parse_command(command, NULL, NULL);
852 free(command);
853
854 if (result->needs_tree_render)
855 tree_render();
856
857 if (result->parse_error) {
858 char *pageraction;
859 sasprintf(&pageraction, "i3-sensible-pager \"%s\"\n", errorfilename);
860 char *argv[] = {
861 NULL, /* will be replaced by the executable path */
862 "-f",
864 "-t",
865 "error",
866 "-m",
867 "The configured command for this shortcut could not be run successfully.",
868 "-b",
869 "show errors",
870 pageraction,
871 NULL};
873 free(pageraction);
874 }
875
876 ipc_send_binding_event("run", bind_cp, modename);
877 FREE(modename);
878 binding_free(bind_cp);
879
880 return result;
881}
882
883static int fill_rmlvo_from_root(struct xkb_rule_names *xkb_names) {
884 xcb_intern_atom_reply_t *atom_reply;
885 size_t content_max_words = 256;
886
887 atom_reply = xcb_intern_atom_reply(
888 conn, xcb_intern_atom(conn, 0, strlen("_XKB_RULES_NAMES"), "_XKB_RULES_NAMES"), NULL);
889 if (atom_reply == NULL)
890 return -1;
891
892 xcb_get_property_cookie_t prop_cookie;
893 xcb_get_property_reply_t *prop_reply;
894 prop_cookie = xcb_get_property_unchecked(conn, false, root, atom_reply->atom,
895 XCB_GET_PROPERTY_TYPE_ANY, 0, content_max_words);
896 prop_reply = xcb_get_property_reply(conn, prop_cookie, NULL);
897 if (prop_reply == NULL) {
898 free(atom_reply);
899 return -1;
900 }
901 if (xcb_get_property_value_length(prop_reply) > 0 && prop_reply->bytes_after > 0) {
902 /* We received an incomplete value. Ask again but with a properly
903 * adjusted size. */
904 content_max_words += ceil(prop_reply->bytes_after / 4.0);
905 /* Repeat the request, with adjusted size */
906 free(prop_reply);
907 prop_cookie = xcb_get_property_unchecked(conn, false, root, atom_reply->atom,
908 XCB_GET_PROPERTY_TYPE_ANY, 0, content_max_words);
909 prop_reply = xcb_get_property_reply(conn, prop_cookie, NULL);
910 if (prop_reply == NULL) {
911 free(atom_reply);
912 return -1;
913 }
914 }
915 if (xcb_get_property_value_length(prop_reply) == 0) {
916 free(atom_reply);
917 free(prop_reply);
918 return -1;
919 }
920
921 const char *walk = (const char *)xcb_get_property_value(prop_reply);
922 int remaining = xcb_get_property_value_length(prop_reply);
923 for (int i = 0; i < 5 && remaining > 0; i++) {
924 const int len = strnlen(walk, remaining);
925 switch (i) {
926 case 0:
927 sasprintf((char **)&(xkb_names->rules), "%.*s", len, walk);
928 break;
929 case 1:
930 sasprintf((char **)&(xkb_names->model), "%.*s", len, walk);
931 break;
932 case 2:
933 sasprintf((char **)&(xkb_names->layout), "%.*s", len, walk);
934 break;
935 case 3:
936 sasprintf((char **)&(xkb_names->variant), "%.*s", len, walk);
937 break;
938 case 4:
939 sasprintf((char **)&(xkb_names->options), "%.*s", len, walk);
940 break;
941 }
942 DLOG("component %d of _XKB_RULES_NAMES is \"%.*s\"\n", i, len, walk);
943 walk += (len + 1);
944 remaining -= (len + 1);
945 }
946
947 free(atom_reply);
948 free(prop_reply);
949 return 0;
950}
951
952/*
953 * Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
954 *
955 */
956bool load_keymap(void) {
957 if (xkb_context == NULL) {
958 if ((xkb_context = xkb_context_new(0)) == NULL) {
959 ELOG("Could not create xkbcommon context\n");
960 return false;
961 }
962 }
963
964 struct xkb_keymap *new_keymap = NULL;
965 int32_t device_id;
966 if (xkb_supported && (device_id = xkb_x11_get_core_keyboard_device_id(conn)) > -1) {
967 if ((new_keymap = xkb_x11_keymap_new_from_device(xkb_context, conn, device_id, 0)) == NULL) {
968 ELOG("xkb_x11_keymap_new_from_device failed\n");
969 return false;
970 }
971 } else {
972 /* Likely there is no XKB support on this server, possibly because it
973 * is a VNC server. */
974 LOG("No XKB / core keyboard device? Assembling keymap from local RMLVO.\n");
975 struct xkb_rule_names names = {
976 .rules = NULL,
977 .model = NULL,
978 .layout = NULL,
979 .variant = NULL,
980 .options = NULL};
981 if (fill_rmlvo_from_root(&names) == -1) {
982 ELOG("Could not get _XKB_RULES_NAMES atom from root window, falling back to defaults.\n");
983 /* Using NULL for the fields of xkb_rule_names. */
984 }
985 new_keymap = xkb_keymap_new_from_names(xkb_context, &names, 0);
986 free((char *)names.rules);
987 free((char *)names.model);
988 free((char *)names.layout);
989 free((char *)names.variant);
990 free((char *)names.options);
991 if (new_keymap == NULL) {
992 ELOG("xkb_keymap_new_from_names failed\n");
993 return false;
994 }
995 }
996 xkb_keymap_unref(xkb_keymap);
997 xkb_keymap = new_keymap;
998
999 return true;
1000}
1001
1002/*
1003 * Returns a list of buttons that should be grabbed on a window.
1004 * This list will always contain 1–3, all higher buttons will only be returned
1005 * if there is a whole-window binding for it on some window in the current
1006 * config.
1007 * The list is terminated by a 0.
1008 */
1010 /* Let's make the reasonable assumption that there's no more than 25
1011 * buttons. */
1012 const int num_max = 25;
1013
1014 int buffer[num_max];
1015 int num = 0;
1016
1017 /* We always return buttons 1 through 3. */
1018 buffer[num++] = 1;
1019 buffer[num++] = 2;
1020 buffer[num++] = 3;
1021
1022 Binding *bind;
1024 if (num + 1 == num_max)
1025 break;
1026
1027 /* We are only interested in whole window mouse bindings. */
1028 if (bind->input_type != B_MOUSE || !bind->whole_window)
1029 continue;
1030
1031 long button;
1032 if (!parse_long(bind->symbol + (sizeof("button") - 1), &button, 10)) {
1033 ELOG("Could not parse button number, skipping this binding. Please report this bug in i3.\n");
1034 continue;
1035 }
1036
1037 /* Avoid duplicates. */
1038 bool exists = false;
1039 for (int i = 0; i < num; i++) {
1040 if (buffer[i] == button) {
1041 exists = true;
1042 break;
1043 }
1044 }
1045
1046 if (!exists) {
1047 buffer[num++] = button;
1048 }
1049 }
1050 buffer[num++] = 0;
1051
1052 int *buttons = scalloc(num, sizeof(int));
1053 memcpy(buttons, buffer, num * sizeof(int));
1054
1055 return buttons;
1056}
void binding_free(Binding *bind)
Frees the binding.
Definition bindings.c:812
static struct xkb_context * xkb_context
Definition bindings.c:16
void check_for_duplicate_bindings(struct context *context)
Checks for duplicate key bindings (the same keycode or keysym is configured more than once).
Definition bindings.c:762
static bool binding_same_key(Binding *a, Binding *b)
Definition bindings.c:725
static Binding * binding_copy(Binding *bind)
Definition bindings.c:791
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
Definition bindings.c:956
static int reorder_binding_cmp(const void *a, const void *b)
Definition bindings.c:657
void grab_all_keys(xcb_connection_t *conn)
Grab the bound keys (tell X to send us keypress events for those keycodes)
Definition bindings.c:149
static void add_keycode_if_matches(struct xkb_keymap *keymap, xkb_keycode_t key, void *data)
Definition bindings.c:381
const char * DEFAULT_BINDING_MODE
The name of the default mode.
Definition bindings.c:25
static struct xkb_keymap * xkb_keymap
Definition bindings.c:17
static Binding * get_binding(i3_event_state_mask_t state_filtered, bool is_release, uint16_t input_code, input_type_t input_type)
Definition bindings.c:201
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:304
void regrab_all_buttons(xcb_connection_t *conn)
Release the button grabs on all managed windows and regrab them, reevaluating which buttons need to b...
Definition bindings.c:179
int * bindings_get_buttons_to_grab(void)
Returns a list of buttons that should be grabbed on a window.
Definition bindings.c:1009
void switch_mode(const char *new_mode)
Switches the key bindings to the given mode, if the mode exists.
Definition bindings.c:620
static int fill_rmlvo_from_root(struct xkb_rule_names *xkb_names)
Definition bindings.c:883
Binding * configure_binding(const char *bindtype, const char *modifiers, const char *input_code, const char *release, const char *border, const char *whole_window, const char *exclude_titlebar, const char *command, const char *modename, bool pango_markup)
Adds a binding from config parameters given as strings and returns a pointer to the binding structure...
Definition bindings.c:59
#define GRAB_KEY(modifier)
static struct Mode * mode_from_name(const char *name, bool pango_markup)
Definition bindings.c:32
static void grab_keycode_for_binding(xcb_connection_t *conn, Binding *bind, uint32_t keycode)
Definition bindings.c:127
pid_t command_error_nagbar_pid
Definition bindings.c:19
CommandResult * run_binding(Binding *bind, Con *con)
Runs the given binding and handles parse errors.
Definition bindings.c:835
#define ADD_TRANSLATED_KEY(code, mods)
Definition bindings.c:367
static void reorder_bindings_of_mode(struct Mode *mode)
Definition bindings.c:669
void reorder_bindings(void)
Reorders bindings by event_state_mask descendingly so that get_binding() correctly matches more speci...
Definition bindings.c:711
static bool binding_in_current_group(const Binding *bind)
Definition bindings.c:108
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
Definition bindings.c:434
CommandResult * parse_command(const char *input, yajl_gen gen, ipc_client *client)
Parses and executes the given command.
Config config
Definition config.c:19
struct modes_head modes
Definition config.c:20
char * current_configpath
Definition config.c:18
void ungrab_all_keys(xcb_connection_t *conn)
Ungrabs all keys, to be called before re-grabbing the keys because of a mapping_notify event or a con...
Definition config.c:29
static char * current_mode
i3_event_state_mask_t event_state_from_str(const char *str)
A utility function to convert a string containing the group and modifiers to the corresponding bit ma...
void start_config_error_nagbar(const char *configpath, bool has_errors)
Launch nagbar to indicate errors in the configuration file.
int xkb_current_group
Definition handlers.c:22
struct all_cons_head all_cons
Definition tree.c:15
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:451
void start_nagbar(pid_t *nagbar_pid, char *argv[])
Starts an i3-nagbar instance with the given parameters.
Definition util.c:354
bool parse_long(const char *str, long *out, int base)
Converts a string into a long using strtol().
Definition util.c:409
unsigned int xcb_numlock_mask
Definition xcb.c:12
void xcb_grab_buttons(xcb_connection_t *conn, xcb_window_t window, int *buttons)
Grab the specified buttons on a window when managing it.
Definition xcb.c:258
void ipc_send_binding_event(const char *event_type, Binding *bind, const char *modename)
For the binding events, we send the serialized binding struct.
Definition ipc.c:1682
void ipc_send_event(const char *event, uint32_t message_type, const char *payload)
Sends the specified event to all IPC clients which are currently connected and subscribed to this kin...
Definition ipc.c:147
char * errorfilename
Definition log.c:38
bool xkb_supported
Definition main.c:104
xcb_connection_t * conn
XCB connection and root screen.
Definition main.c:54
xcb_window_t root
Definition main.c:67
const char * current_binding_mode
Definition main.c:88
struct bindings_head * bindings
Definition main.c:87
@ I3_XKB_GROUP_MASK_2
Definition data.h:129
@ I3_XKB_GROUP_MASK_3
Definition data.h:130
@ I3_XKB_GROUP_MASK_4
Definition data.h:131
@ I3_XKB_GROUP_MASK_1
Definition data.h:128
@ I3_XKB_GROUP_MASK_ANY
Definition data.h:127
uint32_t i3_event_state_mask_t
The lower 16 bits contain a xcb_key_but_mask_t, the higher 16 bits contain an i3_xkb_group_mask_t.
Definition data.h:140
input_type_t
Binding input types.
Definition data.h:118
@ B_KEYBOARD
Definition data.h:119
@ B_MOUSE
Definition data.h:120
#define DLOG(fmt,...)
Definition libi3.h:105
#define LOG(fmt,...)
Definition libi3.h:95
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
#define ELOG(fmt,...)
Definition libi3.h:100
void * scalloc(size_t num, size_t size)
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory a...
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...
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
#define SLIST_FOREACH(var, head, field)
Definition queue.h:114
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:347
#define TAILQ_INIT(head)
Definition queue.h:360
#define SLIST_INSERT_HEAD(head, elm, field)
Definition queue.h:138
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition queue.h:376
#define TAILQ_FIRST(head)
Definition queue.h:336
#define TAILQ_REMOVE(head, elm, field)
Definition queue.h:402
#define TAILQ_EMPTY(head)
Definition queue.h:344
#define FREE(pointer)
Definition util.h:47
struct xkb_state * xkb_state_numlock_no_shift
Definition bindings.c:364
struct xkb_state * xkb_state
Definition bindings.c:355
struct xkb_state * xkb_state_numlock
Definition bindings.c:361
Binding * bind
Definition bindings.c:349
xkb_keysym_t keysym
Definition bindings.c:352
struct xkb_state * xkb_state_no_shift
Definition bindings.c:358
A struct that contains useful information about the result of a command as a whole (e....
Used during the config file lexing/parsing to keep the state of the lexer in order to provide useful ...
bool has_errors
The configuration file can contain multiple sets of bindings.
char * name
struct bindings_head * bindings
bool pango_markup
i3Font font
Stores a resolved keycode (from a keysym), including the modifier mask.
Definition data.h:294
i3_event_state_mask_t modifiers
Definition data.h:296
xcb_keycode_t keycode
Definition data.h:295
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
Definition data.h:310
bool whole_window
If this is true for a mouse binding, the binding should be executed when the button is pressed over a...
Definition data.h:336
char * command
Command, like in command mode.
Definition data.h:361
bool border
If this is true for a mouse binding, the binding should be executed when the button is pressed over t...
Definition data.h:331
uint32_t keycode
Keycode to bind.
Definition data.h:343
char * symbol
Symbol the user specified in configfile, if any.
Definition data.h:353
enum Binding::@10 release
If true, the binding should be executed upon a KeyRelease event, not a KeyPress (the default).
bool exclude_titlebar
If this is true for a mouse binding, the binding should only be executed if the button press was not ...
Definition data.h:340
i3_event_state_mask_t event_state_mask
Bitmask which is applied against event->state for KeyPress and KeyRelease events to determine whether...
Definition data.h:348
input_type_t input_type
Definition data.h:313
xcb_window_t id
Definition data.h:429
A 'Con' represents everything from the X11 root window down to a single X11 window.
Definition data.h:647
struct Window * window
Definition data.h:722
char * pattern
The pattern/name used to load the font.
Definition libi3.h:71