1
0
mirror of git://git.suckless.org/svkbd synced 2024-12-18 04:04:44 +00:00

drawkey does now copy the button to the window directly.

This commit is contained in:
Enno Boland (Gottox) 2008-07-16 10:10:35 +02:00
parent a48c0a4c28
commit 6436823105

17
svkbd.c
View File

@ -166,7 +166,6 @@ drawkeyboard(void) {
drawkey(&keys[i]); drawkey(&keys[i]);
} }
XSync(dpy, False); XSync(dpy, False);
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, wh, 0, 0);
} }
void void
@ -199,6 +198,7 @@ drawkey(Key *k) {
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, l, len); XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, l, len);
else else
XDrawString(dpy, dc.drawable, dc.gc, x, y, l, len); XDrawString(dpy, dc.drawable, dc.gc, x, y, l, len);
XCopyArea(dpy, dc.drawable, win, dc.gc, k->x, k->y, k->w, k->h, k->x, k->y);
} }
void void
@ -278,11 +278,13 @@ initfont(const char *fontstr) {
void void
leavenotify(XEvent *e) { leavenotify(XEvent *e) {
Key *oh = hover;
unpress(NULL); unpress(NULL);
if(!hover) if(!hover)
return; return;
hover = NULL; hover = NULL;
drawkeyboard(); drawkey(oh);
} }
void void
@ -293,12 +295,13 @@ motionnotify(XEvent *e) {
if(h != hover) { if(h != hover) {
oh = hover;; oh = hover;;
hover = h; hover = h;
if(oh) if(oh) {
drawkey(oh); drawkey(oh);
if(hover) }
if(hover) {
drawkey(hover); drawkey(hover);
}
} }
XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, wh, 0, 0);
} }
void void
@ -316,7 +319,6 @@ press(Key *k, KeySym mod) {
XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, k->keysym), True, 0); XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, k->keysym), True, 0);
} }
drawkey(k); drawkey(k);
XCopyArea(dpy, dc.drawable, win, dc.gc, k->x, k->y, k->w, k->h, k->x, k->y);
} }
void void
@ -393,6 +395,7 @@ unpress() {
if(keys[i].pressed && !IsModifierKey(keys[i].keysym)) { if(keys[i].pressed && !IsModifierKey(keys[i].keysym)) {
XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, keys[i].keysym), False, 0); XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, keys[i].keysym), False, 0);
keys[i].pressed = 0; keys[i].pressed = 0;
drawkey(&keys[i]);
break; break;
} }
if(i != LENGTH(keys)) { if(i != LENGTH(keys)) {
@ -403,9 +406,9 @@ unpress() {
if(keys[i].pressed) { if(keys[i].pressed) {
XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, keys[i].keysym), False, 0); XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, keys[i].keysym), False, 0);
keys[i].pressed = 0; keys[i].pressed = 0;
drawkey(&keys[i]);
} }
} }
drawkeyboard();
} }
} }