test: print the keyboard state as part of test_key_seq_va

Makes it easier to debug modifier bugs.
master
Peter Hutterer 2024-02-14 11:41:12 +10:00
parent be1c2f27ce
commit 5270a55324
2 changed files with 11 additions and 2 deletions

View File

@ -434,6 +434,7 @@ if build_tools
link_with: libxkbcommon_tools_internal,
dependencies: dep_libxkbcommon,
)
configh_data.set10('HAVE_TOOLS', true)
# Tool: xkbcli
executable('xkbcli', 'tools/xkbcli.c',
@ -586,6 +587,8 @@ You can disable the Wayland xkbcli programs with -Denable-wayland=false.''')
dependencies: [tools_dep],
include_directories: [include_directories('src', 'include', 'tools')],
install: false)
else
tools_dep = declare_dependency()
endif
@ -628,6 +631,7 @@ libxkbcommon_test_internal = static_library(
test_dep = declare_dependency(
include_directories: include_directories('src', 'include'),
link_with: libxkbcommon_test_internal,
dependencies: [tools_dep],
)
if get_option('enable-x11')
libxkbcommon_x11_test_internal = static_library(

View File

@ -49,6 +49,8 @@
#include "utils.h"
#include "src/keysym.h"
#include "tools/tools-common.h"
/*
* Test a sequence of keysyms, resulting from a sequence of key presses,
* against the keysyms they're supposed to generate.
@ -104,13 +106,16 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap)
syms = &sym;
}
fprintf(stderr, "op %-6s got %u syms for keycode %3u: [", opstr, nsyms, kc);
if (op == DOWN || op == BOTH)
xkb_state_update_key(state, kc, XKB_KEY_DOWN);
if (op == UP || op == BOTH)
xkb_state_update_key(state, kc, XKB_KEY_UP);
#if HAVE_TOOLS
tools_print_keycode_state("", state, NULL, kc, XKB_CONSUMED_MODE_XKB, PRINT_ALL_FIELDS);
#endif
fprintf(stderr, "op %-6s got %u syms for keycode %3u: [", opstr, nsyms, kc);
for (i = 0; i < nsyms; i++) {
keysym = va_arg(ap, int);
xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf));