ref: 7daab6308be2a52987b760d4141ed79b3a31bdbd
dir: /9front.diff/
diff -r ab6ef2653d12 sys/src/cmd/rio/dat.h --- a/sys/src/cmd/rio/dat.h Mon Dec 07 15:15:02 2020 +0100 +++ b/sys/src/cmd/rio/dat.h Mon Dec 07 15:56:46 2020 +0100 @@ -346,11 +346,15 @@ char *startdir; int sweeping; int wctlfd; +int gkbdfd; +Channel* gkbdc; char srvpipe[]; char srvwctl[]; +char srvgkbd[]; int errorshouldabort; int menuing; /* menu action is pending; waiting for window to be indicated */ int snarfversion; /* updated each time it is written */ int messagesize; /* negotiated in 9P version setup */ int shiftdown; +int mod4down; int debug; diff -r ab6ef2653d12 sys/src/cmd/rio/fsys.c --- a/sys/src/cmd/rio/fsys.c Mon Dec 07 15:15:02 2020 +0100 +++ b/sys/src/cmd/rio/fsys.c Mon Dec 07 15:56:46 2020 +0100 @@ -50,6 +50,7 @@ char srvpipe[64]; char srvwctl[64]; +char srvgkbd[64]; static Xfid* filsysflush(Filsys*, Xfid*, Fid*); static Xfid* filsysversion(Filsys*, Xfid*, Fid*); @@ -115,6 +116,34 @@ return 0; } +void +gkbdproc(void *v) +{ + char *s; + int n, eofs; + Channel *c; + + threadsetname("GKBDPROC"); + c = v; + + eofs = 0; + for(;;){ + if((s = recvp(c)) == nil) + break; + n = write(gkbdfd, s, strlen(s)); /* room for \0 */ + free(s); + if(n < 0) + break; + if(n == 0){ + if(++eofs > 20) + break; + continue; + } + eofs = 0; + } + close(gkbdfd); +} + Filsys* filsysinit(Channel *cxfidalloc) { @@ -142,6 +171,12 @@ post(srvwctl, "wctl", p0); close(p0); + if(cexecpipe(&p0, &gkbdfd) < 0) + goto Rescue; + snprint(srvgkbd, sizeof(srvgkbd), "/srv/riogkbd.%s.%lud", fs->user, (ulong)getpid()); + post(srvgkbd, "gkbd", p0); + close(p0); + /* * Start server processes */ @@ -150,6 +185,12 @@ error("wctl channel"); proccreate(wctlproc, c, 4096); threadcreate(wctlthread, c, 4096); + + gkbdc = chancreate(sizeof(char*), 0); + if(gkbdc == nil) + error("gkbd channel"); + proccreate(gkbdproc, gkbdc, 4096); + proccreate(filsysproc, fs, 10000); /* diff -r ab6ef2653d12 sys/src/cmd/rio/rio.c --- a/sys/src/cmd/rio/rio.c Mon Dec 07 15:15:02 2020 +0100 +++ b/sys/src/cmd/rio/rio.c Mon Dec 07 15:56:46 2020 +0100 @@ -340,13 +340,20 @@ keyboardthread(void*) { char *s; + int mod4downnew; threadsetname("keyboardthread"); + mod4downnew = 0; while(s = recvp(kbdchan)){ - if(*s == 'k' || *s == 'K') + if(*s == 'k' || *s == 'K'){ shiftdown = utfrune(s+1, Kshift) != nil; - if(input == nil || sendp(input->ck, s) <= 0) + mod4downnew = utfrune(s+1, Kmod4) != nil; + } + if(mod4down || mod4downnew){ + mod4down = mod4downnew; + sendp(gkbdc, s); + }else if(input == nil || sendp(input->ck, s) <= 0) free(s); } }