Initial revision
This commit is contained in:
parent
ed7c8e8d02
commit
76193d7cb0
223 changed files with 32479 additions and 0 deletions
71
src/libdraw/x11-keyboard.c
Normal file
71
src/libdraw/x11-keyboard.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#include "x11-inc.h"
|
||||
#include <u.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;
|
||||
Keyboardctl *kc;
|
||||
Rune r;
|
||||
XEvent xevent;
|
||||
|
||||
kc = arg;
|
||||
threadsetname("kbdproc");
|
||||
kc->pid = getpid();
|
||||
for(;;){
|
||||
XSelectInput(_x.kbdcon, _x.drawable, KeyPressMask);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keyboardctl*
|
||||
initkeyboard(char *file)
|
||||
{
|
||||
Keyboardctl *kc;
|
||||
|
||||
kc = mallocz(sizeof(Keyboardctl), 1);
|
||||
if(kc == nil)
|
||||
return nil;
|
||||
kc->c = chancreate(sizeof(Rune), 20);
|
||||
proccreate(_ioproc, kc, 4096);
|
||||
return kc;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue