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