diff --git a/hw/dmx/dmxinput.h b/hw/dmx/dmxinput.h index 83c9c8b95..210fd7ad0 100644 --- a/hw/dmx/dmxinput.h +++ b/hw/dmx/dmxinput.h @@ -47,9 +47,6 @@ #ifndef DMXINPUT_H #define DMXINPUT_H -/** Maximum number of file descriptors for SIGIO handling */ -#define DMX_MAX_SIGIO_FDS 4 - struct _DMXInputInfo; /** Reason why window layout was updated. */ @@ -69,15 +66,6 @@ typedef void (*UpdateWindowInfoProc) (struct _DMXInputInfo *, /** An opaque structure that is only exposed in the dmx/input layer. */ typedef struct _DMXLocalInputInfo *DMXLocalInputInfoPtr; -/** State of the SIGIO engine */ -typedef enum { - DMX_NOSIGIO = 0, /**< Device does not use SIGIO at all. */ - DMX_USESIGIO, /**< Device can use SIGIO, but is not - * (e.g., because the VT is switch - * away). */ - DMX_ACTIVESIGIO /**< Device is currently using SIGIO. */ -} dmxSigioState; - /** DMXInputInfo is typedef'd in \a dmx.h so that all routines can have * access to the global pointers. However, the elements are only * available to input-related routines. */ @@ -102,12 +90,6 @@ struct _DMXInputInfo { ProcessInputEventsProc processInputEvents; UpdateWindowInfoProc updateWindowInfo; - /* Local input information */ - dmxSigioState sigioState; /**< Current stat */ - int sigioFdCount; /**< Number of fds in use */ - int sigioFd[DMX_MAX_SIGIO_FDS]; /**< List of fds */ - Bool sigioAdded[DMX_MAX_SIGIO_FDS]; /**< Active fds */ - /** True if a VT switch is pending, but has not yet happened. */ int vt_switch_pending; diff --git a/hw/dmx/input/Makefile.am b/hw/dmx/input/Makefile.am index 185aaf84e..b56ee8e29 100644 --- a/hw/dmx/input/Makefile.am +++ b/hw/dmx/input/Makefile.am @@ -34,8 +34,6 @@ DMXSRCS = dmxinputinit.c \ dmxinputinit.h \ dmxarg.c \ dmxarg.h \ - dmxsigio.c \ - dmxsigio.h \ dmxevents.c \ dmxevents.h \ dmxxinput.c \ diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c index 37896026f..235ba21a3 100644 --- a/hw/dmx/input/dmxevents.c +++ b/hw/dmx/input/dmxevents.c @@ -47,7 +47,6 @@ #include "dmxcommon.h" #include "dmxcursor.h" #include "dmxmotion.h" -#include "dmxsigio.h" #include "dmxmap.h" #include diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c index cdefd9ae0..a9522ff08 100644 --- a/hw/dmx/input/dmxinputinit.c +++ b/hw/dmx/input/dmxinputinit.c @@ -63,7 +63,6 @@ #include "usb-other.h" #include "usb-common.h" -#include "dmxsigio.h" #include "dmxarg.h" #include "inputstr.h" @@ -434,7 +433,6 @@ static int dmxDeviceOnOff(DeviceIntPtr pDevice, int what) { GETDMXINPUTFROMPDEVICE; - int fd; DMXLocalInitInfo info; int i; Atom btn_labels[MAX_BUTTONS] = { 0 }; /* FIXME */ @@ -523,8 +521,8 @@ dmxDeviceOnOff(DeviceIntPtr pDevice, int what) break; case DEVICE_ON: if (!pDev->on) { - if (dmxLocal->on && (fd = dmxLocal->on(pDev)) >= 0) - dmxSigioRegister(dmxInput, fd); + if (dmxLocal->on) + dmxLocal->on(pDev); pDev->on = TRUE; } break; @@ -534,7 +532,6 @@ dmxDeviceOnOff(DeviceIntPtr pDevice, int what) * detached screen (DEVICE_OFF), and then again at server * generation time (DEVICE_CLOSE). */ if (pDev->on) { - dmxSigioUnregister(dmxInput); if (dmxLocal->off) dmxLocal->off(pDev); pDev->on = FALSE; @@ -654,7 +651,6 @@ dmxSwitchReturn(void *p) if (!dmxInput->vt_switched) dmxLog(dmxFatal, "dmxSwitchReturn called, but not switched\n"); - dmxSigioEnableInput(); for (i = 0; i < dmxInput->numDevs; i++) if (dmxInput->devs[i]->vt_post_switch) dmxInput->devs[i]->vt_post_switch(dmxInput->devs[i]->private); @@ -676,7 +672,6 @@ dmxWakeupHandler(void *blockData, int result, void *pReadMask) dmxInput->vt_switch_pending = 0; for (i = 0; i < dmxInput->numDevs; i++) { if (dmxInput->devs[i]->vt_switch) { - dmxSigioDisableInput(); if (!dmxInput->devs[i]->vt_switch(dmxInput->devs[i]->private, dmxInput->vt_switched, dmxSwitchReturn, dmxInput)) diff --git a/hw/dmx/input/dmxsigio.c b/hw/dmx/input/dmxsigio.c deleted file mode 100644 index ebfd3d98c..000000000 --- a/hw/dmx/input/dmxsigio.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright 2002-2003 Red Hat Inc., Durham, North Carolina. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation on the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith - * - */ - -/** \file - * - * Provides an interface for handling SIGIO signals for input devices. */ - -#ifdef HAVE_DMX_CONFIG_H -#include -#endif - -#include "inputstr.h" -#include "dmxinputinit.h" -#include "dmxsigio.h" -#include "dmxevents.h" -#include -#include -#include - -static int dmxFdCount = 0; -static Bool dmxInputEnabled = TRUE; - -/* Define equivalents for non-POSIX systems (e.g., SGI IRIX, Solaris) */ -#ifndef O_ASYNC -#ifdef FASYNC -#define O_ASYNC FASYNC -#else -#define O_ASYNC 0 -#endif -#endif -#ifndef O_NONBLOCK -#define O_NONBLOCK FNONBLK -#endif - -static void -dmxSigioHandler(int sig) -{ - int i, j; - DMXInputInfo *dmxInput; - - for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) { - if (dmxInput->sigioState == DMX_ACTIVESIGIO) { - for (j = 0; j < dmxInput->numDevs; j++) { - DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j]; - - if (dmxLocal->collect_events) { - dmxLocal->collect_events(&dmxLocal->pDevice->public, - dmxMotion, - dmxEnqueue, - dmxCheckSpecialKeys, DMX_NO_BLOCK); - } - } - } - } -} - -static void -dmxSigioHook(void) -{ - struct sigaction a; - sigset_t s; - - memset(&a, 0, sizeof(a)); - a.sa_handler = dmxSigioHandler; - sigemptyset(&a.sa_mask); - sigaddset(&a.sa_mask, SIGIO); - sigaddset(&a.sa_mask, SIGALRM); - sigaddset(&a.sa_mask, SIGVTALRM); - sigaction(SIGIO, &a, 0); - - sigemptyset(&s); - xthread_sigmask(SIG_SETMASK, &s, 0); -} - -static void -dmxSigioUnhook(void) -{ - struct sigaction a; - - memset(&a, 0, sizeof(a)); - a.sa_handler = SIG_IGN; - sigemptyset(&a.sa_mask); - sigaction(SIGIO, &a, 0); -} - -static void -dmxSigioAdd(DMXInputInfo * dmxInput) -{ - int flags; - int i; - - switch (dmxInput->sigioState) { - case DMX_NOSIGIO: - return; - case DMX_USESIGIO: - dmxInput->sigioState = DMX_ACTIVESIGIO; - break; - case DMX_ACTIVESIGIO: - return; - } - - for (i = 0; i < dmxInput->sigioFdCount; i++) { - if (!dmxInput->sigioAdded[i]) { - int fd = dmxInput->sigioFd[i]; - - fcntl(fd, F_SETOWN, getpid()); - flags = fcntl(fd, F_GETFL); - flags |= O_ASYNC | O_NONBLOCK; - fcntl(fd, F_SETFL, flags); - - AddEnabledDevice(fd); - dmxInput->sigioAdded[i] = TRUE; - - if (++dmxFdCount == 1) - dmxSigioHook(); - } - } -} - -static void -dmxSigioRemove(DMXInputInfo * dmxInput) -{ - int flags; - int i; - - switch (dmxInput->sigioState) { - case DMX_NOSIGIO: - return; - case DMX_USESIGIO: - return; - case DMX_ACTIVESIGIO: - dmxInput->sigioState = DMX_USESIGIO; - break; - } - - for (i = 0; i < dmxInput->sigioFdCount; i++) { - if (dmxInput->sigioAdded[i]) { - int fd = dmxInput->sigioFd[i]; - - dmxInput->sigioAdded[i] = FALSE; - RemoveEnabledDevice(fd); - - flags = fcntl(fd, F_GETFL); - flags &= ~(O_ASYNC | O_NONBLOCK); - fcntl(fd, F_SETFL, flags); - - if (!--dmxFdCount) - dmxSigioUnhook(); - } - } -} - -/** Enable SIGIO handling. This instantiates the handler with the OS. */ -void -dmxSigioEnableInput(void) -{ - int i; - DMXInputInfo *dmxInput; - - dmxInputEnabled = TRUE; - for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) - dmxSigioAdd(dmxInput); -} - -/** Disable SIGIO handling. This removes the hanlder from the OS. */ -void -dmxSigioDisableInput(void) -{ - int i; - DMXInputInfo *dmxInput; - - dmxInputEnabled = FALSE; - for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) - dmxSigioRemove(dmxInput); -} - -/** Make a note that the input device described in \a dmxInput will be - * using the file descriptor \a fd for SIGIO signals. Calls - * AddEnabledDevice ifi SIGIO handling has been enabled with - * #dmxSigioEnableInput(). */ -void -dmxSigioRegister(DMXInputInfo * dmxInput, int fd) -{ - dmxInput->sigioState = DMX_USESIGIO; - if (dmxInput->sigioFdCount >= DMX_MAX_SIGIO_FDS) - dmxLog(dmxFatal, "Too many SIGIO file descriptors (%d >= %d)\n", - dmxInput->sigioFdCount, DMX_MAX_SIGIO_FDS); - - dmxInput->sigioFd[dmxInput->sigioFdCount++] = fd; - if (dmxInputEnabled) - dmxSigioAdd(dmxInput); -} - -/** Remove the notes that \a dmxInput is using any file descriptors for - * SIGIO signals. Calls RemoveEnabledDevice. */ -void -dmxSigioUnregister(DMXInputInfo * dmxInput) -{ - if (dmxInput->sigioState == DMX_NOSIGIO) - return; - dmxSigioRemove(dmxInput); - dmxInput->sigioState = DMX_NOSIGIO; - dmxInput->sigioFdCount = 0; -} diff --git a/hw/dmx/input/dmxsigio.h b/hw/dmx/input/dmxsigio.h deleted file mode 100644 index 9f30662d1..000000000 --- a/hw/dmx/input/dmxsigio.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2001 Red Hat Inc., Durham, North Carolina. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation on the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Authors: - * Rickard E. (Rik) Faith - * - */ - -/** \file - * Interface to SIGIO handling support. \see dmxsigio.c */ - -#ifndef _DMXSIGIO_H_ -#define _DMXSIGIO_H_ -extern void dmxSigioEnableInput(void); -extern void dmxSigioDisableInput(void); -extern void dmxSigioRegister(DMXInputInfo * dmxInput, int fd); -extern void dmxSigioUnregister(DMXInputInfo * dmxInput); -#endif