keymap = xkb_state_get_map(state);
for (group = 0; group < xkb_map_num_groups(keymap); group++) {
- if (!xkb_state_group_index_is_active(state, group, XKB_STATE_EFFECTIVE))
+ if (xkb_state_group_index_is_active(state, group, XKB_STATE_EFFECTIVE) != 1)
continue;
fprintf(stderr, "\tgroup %s (%d): %s%s%s%s\n",
xkb_map_group_get_name(keymap, group),
group,
- xkb_state_group_index_is_active(state, group, XKB_STATE_EFFECTIVE) ?
+ xkb_state_group_index_is_active(state, group, XKB_STATE_EFFECTIVE) > 0 ?
"effective " : "",
- xkb_state_group_index_is_active(state, group, XKB_STATE_DEPRESSED) ?
+ xkb_state_group_index_is_active(state, group, XKB_STATE_DEPRESSED) > 0 ?
"depressed " : "",
- xkb_state_group_index_is_active(state, group, XKB_STATE_LATCHED) ?
+ xkb_state_group_index_is_active(state, group, XKB_STATE_LATCHED) > 0 ?
"latched " : "",
- xkb_state_group_index_is_active(state, group, XKB_STATE_LOCKED) ?
+ xkb_state_group_index_is_active(state, group, XKB_STATE_LOCKED) > 0 ?
"locked " : "");
}
fprintf(stderr, "\tmod %s (%d): %s%s%s\n",
xkb_map_mod_get_name(keymap, mod),
mod,
- xkb_state_mod_index_is_active(state, mod, XKB_STATE_DEPRESSED) ?
+ xkb_state_mod_index_is_active(state, mod, XKB_STATE_DEPRESSED) > 0 ?
"depressed " : "",
- xkb_state_mod_index_is_active(state, mod, XKB_STATE_LATCHED) ?
+ xkb_state_mod_index_is_active(state, mod, XKB_STATE_LATCHED) > 0 ?
"latched " : "",
- xkb_state_mod_index_is_active(state, mod, XKB_STATE_LOCKED) ?
+ xkb_state_mod_index_is_active(state, mod, XKB_STATE_LOCKED) > 0 ?
"locked " : "");
}
fprintf(stderr, "dumping state for LCtrl down:\n");
print_state(state);
assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL,
- XKB_STATE_DEPRESSED));
+ XKB_STATE_DEPRESSED) > 0);
/* LCtrl + RAlt down */
xkb_state_update_key(state, KEY_RIGHTALT + EVDEV_OFFSET, XKB_KEY_DOWN);
fprintf(stderr, "dumping state for LCtrl + RAlt down:\n");
print_state(state);
assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL,
- XKB_STATE_DEPRESSED));
+ XKB_STATE_DEPRESSED) > 0);
assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT,
- XKB_STATE_DEPRESSED));
+ XKB_STATE_DEPRESSED) > 0);
assert(xkb_state_mod_names_are_active(state, XKB_STATE_DEPRESSED,
XKB_STATE_MATCH_ALL,
XKB_MOD_NAME_CTRL,
XKB_MOD_NAME_ALT,
- NULL));
+ NULL) > 0);
+ assert(xkb_state_mod_indices_are_active(state, XKB_STATE_DEPRESSED,
+ XKB_STATE_MATCH_ALL,
+ xkb_map_mod_get_index(keymap, XKB_MOD_NAME_CTRL),
+ xkb_map_mod_get_index(keymap, XKB_MOD_NAME_ALT),
+ XKB_MOD_INVALID) > 0);
assert(!xkb_state_mod_names_are_active(state, XKB_STATE_DEPRESSED,
XKB_STATE_MATCH_ALL,
XKB_MOD_NAME_ALT,
- NULL));
+ NULL) > 0);
assert(xkb_state_mod_names_are_active(state, XKB_STATE_DEPRESSED,
(XKB_STATE_MATCH_ANY |
XKB_STATE_MATCH_NON_EXCLUSIVE),
fprintf(stderr, "dumping state for RAlt down:\n");
print_state(state);
assert(!xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL,
- XKB_STATE_EFFECTIVE));
+ XKB_STATE_EFFECTIVE) > 0);
assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT,
- XKB_STATE_DEPRESSED));
+ XKB_STATE_DEPRESSED) > 0);
assert(xkb_state_mod_names_are_active(state, XKB_STATE_DEPRESSED,
XKB_STATE_MATCH_ANY,
XKB_MOD_NAME_CTRL,
XKB_MOD_NAME_ALT,
- NULL));
+ NULL) > 0);
/* none down */
xkb_state_update_key(state, KEY_RIGHTALT + EVDEV_OFFSET, XKB_KEY_UP);
fprintf(stderr, "dumping state for Caps Lock:\n");
print_state(state);
assert(xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CAPS,
- XKB_STATE_LOCKED));
- assert(xkb_state_led_name_is_active(state, XKB_LED_NAME_CAPS));
+ XKB_STATE_LOCKED) > 0);
+ assert(xkb_state_led_name_is_active(state, XKB_LED_NAME_CAPS) > 0);
num_syms = xkb_key_get_syms(state, KEY_Q + EVDEV_OFFSET, &syms);
assert(num_syms == 1 && syms[0] == XKB_KEY_Q);
xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_DOWN);
xkb_state_update_key(state, KEY_CAPSLOCK + EVDEV_OFFSET, XKB_KEY_UP);
assert(!xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CAPS,
- XKB_STATE_EFFECTIVE));
- assert(!xkb_state_led_name_is_active(state, XKB_LED_NAME_CAPS));
+ XKB_STATE_EFFECTIVE) > 0);
+ assert(!xkb_state_led_name_is_active(state, XKB_LED_NAME_CAPS) > 0);
num_syms = xkb_key_get_syms(state, KEY_Q + EVDEV_OFFSET, &syms);
assert(num_syms == 1 && syms[0] == XKB_KEY_q);
enum xkb_state_component type);
/**
- * Returns 1 if the modifiers specified by the varargs (treated as
- * NULL-terminated pointers to strings) are active in the manner
- * specified by 'match', 0 otherwise, or -1 if any of the modifiers
- * do not exist in the map.
+ * Returns 1 if the modifiers specified by the varargs (NULL-terminated
+ * strings, with a NULL sentinel) are active in the manner specified by
+ * 'match', 0 otherwise, or -1 if any of the modifiers do not exist in
+ * the map.
*/
int
xkb_state_mod_names_are_active(struct xkb_state *state,
enum xkb_state_component type);
/**
+ * Returns 1 if the modifiers specified by the varargs (of type
+ * xkb_mod_index_t, with a XKB_MOD_INVALID sentinel) are active in the
+ * manner specified by 'match' and 'type', 0 otherwise, or -1 if any of
+ * the modifiers do not exist in the map.
+ */
+int
+xkb_state_mod_indices_are_active(struct xkb_state *state,
+ enum xkb_state_component type,
+ enum xkb_state_match match,
+ ...);
+
+/**
* Returns 1 if the modifier specified by 'idx' is used in the
* translation of the keycode 'key' to the key symbols obtained by
* pressing it (as in xkb_key_get_syms), given the current state.
xkb_mod_mask_t mask);
/**
- * Returns 1 if the modifiers specified by the varargs (treated as
- * xkb_mod_index_t, terminated with XKB_MOD_INVALID) are active in the manner
- * specified by 'match' and 'type', 0 otherwise, or -1 if the modifier does not
- * exist in the current map.
- */
-int
-xkb_state_mod_indices_are_active(struct xkb_state *state,
- enum xkb_state_component type,
- enum xkb_state_match match,
- ...);
-
-/**
* Returns 1 if the group specified by 'name' is active in the manner
* specified by 'type', 0 if it is unset, or -1 if the group does not
* exist in the current map.