add 'general socket' handler, port ACPI to use it
Add a general socket (not input device, but still need to be woken for it) handler to both the DIX and XFree86, and make XFree86's ACPI handling use it. This stops DPMS waking up every time an ACPI notification comes in.
This commit is contained in:
parent
58653b676d
commit
66b2c9bd2d
|
@ -222,6 +222,10 @@ pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
|
|||
int xf86RemoveInputHandler(pointer handler);
|
||||
void xf86DisableInputHandler(pointer handler);
|
||||
void xf86EnableInputHandler(pointer handler);
|
||||
pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
|
||||
int xf86RemoveGeneralHandler(pointer handler);
|
||||
void xf86DisableGeneralHandler(pointer handler);
|
||||
void xf86EnableGeneralHandler(pointer handler);
|
||||
void xf86InterceptSignals(int *signo);
|
||||
void xf86InterceptSigIll(void (*sigillhandler)(void));
|
||||
Bool xf86EnableVTSwitch(Bool new);
|
||||
|
|
|
@ -1636,8 +1636,8 @@ xf86VTSwitch()
|
|||
|
||||
/* Input handler registration */
|
||||
|
||||
_X_EXPORT pointer
|
||||
xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
|
||||
static pointer
|
||||
addInputHandler(int fd, InputHandlerProc proc, pointer data)
|
||||
{
|
||||
IHPtr ih;
|
||||
|
||||
|
@ -1656,25 +1656,33 @@ xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
|
|||
ih->next = InputHandlers;
|
||||
InputHandlers = ih;
|
||||
|
||||
AddEnabledDevice(fd);
|
||||
|
||||
return ih;
|
||||
}
|
||||
|
||||
_X_EXPORT int
|
||||
xf86RemoveInputHandler(pointer handler)
|
||||
{
|
||||
IHPtr ih, p;
|
||||
int fd;
|
||||
|
||||
if (!handler)
|
||||
return -1;
|
||||
_X_EXPORT pointer
|
||||
xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
|
||||
{
|
||||
IHPtr ih = addInputHandler(fd, proc, data);
|
||||
|
||||
ih = handler;
|
||||
fd = ih->fd;
|
||||
|
||||
if (ih->fd >= 0)
|
||||
RemoveEnabledDevice(ih->fd);
|
||||
if (ih)
|
||||
AddEnabledDevice(fd);
|
||||
return ih;
|
||||
}
|
||||
|
||||
_X_EXPORT pointer
|
||||
xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
|
||||
{
|
||||
IHPtr ih = addInputHandler(fd, proc, data);
|
||||
|
||||
if (ih)
|
||||
AddGeneralSocket(fd);
|
||||
return ih;
|
||||
}
|
||||
|
||||
static void
|
||||
removeInputHandler(IHPtr ih)
|
||||
{
|
||||
IHPtr p;
|
||||
|
||||
if (ih == InputHandlers)
|
||||
InputHandlers = ih->next;
|
||||
|
@ -1686,6 +1694,43 @@ xf86RemoveInputHandler(pointer handler)
|
|||
p->next = ih->next;
|
||||
}
|
||||
xfree(ih);
|
||||
}
|
||||
|
||||
_X_EXPORT int
|
||||
xf86RemoveInputHandler(pointer handler)
|
||||
{
|
||||
IHPtr ih;
|
||||
int fd;
|
||||
|
||||
if (!handler)
|
||||
return -1;
|
||||
|
||||
ih = handler;
|
||||
fd = ih->fd;
|
||||
|
||||
if (ih->fd >= 0)
|
||||
RemoveEnabledDevice(ih->fd);
|
||||
removeInputHandler(ih);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
_X_EXPORT int
|
||||
xf86RemoveGeneralHandler(pointer handler)
|
||||
{
|
||||
IHPtr ih;
|
||||
int fd;
|
||||
|
||||
if (!handler)
|
||||
return -1;
|
||||
|
||||
ih = handler;
|
||||
fd = ih->fd;
|
||||
|
||||
if (ih->fd >= 0)
|
||||
RemoveGeneralSocket(ih->fd);
|
||||
removeInputHandler(ih);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -1703,6 +1748,20 @@ xf86DisableInputHandler(pointer handler)
|
|||
RemoveEnabledDevice(ih->fd);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
xf86DisableGeneralHandler(pointer handler)
|
||||
{
|
||||
IHPtr ih;
|
||||
|
||||
if (!handler)
|
||||
return;
|
||||
|
||||
ih = handler;
|
||||
ih->enabled = FALSE;
|
||||
if (ih->fd >= 0)
|
||||
RemoveGeneralSocket(ih->fd);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
xf86EnableInputHandler(pointer handler)
|
||||
{
|
||||
|
@ -1717,6 +1776,20 @@ xf86EnableInputHandler(pointer handler)
|
|||
AddEnabledDevice(ih->fd);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
xf86EnableGeneralHandler(pointer handler)
|
||||
{
|
||||
IHPtr ih;
|
||||
|
||||
if (!handler)
|
||||
return;
|
||||
|
||||
ih = handler;
|
||||
ih->enabled = TRUE;
|
||||
if (ih->fd >= 0)
|
||||
AddGeneralSocket(ih->fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* As used currently by the DRI, the return value is ignored.
|
||||
*/
|
||||
|
|
|
@ -163,7 +163,7 @@ lnxACPIOpen(void)
|
|||
|
||||
xf86PMGetEventFromOs = lnxACPIGetEventFromOs;
|
||||
xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs;
|
||||
ACPIihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL);
|
||||
ACPIihPtr = xf86AddGeneralHandler(fd,xf86HandlePMEvents,NULL);
|
||||
xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET);
|
||||
|
||||
return lnxCloseACPI;
|
||||
|
@ -178,7 +178,7 @@ lnxCloseACPI(void)
|
|||
ErrorF("ACPI: Closing device\n");
|
||||
#endif
|
||||
if (ACPIihPtr) {
|
||||
fd = xf86RemoveInputHandler(ACPIihPtr);
|
||||
fd = xf86RemoveGeneralHandler(ACPIihPtr);
|
||||
shutdown(fd, 2);
|
||||
close(fd);
|
||||
ACPIihPtr = NULL;
|
||||
|
|
|
@ -147,6 +147,10 @@ extern void CheckConnections(void);
|
|||
|
||||
extern void CloseDownConnection(ClientPtr /*client*/);
|
||||
|
||||
extern void AddGeneralSocket(int /*fd*/);
|
||||
|
||||
extern void RemoveGeneralSocket(int /*fd*/);
|
||||
|
||||
extern void AddEnabledDevice(int /*fd*/);
|
||||
|
||||
extern void RemoveEnabledDevice(int /*fd*/);
|
||||
|
|
|
@ -1047,22 +1047,34 @@ CloseDownConnection(ClientPtr client)
|
|||
AuditF("client %d disconnected\n", client->index);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
AddGeneralSocket(int fd)
|
||||
{
|
||||
FD_SET(fd, &AllSockets);
|
||||
if (GrabInProgress)
|
||||
FD_SET(fd, &SavedAllSockets);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
AddEnabledDevice(int fd)
|
||||
{
|
||||
FD_SET(fd, &EnabledDevices);
|
||||
FD_SET(fd, &AllSockets);
|
||||
AddGeneralSocket(fd);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
RemoveGeneralSocket(int fd)
|
||||
{
|
||||
FD_CLR(fd, &AllSockets);
|
||||
if (GrabInProgress)
|
||||
FD_SET(fd, &SavedAllSockets);
|
||||
FD_CLR(fd, &SavedAllSockets);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
RemoveEnabledDevice(int fd)
|
||||
{
|
||||
FD_CLR(fd, &EnabledDevices);
|
||||
FD_CLR(fd, &AllSockets);
|
||||
if (GrabInProgress)
|
||||
FD_CLR(fd, &SavedAllSockets);
|
||||
RemoveGeneralSocket(fd);
|
||||
}
|
||||
|
||||
/*****************
|
||||
|
|
Loading…
Reference in New Issue
Block a user