tFlush the display when we poll for events. - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 59d7d92ee7a1de3387cedb079b1bfcfc75d34b8b
 (DIR) parent e6f4b2e311cd461dd2d8380ba21ab113e5c8c072
 (HTM) Author: rsc <devnull@localhost>
       Date:   Mon, 13 Oct 2003 17:16:29 +0000
       
       Flush the display when we poll for events.
       
       Diffstat:
         M src/libdraw/x11-event.c             |      28 ++++++++++++++++++++++++++++
       
       1 file changed, 28 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/libdraw/x11-event.c b/src/libdraw/x11-event.c
       t@@ -15,6 +15,24 @@ event(Event *e)
                return eread(~0UL, e);
        }
        
       +static void
       +eflush(void)
       +{
       +        /* avoid generating a message if there's nothing to show. */
       +        /* this test isn't perfect, though; could do flushimage(display, 0) then call extract */
       +        /* also: make sure we don't interfere if we're multiprocessing the display */
       +        if(display->locking){
       +                /* if locking is being done by program, this means it can't depend on automatic flush in emouse() etc. */
       +                if(canqlock(&display->qlock)){
       +                        if(display->bufp > display->buf)
       +                                flushimage(display, 1);
       +                        unlockdisplay(display);
       +                }
       +        }else
       +                if(display->bufp > display->buf)
       +                        flushimage(display, 1);
       +}
       +
        ulong
        eread(ulong keys, Event *e)
        {
       t@@ -23,6 +41,8 @@ eread(ulong keys, Event *e)
        
                xmask = ExposureMask;
        
       +        eflush();
       +
                if(keys&Emouse)
                        xmask |= MouseMask|StructureNotifyMask;
                if(keys&Ekeyboard)
       t@@ -103,6 +123,7 @@ ecanmouse(void)
                XEvent xe;
                Mouse m;
        
       +        eflush();
        again:
                if(XCheckWindowEvent(_x.display, _x.drawable, MouseMask, &xe)){
                        if(xtoplan9mouse(&xe, &m) < 0)
       t@@ -118,6 +139,7 @@ ecankbd(void)
        {
                XEvent xe;
        
       +        eflush();
        again:
                if(XCheckWindowEvent(_x.display, _x.drawable, KeyPressMask, &xe)){
                        if(xtoplan9kbd(&xe) == -1)
       t@@ -134,3 +156,9 @@ emoveto(Point p)
                xmoveto(p);
        }
        
       +void
       +esetcursor(Cursor *c)
       +{
       +        xsetcursor(c);
       +}
       +