[PATCH xserver 2/2] kdrive/ephyr: Poll for events in block handler

Keith Packard keithp at keithp.com
Fri Nov 13 08:37:44 PST 2015


With the driver block handler guaranteed to be the last thing called
before the server blocks, we can now reliably check for events there
and never block with events read but not processed.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/kdrive/ephyr/ephyr.c     | 14 +++++++++++++-
 hw/kdrive/ephyr/ephyr.h     |  3 +++
 hw/kdrive/ephyr/ephyrinit.c |  1 +
 hw/kdrive/src/kdrive.h      |  2 +-
 hw/kdrive/src/kinput.c      |  9 ++++-----
 5 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index ea0e2d4..b155970 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -1183,7 +1183,7 @@ ephyrProcessConfigureNotify(xcb_generic_event_t *xev)
 }
 
 static void
-ephyrXcbNotify(int fd, int ready, void *data)
+ephyrXcbProcessEvents(void)
 {
     xcb_connection_t *conn = hostx_get_xcbconn();
 
@@ -1243,6 +1243,18 @@ ephyrXcbNotify(int fd, int ready, void *data)
     }
 }
 
+static void
+ephyrXcbNotify(int fd, int ready, void *data)
+{
+    ephyrXcbProcessEvents();
+}
+
+void
+ephyrBlockHandler(ScreenPtr pScreen, void *timeo)
+{
+    ephyrXcbProcessEvents();
+}
+
 void
 ephyrCardFini(KdCardInfo * card)
 {
diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h
index f5015f6..ef5736e 100644
--- a/hw/kdrive/ephyr/ephyr.h
+++ b/hw/kdrive/ephyr/ephyr.h
@@ -138,6 +138,9 @@ void
 ephyrCloseScreen(ScreenPtr pScreen);
 
 void
+ephyrBlockHandler(ScreenPtr pScreen, void *timeo);
+
+void
  ephyrCardFini(KdCardInfo * card);
 
 void
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index d86baf2..db6ef53 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -413,4 +413,5 @@ KdCardFuncs ephyrFuncs = {
     ephyrPutColors,             /* putColors */
 
     ephyrCloseScreen,           /* closeScreen */
+    ephyrBlockHandler,          /* blockHandler */
 };
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 3c7f2cd..6ef7337 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -133,6 +133,7 @@ typedef struct _KdCardFuncs {
     void (*putColors) (ScreenPtr, int, xColorItem *);
 
     void (*closeScreen) (ScreenPtr);    /* close ScreenRec */
+    void (*blockHandler) (ScreenPtr, void *timeo);
 } KdCardFuncs;
 
 #define KD_MAX_PSEUDO_DEPTH 8
@@ -296,7 +297,6 @@ typedef struct _KdOsFuncs {
     Bool (*SpecialKey) (KeySym);
     void (*Disable) (void);
     void (*Fini) (void);
-    void (*pollEvents) (void);
     void (*Bell) (int, int, int);
 } KdOsFuncs;
 
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 956c502..86cc722 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1920,6 +1920,7 @@ KdBlockHandler(ScreenPtr pScreen, void *timeo)
 {
     KdPointerInfo *pi;
     int myTimeout = 0;
+    KdScreenPriv(pScreen);
 
     for (pi = kdPointers; pi; pi = pi->next) {
         if (pi->timeoutPending) {
@@ -1932,13 +1933,11 @@ KdBlockHandler(ScreenPtr pScreen, void *timeo)
                 myTimeout = ms;
         }
     }
-    /* if we need to poll for events, do that */
-    if (kdOsFuncs->pollEvents) {
-        (*kdOsFuncs->pollEvents) ();
-        myTimeout = 20;
-    }
     if (myTimeout > 0)
         AdjustWaitForDelay(timeo, myTimeout);
+
+    if (pScreenPriv->card->cfuncs->blockHandler)
+        (*pScreenPriv->card->cfuncs->blockHandler)(pScreen, timeo);
 }
 
 void
-- 
2.6.1



More information about the xorg-devel mailing list