[PATCH xserver 09/11] dmx: Eliminate use of AddEnabledDevice

Keith Packard keithp at keithp.com
Wed May 18 21:51:56 UTC 2016


Use SetNotifyFd instead, with the hope that someday someone will come
fix this to be more efficient -- right now, the wakeup handler is
doing the event reading, instead of the notify callback.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/dmx/input/dmxcommon.c | 17 +++++++++++++----
 hw/dmx/input/dmxsigio.c  |  9 +++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/hw/dmx/input/dmxcommon.c b/hw/dmx/input/dmxcommon.c
index 90154ef..c7aed68 100644
--- a/hw/dmx/input/dmxcommon.c
+++ b/hw/dmx/input/dmxcommon.c
@@ -480,17 +480,26 @@ dmxCommonXSelect(DMXScreenInfo * dmxScreen, void *closure)
     return NULL;
 }
 
+static void
+dmxCommonFdNotify(int fd, int ready, void *data)
+{
+    /* This should process input on this fd, but instead all
+     * of that is delayed until the block and wakeup handlers are called
+     */
+    ;
+}
+
 static void *
 dmxCommonAddEnabledDevice(DMXScreenInfo * dmxScreen, void *closure)
 {
-    AddEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
+    SetNotifyFd(XConnectionNumber(dmxScreen->beDisplay), dmxCommonFdNotify, X_NOTIFY_READ, closure);
     return NULL;
 }
 
 static void *
 dmxCommonRemoveEnabledDevice(DMXScreenInfo * dmxScreen, void *closure)
 {
-    RemoveEnabledDevice(XConnectionNumber(dmxScreen->beDisplay));
+    RemoveNotifyFd(XConnectionNumber(dmxScreen->beDisplay));
     return NULL;
 }
 
@@ -504,7 +513,7 @@ dmxCommonMouOn(DevicePtr pDev)
     priv->eventMask |= DMX_POINTER_EVENT_MASK;
     if (!priv->be) {
         XSelectInput(priv->display, priv->window, priv->eventMask);
-        AddEnabledDevice(XConnectionNumber(priv->display));
+        SetNotifyFd(XConnectionNumber(priv->display), dmxCommonFdNotify,X_NOTIFY_READ, pDev);
     }
     else {
         dmxPropertyIterate(priv->be, dmxCommonXSelect, priv);
@@ -523,7 +532,7 @@ dmxCommonMouOff(DevicePtr pDev)
 
     priv->eventMask &= ~DMX_POINTER_EVENT_MASK;
     if (!priv->be) {
-        RemoveEnabledDevice(XConnectionNumber(priv->display));
+        RemoveNotifyFd(XConnectionNumber(priv->display));
         XSelectInput(priv->display, priv->window, priv->eventMask);
     }
     else {
diff --git a/hw/dmx/input/dmxsigio.c b/hw/dmx/input/dmxsigio.c
index 6ef543c..85eb5b9 100644
--- a/hw/dmx/input/dmxsigio.c
+++ b/hw/dmx/input/dmxsigio.c
@@ -114,6 +114,11 @@ dmxSigioUnhook(void)
 }
 
 static void
+dmxSigioFdNotify(int fd, int ready, void *data)
+{
+}
+
+static void
 dmxSigioAdd(DMXInputInfo * dmxInput)
 {
     int flags;
@@ -138,7 +143,7 @@ dmxSigioAdd(DMXInputInfo * dmxInput)
             flags |= O_ASYNC | O_NONBLOCK;
             fcntl(fd, F_SETFL, flags);
 
-            AddEnabledDevice(fd);
+            SetNotifyFd(fd, dmxSigioFdNotify, X_NOTIFY_READ, NULL);
             dmxInput->sigioAdded[i] = TRUE;
 
             if (++dmxFdCount == 1)
@@ -168,7 +173,7 @@ dmxSigioRemove(DMXInputInfo * dmxInput)
             int fd = dmxInput->sigioFd[i];
 
             dmxInput->sigioAdded[i] = FALSE;
-            RemoveEnabledDevice(fd);
+            RemoveNotifyFd(fd);
 
             flags = fcntl(fd, F_GETFL);
             flags &= ~(O_ASYNC | O_NONBLOCK);
-- 
2.8.0.rc3



More information about the xorg-devel mailing list