xfree86: add general handler, port ACPI to it (bug #5665)

Add 'general' handler registration, which will not trigger DPMS when an
event comes in.
Make ACPI use this.
This commit is contained in:
Daniel Stone 2006-11-08 15:27:58 +02:00 committed by Daniel Stone
parent b5438f7fb2
commit 809e2841aa
3 changed files with 96 additions and 19 deletions

View File

@ -222,6 +222,10 @@ pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
int xf86RemoveInputHandler(pointer handler); int xf86RemoveInputHandler(pointer handler);
void xf86DisableInputHandler(pointer handler); void xf86DisableInputHandler(pointer handler);
void xf86EnableInputHandler(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 xf86InterceptSignals(int *signo);
void xf86InterceptSigIll(void (*sigillhandler)(void)); void xf86InterceptSigIll(void (*sigillhandler)(void));
Bool xf86EnableVTSwitch(Bool new); Bool xf86EnableVTSwitch(Bool new);

View File

@ -1014,8 +1014,8 @@ xf86VTSwitch()
/* Input handler registration */ /* Input handler registration */
_X_EXPORT pointer static pointer
xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data) addInputHandler(int fd, InputHandlerProc proc, pointer data)
{ {
IHPtr ih; IHPtr ih;
@ -1034,25 +1034,33 @@ xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
ih->next = InputHandlers; ih->next = InputHandlers;
InputHandlers = ih; InputHandlers = ih;
AddEnabledDevice(fd);
return ih; return ih;
} }
_X_EXPORT int _X_EXPORT pointer
xf86RemoveInputHandler(pointer handler) xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
{ {
IHPtr ih, p; IHPtr ih = addInputHandler(fd, proc, data);
int fd;
if (!handler)
return -1;
ih = handler; if (ih)
fd = ih->fd; AddEnabledDevice(fd);
return ih;
if (ih->fd >= 0) }
RemoveEnabledDevice(ih->fd);
_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) if (ih == InputHandlers)
InputHandlers = ih->next; InputHandlers = ih->next;
@ -1064,6 +1072,43 @@ xf86RemoveInputHandler(pointer handler)
p->next = ih->next; p->next = ih->next;
} }
xfree(ih); 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; return fd;
} }
@ -1081,6 +1126,20 @@ xf86DisableInputHandler(pointer handler)
RemoveEnabledDevice(ih->fd); 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 _X_EXPORT void
xf86EnableInputHandler(pointer handler) xf86EnableInputHandler(pointer handler)
{ {
@ -1095,6 +1154,20 @@ xf86EnableInputHandler(pointer handler)
AddEnabledDevice(ih->fd); 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. * As used currently by the DRI, the return value is ignored.
*/ */

View File

@ -163,7 +163,7 @@ lnxACPIOpen(void)
xf86PMGetEventFromOs = lnxACPIGetEventFromOs; xf86PMGetEventFromOs = lnxACPIGetEventFromOs;
xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs; xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs;
ACPIihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL); ACPIihPtr = xf86AddGeneralHandler(fd,xf86HandlePMEvents,NULL);
xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET); xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET);
return lnxCloseACPI; return lnxCloseACPI;
@ -178,7 +178,7 @@ lnxCloseACPI(void)
ErrorF("ACPI: Closing device\n"); ErrorF("ACPI: Closing device\n");
#endif #endif
if (ACPIihPtr) { if (ACPIihPtr) {
fd = xf86RemoveInputHandler(ACPIihPtr); fd = xf86RemoveGeneralHandler(ACPIihPtr);
shutdown(fd, 2); shutdown(fd, 2);
close(fd); close(fd);
ACPIihPtr = NULL; ACPIihPtr = NULL;