Fixing the problem of repeating keys.

master
Christoph Lohmann 12 years ago
parent fc23b8e713
commit d356e43d9c
  1. 18
      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(ev->x < 0 || ev->y < 0) {
unpress(NULL, mod);
} else {
if((k = findkey(ev->x, ev->y))) if((k = findkey(ev->x, ev->y)))
unpress(k, mod); 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;
@ -400,13 +399,14 @@ unpress(Key *k, KeySym mod) {
} }
} }
if(i != LENGTH(keys)) { if(i != LENGTH(keys)) {
for(i = 0; i < LENGTH(keys); i++) {
if(pressedmod) { if(pressedmod) {
XTestFakeKeyEvent(dpy, XTestFakeKeyEvent(dpy,
XKeysymToKeycode(dpy, pressedmod), XKeysymToKeycode(dpy, pressedmod),
False, 0); False, 0);
} }
pressedmod = 0; pressedmod = 0;
for(i = 0; i < LENGTH(keys); i++) {
if(keys[i].pressed) { if(keys[i].pressed) {
XTestFakeKeyEvent(dpy, XTestFakeKeyEvent(dpy,
XKeysymToKeycode(dpy, XKeysymToKeycode(dpy,

Loading…
Cancel
Save