hw/kdrive: Use NotifyFd for kdrive input devices
This switches the kdrive code to use FD notification for input devices, rather than the block and wakeup handlers. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
21c1680e83
commit
483c2a1adf
|
@ -153,7 +153,16 @@ KdNonBlockFd(int fd)
|
|||
}
|
||||
|
||||
static void
|
||||
KdAddFd(int fd)
|
||||
KdNotifyFd(int fd, int ready, void *data)
|
||||
{
|
||||
int i = (int) (intptr_t) data;
|
||||
OsBlockSIGIO();
|
||||
(*kdInputFds[i].read)(fd, kdInputFds[i].closure);
|
||||
OsReleaseSIGIO();
|
||||
}
|
||||
|
||||
static void
|
||||
KdAddFd(int fd, int i)
|
||||
{
|
||||
struct sigaction act;
|
||||
sigset_t set;
|
||||
|
@ -162,6 +171,7 @@ KdAddFd(int fd)
|
|||
fcntl(fd, F_SETOWN, getpid());
|
||||
KdNonBlockFd(fd);
|
||||
AddEnabledDevice(fd);
|
||||
SetNotifyFd(fd, KdNotifyFd, X_NOTIFY_READ, (void *) (intptr_t) i);
|
||||
memset(&act, '\0', sizeof act);
|
||||
act.sa_handler = KdSigio;
|
||||
sigemptyset(&act.sa_mask);
|
||||
|
@ -181,6 +191,7 @@ KdRemoveFd(int fd)
|
|||
|
||||
kdnFds--;
|
||||
RemoveEnabledDevice(fd);
|
||||
RemoveNotifyFd(fd);
|
||||
flags = fcntl(fd, F_GETFL);
|
||||
flags &= ~(FASYNC | NOBLOCK);
|
||||
fcntl(fd, F_SETFL, flags);
|
||||
|
@ -202,9 +213,9 @@ KdRegisterFd(int fd, void (*read) (int fd, void *closure), void *closure)
|
|||
kdInputFds[kdNumInputFds].enable = 0;
|
||||
kdInputFds[kdNumInputFds].disable = 0;
|
||||
kdInputFds[kdNumInputFds].closure = closure;
|
||||
kdNumInputFds++;
|
||||
if (kdInputEnabled)
|
||||
KdAddFd(fd);
|
||||
KdAddFd(fd, kdNumInputFds);
|
||||
kdNumInputFds++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1933,19 +1944,8 @@ KdBlockHandler(ScreenPtr pScreen, void *timeo, void *readmask)
|
|||
void
|
||||
KdWakeupHandler(ScreenPtr pScreen, unsigned long lresult, void *readmask)
|
||||
{
|
||||
int result = (int) lresult;
|
||||
fd_set *pReadmask = (fd_set *) readmask;
|
||||
int i;
|
||||
KdPointerInfo *pi;
|
||||
|
||||
if (kdInputEnabled && result > 0) {
|
||||
for (i = 0; i < kdNumInputFds; i++)
|
||||
if (FD_ISSET(kdInputFds[i].fd, pReadmask)) {
|
||||
OsBlockSIGIO();
|
||||
(*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
|
||||
OsReleaseSIGIO();
|
||||
}
|
||||
}
|
||||
for (pi = kdPointers; pi; pi = pi->next) {
|
||||
if (pi->timeoutPending) {
|
||||
if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) {
|
||||
|
|
Loading…
Reference in New Issue