From 16a709666981e77a00a88a87b286b586ac77ffdc Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 23 Nov 2003 18:15:43 +0000 Subject: Add drawsetlabel(Display*, char*). Turn window destruction into "hangup" note. Fix (?) snarf buffer management. Add latin1 keyboard translation. --- src/libdraw/x11-event.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/libdraw/x11-event.c') diff --git a/src/libdraw/x11-event.c b/src/libdraw/x11-event.c index 1361b42e..408eb419 100644 --- a/src/libdraw/x11-event.c +++ b/src/libdraw/x11-event.c @@ -36,6 +36,7 @@ eflush(void) ulong eread(ulong keys, Event *e) { + int r; ulong xmask; XEvent xevent; @@ -45,8 +46,13 @@ eread(ulong keys, Event *e) if(keys&Emouse) xmask |= MouseMask|StructureNotifyMask; - if(keys&Ekeyboard) + if(keys&Ekeyboard){ xmask |= KeyPressMask; + if((r = xtoplan9kbd(nil)) >= 0){ + e->kbdc = r; + return Ekeyboard; + } + } XSelectInput(_x.display, _x.drawable, xmask); again: @@ -56,6 +62,10 @@ again: case Expose: xexpose(&xevent, _x.display); goto again; + case DestroyNotify: + if(xdestroy(&xevent, _x.display)) + postnote(PNGROUP, getpgrp(), "hangup"); + goto again; case ConfigureNotify: if(xconfigure(&xevent, _x.display)) eresized(1); @@ -63,7 +73,7 @@ again: case ButtonPress: case ButtonRelease: case MotionNotify: - if(xtoplan9mouse(&xevent, &e->mouse) < 0) + if(xtoplan9mouse(_x.display, &xevent, &e->mouse) < 0) goto again; return Emouse; case KeyPress: @@ -126,7 +136,7 @@ ecanmouse(void) eflush(); again: if(XCheckWindowEvent(_x.display, _x.drawable, MouseMask, &xe)){ - if(xtoplan9mouse(&xe, &m) < 0) + if(xtoplan9mouse(_x.display, &xe, &m) < 0) goto again; XPutBackEvent(_x.display, &xe); return 1; @@ -138,8 +148,13 @@ int ecankbd(void) { XEvent xe; + int r; eflush(); + if((r = xtoplan9kbd(nil)) >= 0){ + xtoplan9kbd((XEvent*)-1); + return 1; + } again: if(XCheckWindowEvent(_x.display, _x.drawable, KeyPressMask, &xe)){ if(xtoplan9kbd(&xe) == -1) -- cgit v1.2.3