diff options
author | Ran Benita <ran234@gmail.com> | 2013-02-19 15:57:14 +0200 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2013-03-18 22:20:02 +0000 |
commit | c7aef1664922b47cdc8ea06513d0e1898889bfe3 (patch) | |
tree | 733b00be35f42a1b3a88dba8118e017a1b1d3896 /src | |
parent | dd81d5e0c00e8d80f62b29a1c67752e84215f354 (diff) |
keysym: print unicode keysyms uppercase and 0-padded
Use the same format as XKeysymToString.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/keysym.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/keysym.c b/src/keysym.c index f80a1ed..1e92a4a 100644 --- a/src/keysym.c +++ b/src/keysym.c @@ -85,9 +85,11 @@ xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size) if (entry) return snprintf(buffer, size, "%s", entry->name); - if (ks >= 0x01000100 && ks <= 0x0110ffff) - /* Unnamed Unicode codepoint. */ - return snprintf(buffer, size, "U%lx", ks & 0xffffffUL); + /* Unnamed Unicode codepoint. */ + if (ks >= 0x01000100 && ks <= 0x0110ffff) { + const int width = (ks & 0xff0000UL) ? 8 : 4; + return snprintf(buffer, size, "U%0*lX", width, ks & 0xffffffUL); + } /* Unnamed, non-Unicode, symbol (shouldn't generally happen). */ return snprintf(buffer, size, "0x%08x", ks); |