* the list of modes.
*
*/
-static struct Mode *mode_from_name(const char *name) {
+static struct Mode *mode_from_name(const char *name, bool pango_markup) {
struct Mode *mode;
/* Try to find the mode in the list of modes and return it */
/* If the mode was not found, create a new one */
mode = scalloc(1, sizeof(struct Mode));
mode->name = sstrdup(name);
+ mode->pango_markup = pango_markup;
mode->bindings = scalloc(1, sizeof(struct bindings_head));
TAILQ_INIT(mode->bindings);
SLIST_INSERT_HEAD(&modes, mode, modes);
*/
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 *command, const char *modename) {
+ const char *command, const char *modename, bool pango_markup) {
Binding *new_binding = scalloc(1, sizeof(Binding));
DLOG("bindtype %s, modifiers %s, input code %s, release %s\n", bindtype, modifiers, input_code, release);
new_binding->release = (release != NULL ? B_UPON_KEYRELEASE : B_UPON_KEYPRESS);
if (group_bits_set > 1)
ELOG("Keybinding has more than one Group specified, but your X server is always in precisely one group. The keybinding can never trigger.\n");
- struct Mode *mode = mode_from_name(modename);
+ struct Mode *mode = mode_from_name(modename, pango_markup);
TAILQ_INSERT_TAIL(mode->bindings, new_binding, bindings);
return new_binding;
}
TAILQ_FOREACH(bind, bindings, bindings) {
+ bool state_matches;
+ if ((bind->event_state_mask & 0xFFFF) == 0) {
+ /* Verify no modifiers are pressed. A bitwise AND would lead to
+ * false positives, see issue #2002. */
+ state_matches = (state_filtered == bind->event_state_mask);
+ } else {
+ state_matches = ((state_filtered & bind->event_state_mask) == bind->event_state_mask);
+ }
+
DLOG("binding with event_state_mask 0x%x, state_filtered 0x%x, match: %s\n",
- bind->event_state_mask, state_filtered,
- ((state_filtered & bind->event_state_mask) == bind->event_state_mask) ? "yes" : "no");
+ bind->event_state_mask, state_filtered, (state_matches ? "yes" : "no"));
/* First compare the state_filtered (unless this is a
* B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
* event) */
if (bind->input_type != input_type)
continue;
- if ((state_filtered & bind->event_state_mask) != bind->event_state_mask &&
+ if (!state_matches &&
(bind->release != B_UPON_KEYRELEASE_IGNORE_MODS ||
!is_release))
continue;
}
xkb_state_unref(dummy_state);
+ xkb_state_unref(dummy_state_no_shift);
if (has_errors) {
start_config_error_nagbar(current_configpath, true);
grab_all_keys(conn);
char *event_msg;
- sasprintf(&event_msg, "{\"change\":\"%s\"}", mode->name);
+ sasprintf(&event_msg, "{\"change\":\"%s\", \"pango_markup\":%s}",
+ mode->name, (mode->pango_markup ? "true" : "false"));
ipc_send_event("mode", I3_IPC_EVENT_MODE, event_msg);
FREE(event_msg);