Fixing the problem of repeating keys.

master
Christoph Lohmann 12 years ago
parent fc23b8e713
commit d356e43d9c
  1. 34
      svkbd.c

@ -63,7 +63,6 @@ static void buttonrelease(XEvent *e);
static void cleanup(void); static void cleanup(void);
static void configurenotify(XEvent *e); static void configurenotify(XEvent *e);
static void countrows(); static void countrows();
static void unmapnotify(XEvent *e);
static void die(const char *errstr, ...); static void die(const char *errstr, ...);
static void drawkeyboard(void); static void drawkeyboard(void);
static void drawkey(Key *k); static void drawkey(Key *k);
@ -85,7 +84,6 @@ static void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress, [ButtonPress] = buttonpress,
[ButtonRelease] = buttonrelease, [ButtonRelease] = buttonrelease,
[ConfigureNotify] = configurenotify, [ConfigureNotify] = configurenotify,
[UnmapNotify] = unmapnotify,
[Expose] = expose, [Expose] = expose,
[LeaveNotify] = leavenotify, [LeaveNotify] = leavenotify,
[MotionNotify] = motionnotify [MotionNotify] = motionnotify
@ -128,7 +126,8 @@ motionnotify(XEvent *e)
} }
if(!IsModifierKey(keys[i].keysym) && keys[i].pressed == True) { if(!IsModifierKey(keys[i].keysym) && keys[i].pressed == True) {
keys[i].pressed = False; unpress(&keys[i], 0);
drawkey(&keys[i]); drawkey(&keys[i]);
} }
if(keys[i].highlighted == True) { if(keys[i].highlighted == True) {
@ -172,8 +171,13 @@ buttonrelease(XEvent *e) {
break; break;
} }
} }
if((k = findkey(ev->x, ev->y)))
unpress(k, mod); if(ev->x < 0 || ev->y < 0) {
unpress(NULL, mod);
} else {
if((k = findkey(ev->x, ev->y)))
unpress(k, mod);
}
} }
void void
@ -274,11 +278,6 @@ drawkey(Key *k) {
k->x, k->y); k->x, k->y);
} }
void
unmapnotify(XEvent *e) {
running = False;
}
void void
expose(XEvent *e) { expose(XEvent *e) {
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
@ -399,14 +398,15 @@ unpress(Key *k, KeySym mod) {
break; break;
} }
} }
if(i != LENGTH(keys)) { if(i != LENGTH(keys)) {
if(pressedmod) {
XTestFakeKeyEvent(dpy,
XKeysymToKeycode(dpy, pressedmod),
False, 0);
}
pressedmod = 0;
for(i = 0; i < LENGTH(keys); i++) { for(i = 0; i < LENGTH(keys); i++) {
if(pressedmod) {
XTestFakeKeyEvent(dpy,
XKeysymToKeycode(dpy, pressedmod),
False, 0);
}
pressedmod = 0;
if(keys[i].pressed) { if(keys[i].pressed) {
XTestFakeKeyEvent(dpy, XTestFakeKeyEvent(dpy,
XKeysymToKeycode(dpy, XKeysymToKeycode(dpy,

Loading…
Cancel
Save