mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-15 11:20:03 +00:00
a0e8d02d09
buffers than the standard ones. 64kB appears to be enough for a stack in that case, but let's just go nuts and make the stacks enormous, so that it takes a few more doublings of X's stack needs before we run into this problem again. The VM system should take care of not actually using most of the memory anyway.
78 lines
1.2 KiB
C
78 lines
1.2 KiB
C
#include <u.h>
|
|
#include "x11-inc.h"
|
|
#include <libc.h>
|
|
#include <draw.h>
|
|
#include <thread.h>
|
|
#include <memdraw.h>
|
|
#include <keyboard.h>
|
|
#include "x11-memdraw.h"
|
|
|
|
void
|
|
closekeyboard(Keyboardctl *kc)
|
|
{
|
|
if(kc == nil)
|
|
return;
|
|
|
|
/* postnote(PNPROC, kc->pid, "kill");
|
|
*/
|
|
|
|
#ifdef BUG
|
|
/* Drain the channel */
|
|
while(?kc->c)
|
|
<-kc->c;
|
|
#endif
|
|
|
|
close(kc->ctlfd);
|
|
close(kc->consfd);
|
|
free(kc->file);
|
|
free(kc->c);
|
|
free(kc);
|
|
}
|
|
|
|
static
|
|
void
|
|
_ioproc(void *arg)
|
|
{
|
|
int i;
|
|
int fd;
|
|
Keyboardctl *kc;
|
|
Rune r;
|
|
XEvent xevent;
|
|
|
|
kc = arg;
|
|
threadsetname("kbdproc");
|
|
kc->pid = getpid();
|
|
fd = XConnectionNumber(_x.kbdcon);
|
|
XSelectInput(_x.kbdcon, _x.drawable, KeyPressMask);
|
|
for(;;){
|
|
XWindowEvent(_x.kbdcon, _x.drawable, KeyPressMask, &xevent);
|
|
switch(xevent.type){
|
|
case KeyPress:
|
|
i = _xtoplan9kbd(&xevent);
|
|
if(i == -1)
|
|
continue;
|
|
r = i;
|
|
send(kc->c, &r);
|
|
while((i=_xtoplan9kbd(nil)) >= 0){
|
|
r = i;
|
|
send(kc->c, &r);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
Keyboardctl*
|
|
initkeyboard(char *file)
|
|
{
|
|
Keyboardctl *kc;
|
|
|
|
kc = mallocz(sizeof(Keyboardctl), 1);
|
|
if(kc == nil)
|
|
return nil;
|
|
kc->c = chancreate(sizeof(Rune), 20);
|
|
chansetname(kc->c, "kbdc");
|
|
proccreate(_ioproc, kc, 256*1024);
|
|
return kc;
|
|
}
|
|
|