Widen keycode range to 8/255 if possible (bug #63390)

If the keycode range is smaller than 8 → 255, artifically widen it when
dumping the keymap as not to displease X.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2013-05-09 14:47:09 +01:00
parent a392d2682b
commit 17a956d807
3 changed files with 21 additions and 0 deletions

View File

@ -93,6 +93,18 @@ memdup(const void *mem, size_t nmemb, size_t size)
return p; return p;
} }
static inline int
min(int misc, int other)
{
return (misc < other) ? misc : other;
}
static inline int
max(int misc, int other)
{
return (misc > other) ? misc : other;
}
bool bool
map_file(FILE *file, const char **string_out, size_t *size_out); map_file(FILE *file, const char **string_out, size_t *size_out);

View File

@ -157,6 +157,13 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf)
else else
write_buf(buf, "xkb_keycodes {\n"); write_buf(buf, "xkb_keycodes {\n");
/* xkbcomp and X11 really want to see keymaps with a minimum of 8, and
* a maximum of at least 255, else XWayland really starts hating life.
* If this is a problem and people really need strictly bounded keymaps,
* we should probably control this with a flag. */
write_buf(buf, "\tminimum = %d;\n", min(keymap->min_key_code, 8));
write_buf(buf, "\tmaximum = %d;\n", max(keymap->max_key_code, 255));
xkb_foreach_key(key, keymap) { xkb_foreach_key(key, keymap) {
if (key->name == XKB_ATOM_NONE) if (key->name == XKB_ATOM_NONE)
continue; continue;

View File

@ -1,5 +1,7 @@
xkb_keymap { xkb_keymap {
xkb_keycodes "evdev_aliases(qwerty)" { xkb_keycodes "evdev_aliases(qwerty)" {
minimum = 8;
maximum = 255;
<ESC> = 9; <ESC> = 9;
<AE01> = 10; <AE01> = 10;
<AE02> = 11; <AE02> = 11;