summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-10-11 16:54:17 +0200
committerRan Benita <ran234@gmail.com>2012-10-11 16:54:17 +0200
commitbbf388ec1f632f648b0e1323fe90c251c0425bf7 (patch)
treec71d8425c76d7323e6acd9f11ef873cd73130e4a /test
parentb6ddd105686aaa7accb63d5fe9c228cc4d7b1db0 (diff)
downloadlibxkbcommon-bbf388ec1f632f648b0e1323fe90c251c0425bf7.tar.gz
libxkbcommon-bbf388ec1f632f648b0e1323fe90c251c0425bf7.tar.bz2
libxkbcommon-bbf388ec1f632f648b0e1323fe90c251c0425bf7.zip
Make xkb_keymap_num_leds return the index range instead of active count
Currently xkb_keymap_num_leds() returns a count of valid (settable) leds. Because the indexes might be non-consecutive, and some leds might not be settable, it is incorrect to use this function for iterating over the leds in the keymap. But this is the main use case of this function, so instead of the current behavior we adapt the function to the use case by making it return the needed range of iteration. The caller needs to handle invalid intermittent indexes, though. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/interactive.c2
-rw-r--r--test/state.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/test/interactive.c b/test/interactive.c
index 8162d8d..15442c9 100644
--- a/test/interactive.c
+++ b/test/interactive.c
@@ -274,7 +274,7 @@ print_keycode(struct keyboard *kbd, xkb_keycode_t keycode)
printf("] ");
printf("leds [ ");
- for (led = 0; led < sizeof(xkb_led_mask_t) * 8; led++) {
+ for (led = 0; led < xkb_keymap_num_leds(keymap); led++) {
if (xkb_state_led_index_is_active(state, led) <= 0)
continue;
printf("%s ", xkb_keymap_led_get_name(keymap, led));
diff --git a/test/state.c b/test/state.c
index ee5abce..cafc264 100644
--- a/test/state.c
+++ b/test/state.c
@@ -82,7 +82,7 @@ print_state(struct xkb_state *state)
"locked " : "");
}
- for (led = 0; led < sizeof(xkb_led_mask_t) * 8; led++) {
+ for (led = 0; led < xkb_keymap_num_leds(keymap); led++) {
if (xkb_state_led_index_is_active(state, led) <= 0)
continue;
fprintf(stderr, "\tled %s (%d): active\n",