Skip to content

馃崚[kcms/keyboard] tastenbrett: more correct handling of xkb_keysym_*

Harald Sitter requested to merge work/cherry-pick-fcf07db7 into Plasma/6.1
  • Fix off-by-one. xkb_keysym_get_name returns the needed size without the trailing NUL byte. Since there are apparently no keysyms larger than 32 bytes, to test the potential problem chars could be made e.g. 15 bytes large, and then "dead_circumflex", "dead_doubleacute", "ISO_Level3_Shift", ... would get truncated.
  • xkb_keysym_to_utf8 returns at most 5 (4 bytes for the encoding of a Unicode character between 0x00010000 and 0x0010FFFF plus a trailing NUL byte), so no need to check for size > chars.size().
  • The return value of xkb_keysym_to_utf8 includes the trailing NUL byte, so substract one to create a QString which does not include that NUL byte.
  • Explicitly return an empty QString when xkb_keysym_to_utf8 returns 0. This wasn't previously needed, see previous bullet point.

(cherry picked from commit fcf07db7)

Co-authored-by: Luis Javier Merino Mor谩n ninjalj@gmail.com

Merge request reports