Revert "Bugfix: set group mask 1 by default, correctly compare modifiers"
This reverts commit 9692c1498b
.
That commit accidentally defaulted to group mask 1, but the default
should be to match any group mask, so that having multiple layouts
loaded at the same time works.
fixes #2062
This commit is contained in:
parent
ff63104a2d
commit
e48c4cd257
|
@ -165,18 +165,28 @@ static Binding *get_binding(i3_event_state_mask_t state_filtered, bool is_releas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint32_t xkb_group_state = (state_filtered & 0xFFFF0000);
|
||||||
|
const uint32_t modifiers_state = (state_filtered & 0x0000FFFF);
|
||||||
TAILQ_FOREACH(bind, bindings, bindings) {
|
TAILQ_FOREACH(bind, bindings, bindings) {
|
||||||
bool state_matches;
|
const uint32_t xkb_group_mask = (bind->event_state_mask & 0xFFFF0000);
|
||||||
if ((bind->event_state_mask & 0xFFFF) == 0) {
|
/* modifiers_mask is a special case: a value of 0 does not mean “match all”,
|
||||||
|
* but rather “match exactly when no modifiers are present”. */
|
||||||
|
const uint32_t modifiers_mask = (bind->event_state_mask & 0x0000FFFF);
|
||||||
|
const bool groups_match = ((xkb_group_state & xkb_group_mask) == xkb_group_mask);
|
||||||
|
bool mods_match;
|
||||||
|
if (modifiers_mask == 0) {
|
||||||
/* Verify no modifiers are pressed. A bitwise AND would lead to
|
/* Verify no modifiers are pressed. A bitwise AND would lead to
|
||||||
* false positives, see issue #2002. */
|
* false positives, see issue #2002. */
|
||||||
state_matches = (state_filtered == bind->event_state_mask);
|
mods_match = (modifiers_state == 0);
|
||||||
} else {
|
} else {
|
||||||
state_matches = ((state_filtered & bind->event_state_mask) == bind->event_state_mask);
|
mods_match = ((modifiers_state & modifiers_mask) == modifiers_mask);
|
||||||
}
|
}
|
||||||
|
const bool state_matches = (groups_match && mods_match);
|
||||||
|
|
||||||
DLOG("binding with event_state_mask 0x%x, state_filtered 0x%x, match: %s\n",
|
DLOG("binding groups_match = %s, mods_match = %s, state_matches = %s\n",
|
||||||
bind->event_state_mask, state_filtered, (state_matches ? "yes" : "no"));
|
(groups_match ? "yes" : "no"),
|
||||||
|
(mods_match ? "yes" : "no"),
|
||||||
|
(state_matches ? "yes" : "no"));
|
||||||
/* First compare the state_filtered (unless this is a
|
/* First compare the state_filtered (unless this is a
|
||||||
* B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
|
* B_UPON_KEYRELEASE_IGNORE_MODS binding and this is a KeyRelease
|
||||||
* event) */
|
* event) */
|
||||||
|
|
|
@ -67,9 +67,8 @@ i3_event_state_mask_t event_state_from_str(const char *str) {
|
||||||
/* It might be better to use strtok() here, but the simpler strstr() should
|
/* It might be better to use strtok() here, but the simpler strstr() should
|
||||||
* do for now. */
|
* do for now. */
|
||||||
i3_event_state_mask_t result = 0;
|
i3_event_state_mask_t result = 0;
|
||||||
int group_bits_set = 0;
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return (I3_XKB_GROUP_MASK_1 << 16);
|
return result;
|
||||||
if (strstr(str, "Mod1") != NULL)
|
if (strstr(str, "Mod1") != NULL)
|
||||||
result |= XCB_KEY_BUT_MASK_MOD_1;
|
result |= XCB_KEY_BUT_MASK_MOD_1;
|
||||||
if (strstr(str, "Mod2") != NULL)
|
if (strstr(str, "Mod2") != NULL)
|
||||||
|
@ -86,26 +85,15 @@ i3_event_state_mask_t event_state_from_str(const char *str) {
|
||||||
if (strstr(str, "Shift") != NULL)
|
if (strstr(str, "Shift") != NULL)
|
||||||
result |= XCB_KEY_BUT_MASK_SHIFT;
|
result |= XCB_KEY_BUT_MASK_SHIFT;
|
||||||
|
|
||||||
if (strstr(str, "Group1") != NULL) {
|
if (strstr(str, "Group1") != NULL)
|
||||||
result |= (I3_XKB_GROUP_MASK_1 << 16);
|
result |= (I3_XKB_GROUP_MASK_1 << 16);
|
||||||
group_bits_set++;
|
|
||||||
}
|
|
||||||
if (strstr(str, "Group2") != NULL ||
|
if (strstr(str, "Group2") != NULL ||
|
||||||
strstr(str, "Mode_switch") != NULL) {
|
strstr(str, "Mode_switch") != NULL)
|
||||||
result |= (I3_XKB_GROUP_MASK_2 << 16);
|
result |= (I3_XKB_GROUP_MASK_2 << 16);
|
||||||
group_bits_set++;
|
if (strstr(str, "Group3") != NULL)
|
||||||
}
|
|
||||||
if (strstr(str, "Group3") != NULL) {
|
|
||||||
result |= (I3_XKB_GROUP_MASK_3 << 16);
|
result |= (I3_XKB_GROUP_MASK_3 << 16);
|
||||||
group_bits_set++;
|
if (strstr(str, "Group4") != NULL)
|
||||||
}
|
|
||||||
if (strstr(str, "Group4") != NULL) {
|
|
||||||
result |= (I3_XKB_GROUP_MASK_4 << 16);
|
result |= (I3_XKB_GROUP_MASK_4 << 16);
|
||||||
group_bits_set++;
|
|
||||||
}
|
|
||||||
if (group_bits_set == 0) {
|
|
||||||
result |= (I3_XKB_GROUP_MASK_1 << 16);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue