mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
loopbreaker and fixes
This commit is contained in:
parent
9386cbb2e2
commit
7f226842df
@ -30,6 +30,7 @@ void insertItem(unsigned long value, KeyCode keycode) {
|
|||||||
|
|
||||||
void deleteItem(unsigned long value) {
|
void deleteItem(unsigned long value) {
|
||||||
node *myNode = head, *previous = NULL;
|
node *myNode = head, *previous = NULL;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
while (myNode) {
|
while (myNode) {
|
||||||
if (myNode->number == value) {
|
if (myNode->number == value) {
|
||||||
@ -44,11 +45,17 @@ void deleteItem(unsigned long value) {
|
|||||||
|
|
||||||
previous = myNode;
|
previous = myNode;
|
||||||
myNode = myNode->next;
|
myNode = myNode->next;
|
||||||
|
if (i++ > 120) {
|
||||||
|
// this should lead to a panic
|
||||||
|
printf("loop over limit");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node *searchItemNode(unsigned long value) {
|
node *searchItemNode(unsigned long value) {
|
||||||
node *searchNode = head;
|
node *searchNode = head;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
while (searchNode) {
|
while (searchNode) {
|
||||||
if (searchNode->number == value) {
|
if (searchNode->number == value) {
|
||||||
@ -56,6 +63,12 @@ node *searchItemNode(unsigned long value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchNode = searchNode->next;
|
searchNode = searchNode->next;
|
||||||
|
|
||||||
|
if (i++ > 120) {
|
||||||
|
// this should lead to a panic
|
||||||
|
printf("loop over limit");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -151,24 +164,27 @@ void XButton(unsigned int button, int down) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyCode XkbKeysymToKeycode(KeySym keysym) {
|
KeyCode XkbKeysymToKeycode(Display *dpy, KeySym keysym) {
|
||||||
XkbDescPtr xkb;
|
XkbDescPtr xkb;
|
||||||
XkbStateRec state;
|
XkbStateRec state;
|
||||||
|
unsigned int mods;
|
||||||
unsigned keycode;
|
unsigned keycode;
|
||||||
Display *dpy = getXDisplay();
|
|
||||||
|
|
||||||
xkb = XkbGetMap(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
|
xkb = XkbGetMap(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
|
||||||
if (!xkb)
|
if (!xkb)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
XkbGetState(dpy, XkbUseCoreKbd, &state);
|
XkbGetState(dpy, XkbUseCoreKbd, &state);
|
||||||
|
// XkbStateFieldFromRec() doesn't work properly because
|
||||||
|
// state.lookup_mods isn't properly updated, so we do this manually
|
||||||
|
mods = XkbBuildCoreState(XkbStateMods(&state), state.group);
|
||||||
|
|
||||||
for (keycode = xkb->min_key_code;
|
for (keycode = xkb->min_key_code;
|
||||||
keycode <= xkb->max_key_code;
|
keycode <= xkb->max_key_code;
|
||||||
keycode++) {
|
keycode++) {
|
||||||
KeySym cursym;
|
KeySym cursym;
|
||||||
unsigned int mods;
|
unsigned int out_mods;
|
||||||
XkbTranslateKeyCode(xkb, keycode, state.compat_state, &mods, &cursym);
|
XkbTranslateKeyCode(xkb, keycode, mods, &out_mods, &cursym);
|
||||||
if (cursym == keysym)
|
if (cursym == keysym)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -178,6 +194,11 @@ KeyCode XkbKeysymToKeycode(KeySym keysym) {
|
|||||||
|
|
||||||
XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
||||||
|
|
||||||
|
// Shift+Tab is usually ISO_Left_Tab, but RFB hides this fact. Do
|
||||||
|
// another attempt if we failed the initial lookup
|
||||||
|
if ((keycode == 0) && (keysym == XK_Tab) && (mods & ShiftMask))
|
||||||
|
return XkbKeysymToKeycode(dpy, XK_ISO_Left_Tab);
|
||||||
|
|
||||||
return keycode;
|
return keycode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +222,7 @@ void XKey(unsigned long key, int down) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = XkbKeysymToKeycode(key);
|
code = XkbKeysymToKeycode(display, key);
|
||||||
if (!code) {
|
if (!code) {
|
||||||
int min, max, numcodes;
|
int min, max, numcodes;
|
||||||
XDisplayKeycodes(display, &min, &max);
|
XDisplayKeycodes(display, &min, &max);
|
||||||
|
Loading…
Reference in New Issue
Block a user