no free keycodes, pick last two keycodes anyway.

This commit is contained in:
Miroslav Šedivý 2023-01-14 20:38:37 +01:00
parent 67cc23fd53
commit eac9796c47

View File

@ -191,11 +191,24 @@ void XFreeKeycodesInit(Display* dpy) {
last = entry; last = entry;
} }
if (last != NULL) { // no free keycodes, pick last two keycodes anyway
// make as circular list if (last == NULL) {
last->next = xFreeKeycodesHead; xkeycode_t *entry1 = (xkeycode_t *) malloc(sizeof(xkeycode_t));
if (entry1 == NULL) return;
entry1->keycode = max-1;
xkeycode_t *entry2 = (xkeycode_t *) malloc(sizeof(xkeycode_t));
if (entry2 == NULL) return;
entry2->keycode = max-2;
xFreeKeycodesHead = entry1;
entry1->next = entry2;
last = entry2;
} }
// make as circular list
last->next = xFreeKeycodesHead;
XFree(keysyms); XFree(keysyms);
} }