Skip to content

Commit

Permalink
test: print the keyboard state as part of test_key_seq_va
Browse files Browse the repository at this point in the history
Makes it easier to debug modifier bugs.
  • Loading branch information
whot committed Feb 14, 2024
1 parent e9af069 commit b02058d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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(
Expand Down
9 changes: 7 additions & 2 deletions test/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit b02058d

Please sign in to comment.