summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rio/wind.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2023-02-06 19:04:15 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2023-02-06 19:04:15 +0000
commite982ca2f8d6779b6b103a0d812d61f88f2338294 (patch)
tree6b4068449f2c5ea93ce8e1a02c4bfd7bc87d07a8 /sys/src/cmd/rio/wind.c
parent32acb3ebd8ecb684a4db054febc082b99d5957be (diff)
rio: refactor the keyboardtap code a bit
run the keyboardtap as a thread instead of a proc so that we can read input window variable. This gets rid of the wintap channel. do focus handling by tracking the last window and only send context switch when we start typing into a different window. have fromtap, totap channels created by open and use the variable also as the in-use flag. handle use nbsendp() when sending to the tap program, as it might be blocked or misbehaving. if the totap channel is full, we bypass the tap and send to input again. handle keyup on focus loss in the window thread instead (just like the artificial mouseup) it is unrelated to keyboardtap.
Diffstat (limited to 'sys/src/cmd/rio/wind.c')
-rw-r--r--sys/src/cmd/rio/wind.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index 0bb63c83a..80e00eae7 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -83,14 +83,12 @@ wcurrent(Window *w)
Channel *c;
if(input == nil){
- sendp(wintap, w);
input = w;
return;
}
if(w == input)
return;
incref(input);
- sendp(wintap, w);
c = chancreate(sizeof(Window*), 0);
wsendctlmesg(input, Repaint, ZR, c);
sendp(c, w); /* send the new input */
@@ -1305,7 +1303,6 @@ wclunk(Window *w)
return;
w->deleted = TRUE;
if(w == input){
- sendp(wintap, nil);
input = nil;
riosetcursor(nil);
}
@@ -1384,11 +1381,12 @@ wctlmesg(Window *w, int m, Rectangle r, void *p)
Channel *c = p;
input = recvp(c);
- /* when we lost input, release mouse buttons */
+ /* when we lost input, release mouse and keyboard buttons */
if(w->mc.buttons){
w->mc.buttons = 0;
w->mouse.counter++;
}
+ w->keyup = w->kbdopen;
w->wctlready = 1;
sendp(c, w);
@@ -1559,9 +1557,9 @@ winctl(void *arg)
alts[WWread].op = CHANNOP;
alts[WCread].op = CHANNOP;
} else {
- alts[WKbdread].op = (w->kbdopen && kbdqw != kbdqr) ?
+ alts[WKbdread].op = w->kbdopen && (kbdqw != kbdqr || w->keyup) ?
CHANSND : CHANNOP;
- alts[WMouseread].op = (w->mouseopen && w->mouse.counter != w->mouse.lastcounter) ?
+ alts[WMouseread].op = w->mouseopen && w->mouse.counter != w->mouse.lastcounter ?
CHANSND : CHANNOP;
alts[WCwrite].op = w->scrolling || w->mouseopen || (w->qh <= w->org+w->nchars) ?
CHANSND : CHANNOP;
@@ -1615,6 +1613,11 @@ winctl(void *arg)
nb += i;
kbdqr++;
}
+ if(w->keyup && nb+2 <= pair.ns){
+ w->keyup = 0;
+ memmove((char*)pair.s + nb, "K", 2);
+ nb += 2;
+ }
pair.ns = nb;
send(crm.c2, &pair);
continue;