summaryrefslogtreecommitdiff
path: root/hw/xfree86
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-11-11 22:02:16 -0800
committerAdam Jackson <ajax@redhat.com>2015-12-01 13:56:13 -0500
commit1df07dc36ca145c59f51176d9ab2651112506d75 (patch)
treef6e0651fd66463c22fbe8664ce808936c4d4a0a1 /hw/xfree86
parente51ea53b26bd9ec05b9209825960af28d0b6bbe1 (diff)
hw/xfree86: Use NotifyFd for device and other input fd wakeups
Remove code in xf86Wakeup for dealing with device and other input and switch to using the new NotifyFd interface. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'hw/xfree86')
-rw-r--r--hw/xfree86/common/xf86Events.c67
1 files changed, 26 insertions, 41 deletions
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 709afd6f9..2db6e5b8c 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -101,8 +101,6 @@ Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
switches when using the DRI
automatic full screen mode.*/
-extern fd_set EnabledDevices;
-
#ifdef XF86PM
extern void (*xf86OSPMClose) (void);
#endif
@@ -247,45 +245,6 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
void
xf86Wakeup(void *blockData, int err, void *pReadmask)
{
- fd_set *LastSelectMask = (fd_set *) pReadmask;
- fd_set devicesWithInput;
- InputInfoPtr pInfo;
-
- if (err >= 0) {
-
- XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
- if (XFD_ANYSET(&devicesWithInput)) {
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->read_input && pInfo->fd >= 0 &&
- (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
- OsBlockSIGIO();
-
- /*
- * Remove the descriptior from the set because more than one
- * device may share the same file descriptor.
- */
- FD_CLR(pInfo->fd, &devicesWithInput);
-
- pInfo->read_input(pInfo);
- OsReleaseSIGIO();
- }
- pInfo = pInfo->next;
- }
- }
- }
-
- if (err >= 0) { /* we don't want the handlers called if select() */
- IHPtr ih, ih_tmp; /* returned with an error condition, do we? */
-
- nt_list_for_each_entry_safe(ih, ih_tmp, InputHandlers, next) {
- if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
- (FD_ISSET(ih->fd, ((fd_set *) pReadmask)) != 0)) {
- ih->ihproc(ih->fd, ih->data);
- }
- }
- }
-
if (xf86VTSwitchPending())
xf86VTSwitch();
}
@@ -305,6 +264,15 @@ xf86SigioReadInput(int fd, void *closure)
errno = errno_save;
}
+static void
+xf86NotifyReadInput(int fd, int ready, void *closure)
+{
+ InputInfoPtr pInfo = closure;
+ OsBlockSIGIO();
+ pInfo->read_input(pInfo);
+ OsReleaseSIGIO();
+}
+
/*
* xf86AddEnabledDevice --
*
@@ -314,6 +282,7 @@ xf86AddEnabledDevice(InputInfoPtr pInfo)
{
if (!xf86InstallSIGIOHandler(pInfo->fd, xf86SigioReadInput, pInfo)) {
AddEnabledDevice(pInfo->fd);
+ SetNotifyFd(pInfo->fd, xf86NotifyReadInput, X_NOTIFY_READ, pInfo);
}
}
@@ -326,6 +295,7 @@ xf86RemoveEnabledDevice(InputInfoPtr pInfo)
{
if (!xf86RemoveSIGIOHandler(pInfo->fd)) {
RemoveEnabledDevice(pInfo->fd);
+ RemoveNotifyFd(pInfo->fd);
}
}
@@ -636,6 +606,16 @@ xf86VTSwitch(void)
/* Input handler registration */
+static void
+xf86InputHandlerNotify(int fd, int ready, void *data)
+{
+ IHPtr ih = data;
+
+ if (ih->enabled && ih->fd >= 0 && ih->ihproc) {
+ ih->ihproc(ih->fd, ih->data);
+ }
+}
+
static void *
addInputHandler(int fd, InputHandlerProc proc, void *data)
{
@@ -653,6 +633,11 @@ addInputHandler(int fd, InputHandlerProc proc, void *data)
ih->data = data;
ih->enabled = TRUE;
+ if (!SetNotifyFd(fd, xf86InputHandlerNotify, X_NOTIFY_READ, ih)) {
+ free(ih);
+ return NULL;
+ }
+
ih->next = InputHandlers;
InputHandlers = ih;