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

Keith Packard keithp at keithp.com
Wed May 25 05:38:45 UTC 2016


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 1a410ca..6066b5d 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -1106,7 +1106,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();
 
@@ -1166,6 +1166,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 149ea98..03d6289 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -411,4 +411,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 c0f1cf7..2234dfc 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1965,6 +1965,7 @@ KdBlockHandler(ScreenPtr pScreen, void *timeo)
 {
     KdPointerInfo *pi;
     int myTimeout = 0;
+    KdScreenPriv(pScreen);
 
     for (pi = kdPointers; pi; pi = pi->next) {
         if (pi->timeoutPending) {
@@ -1977,13 +1978,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.8.0.rc3



More information about the xorg-devel mailing list