mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
input: don’t crash if xkbcommon cannot find a compose file
Handle xkb_compose_table_new_from_locale() returning NULL. When this happens, log a warning that “dead keys” will be disabled, and make sure to never de-reference the compose table pointer. Closes #170
This commit is contained in:
parent
e6737034e5
commit
0573c685c7
2 changed files with 30 additions and 8 deletions
|
|
@ -47,6 +47,12 @@
|
|||
### Deprecated
|
||||
### Removed
|
||||
### Fixed
|
||||
|
||||
* Crash when libxkbcommon cannot find a suitable libX11 _compose_
|
||||
file. Note that foot will run, but without support for dead keys.
|
||||
(https://codeberg.org/dnkl/foot/issues/170).
|
||||
|
||||
|
||||
### Security
|
||||
### Contributors
|
||||
|
||||
|
|
|
|||
32
input.c
32
input.c
|
|
@ -504,8 +504,13 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
|||
/* Compose (dead keys) */
|
||||
seat->kbd.xkb_compose_table = xkb_compose_table_new_from_locale(
|
||||
seat->kbd.xkb, setlocale(LC_CTYPE, NULL), XKB_COMPOSE_COMPILE_NO_FLAGS);
|
||||
seat->kbd.xkb_compose_state = xkb_compose_state_new(
|
||||
seat->kbd.xkb_compose_table, XKB_COMPOSE_STATE_NO_FLAGS);
|
||||
|
||||
if (seat->kbd.xkb_compose_table == NULL) {
|
||||
LOG_WARN("failed to instantiate compose table; dead keys will not work");
|
||||
} else {
|
||||
seat->kbd.xkb_compose_state = xkb_compose_state_new(
|
||||
seat->kbd.xkb_compose_table, XKB_COMPOSE_STATE_NO_FLAGS);
|
||||
}
|
||||
|
||||
munmap(map_str, size);
|
||||
close(fd);
|
||||
|
|
@ -604,7 +609,8 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
|||
seat->kbd.alt = false;
|
||||
seat->kbd.ctrl = false;
|
||||
seat->kbd.meta = false;
|
||||
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
|
||||
if (seat->kbd.xkb_compose_state != NULL)
|
||||
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
|
||||
|
||||
if (old_focused != NULL) {
|
||||
seat->pointer.hidden = false;
|
||||
|
|
@ -782,9 +788,13 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
|||
LOG_INFO("%s", foo);
|
||||
#endif
|
||||
|
||||
xkb_compose_state_feed(seat->kbd.xkb_compose_state, sym);
|
||||
enum xkb_compose_status compose_status = xkb_compose_state_get_status(
|
||||
seat->kbd.xkb_compose_state);
|
||||
enum xkb_compose_status compose_status = XKB_COMPOSE_NOTHING;
|
||||
|
||||
if (seat->kbd.xkb_compose_state != NULL) {
|
||||
xkb_compose_state_feed(seat->kbd.xkb_compose_state, sym);
|
||||
compose_status = xkb_compose_state_get_status(
|
||||
seat->kbd.xkb_compose_state);
|
||||
}
|
||||
|
||||
if (compose_status == XKB_COMPOSE_COMPOSING) {
|
||||
/* TODO: goto maybe_repeat? */
|
||||
|
|
@ -868,12 +878,18 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
|||
int count = 0;
|
||||
|
||||
if (compose_status == XKB_COMPOSE_COMPOSED) {
|
||||
assert(seat->kbd.xkb_compose_state != NULL);
|
||||
|
||||
count = xkb_compose_state_get_utf8(
|
||||
seat->kbd.xkb_compose_state, (char *)buf, sizeof(buf));
|
||||
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
|
||||
} else if (compose_status == XKB_COMPOSE_CANCELLED) {
|
||||
}
|
||||
|
||||
else if (compose_status == XKB_COMPOSE_CANCELLED) {
|
||||
goto maybe_repeat;
|
||||
} else {
|
||||
}
|
||||
|
||||
else {
|
||||
count = xkb_state_key_get_utf8(
|
||||
seat->kbd.xkb_state, key, (char *)buf, sizeof(buf));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue