Skip to content

Commit bf4b374

Browse files
committed
[input_dispatcher] fix multi-byte input handling
Related to #1529
1 parent e9b3ed0 commit bf4b374

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/input_dispatcher.cc

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ input_dispatcher::new_input(const struct timeval& current_time,
6868
std::string eff_str;
6969

7070
for (size_t lpc = 0; ch.eff_text[lpc]; lpc++) {
71-
fmt::format_to(
72-
std::back_inserter(eff_str), FMT_STRING("{:02x}"), ch.eff_text[lpc]);
71+
fmt::format_to(std::back_inserter(eff_str),
72+
FMT_STRING("{:02x}"),
73+
ch.eff_text[lpc]);
7374
}
7475
log_debug("new input %x %d/%x(%c)/%s/%s evtype=%d",
7576
ch.modifiers,
@@ -110,19 +111,11 @@ input_dispatcher::new_input(const struct timeval& current_time,
110111
log_debug("nckey %s", keyseq.data());
111112
handled = this->id_key_handler(nc, ch, keyseq.data());
112113
} else {
113-
auto seq_size = utf::utf8::char_size([&ch]() {
114-
return std::make_pair(ch.eff_text[0], 16);
115-
}).unwrapOr(size_t{1});
116-
log_debug("seq_size %d", seq_size);
117-
if (seq_size == 1) {
118-
snprintf(
119-
keyseq.data(), keyseq.size(), "x%02x", ch.eff_text[0] & 0xff);
120-
log_debug("key %s", keyseq.data());
121-
handled = this->id_key_handler(nc, ch, keyseq.data());
122-
}
114+
to_key_seq(keyseq, ch.utf8);
115+
handled = this->id_key_handler(nc, ch, keyseq.data());
123116
}
124117

125118
if (handled && !handled.value()) {
126119
this->id_unhandled_handler(keyseq.data());
127120
}
128-
}
121+
}

0 commit comments

Comments
 (0)