summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2006-11-08 17:57:48 +0200
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-11-08 18:10:40 +0200
commit66b2c9bd2dddf8f8410147ebf1de7a6c045d8249 (patch)
treeedb9875d65d461dd93e3bd05371532ea53c703bc
parent58653b676d68b731c046128eade8efff9ab61582 (diff)
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.
-rw-r--r--hw/xfree86/common/xf86.h4
-rw-r--r--hw/xfree86/common/xf86Events.c101
-rw-r--r--hw/xfree86/os-support/linux/lnx_acpi.c4
-rw-r--r--include/os.h4
-rw-r--r--os/connection.c22
5 files changed, 114 insertions, 21 deletions
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 458750007..51125304e 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -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);
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 831c68ad8..b1ee1e93e 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -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,15 +1656,50 @@ xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
ih->next = InputHandlers;
InputHandlers = ih;
- AddEnabledDevice(fd);
+ return ih;
+}
+
+_X_EXPORT pointer
+xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih = addInputHandler(fd, proc, data);
+
+ 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;
+ else {
+ p = InputHandlers;
+ while (p && p->next != ih)
+ p = p->next;
+ if (ih)
+ p->next = ih->next;
+ }
+ xfree(ih);
+}
+
_X_EXPORT int
xf86RemoveInputHandler(pointer handler)
{
- IHPtr ih, p;
+ IHPtr ih;
int fd;
if (!handler)
@@ -1675,17 +1710,27 @@ xf86RemoveInputHandler(pointer handler)
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);
- if (ih == InputHandlers)
- InputHandlers = ih->next;
- else {
- p = InputHandlers;
- while (p && p->next != ih)
- p = p->next;
- if (ih)
- p->next = ih->next;
- }
- xfree(ih);
return fd;
}
@@ -1704,6 +1749,20 @@ xf86DisableInputHandler(pointer handler)
}
_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)
{
IHPtr ih;
@@ -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.
*/
diff --git a/hw/xfree86/os-support/linux/lnx_acpi.c b/hw/xfree86/os-support/linux/lnx_acpi.c
index eca76dbf3..aa30e72c2 100644
--- a/hw/xfree86/os-support/linux/lnx_acpi.c
+++ b/hw/xfree86/os-support/linux/lnx_acpi.c
@@ -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;
diff --git a/include/os.h b/include/os.h
index 4c4967164..fbe1592a1 100644
--- a/include/os.h
+++ b/include/os.h
@@ -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*/);
diff --git a/os/connection.c b/os/connection.c
index 6ca4010e2..daad2ac8a 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1048,21 +1048,33 @@ CloseDownConnection(ClientPtr client)
}
_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);
}
/*****************