summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Carrijo <fcarrijo@yahoo.com.br>2010-08-03 16:45:20 +0300
committerTiago Vignatti <tiago.vignatti@nokia.com>2010-08-03 18:30:06 +0300
commit30c4c00fcb77170e7d9ad959c2b2c221ae11f330 (patch)
tree5a2e3820217867b55bf20c1e83afeff3a1930bfa
parenta2bff7454d7d427bc1b770ad73db9f9e076895f5 (diff)
os: inputthread: Fix indentation and add comments to WaitForInput
Signed-off-by: Fernando Carrijo <fcarrijo@yahoo.com.br> Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
-rw-r--r--os/inputthread.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/os/inputthread.c b/os/inputthread.c
index 0a950fa12..1a7967bd0 100644
--- a/os/inputthread.c
+++ b/os/inputthread.c
@@ -76,10 +76,17 @@ AddEnabledDeviceThreaded(int fd, void (*f)(void *), void *closure)
DebugF("Input thread: Using PTHREAD for input device %d\n", fd);
}
-/*
- * @return exit code for the child process which currently is none. The child
- * process exits only when the main thread (parent) send a signal or a
- * fatal error occurs.
+/**
+ * The workhorse of threaded input event generation.
+ *
+ * Runs in parallel with the server main thread, listening to input devices in
+ * an endless loop. Whenever new input data is made available, calls the proper
+ * device driver's routines which are ultimately responsible for the generation
+ * of input events as known by X.
+ *
+ * @see _DeviceEvent
+ * @see _RawDeviceEvent
+ * @see _InternalEvent
*/
static void*
WaitForInput(void* argument)
@@ -93,9 +100,12 @@ WaitForInput(void* argument)
while (1)
{
- XFD_COPYSET (&InputThreadFd, &ReadyInputDevices);
+ XFD_COPYSET(&InputThreadFd, &ReadyInputDevices);
+
+ DebugF("inputthread: WaitForInput() blocking in Select()\n");
i = Select(MaxInputDevices, &ReadyInputDevices, NULL, NULL, NULL);
- DebugF("threading input generation\n");
+ DebugF("inputthread: WaitForInput() awakening from Select()\n");
+
if (i <= 0) /* An error or timeout occurred */
{
if (i < 0) /* This logic are stolen from WaitFor.c */
@@ -112,17 +122,15 @@ WaitForInput(void* argument)
}
}
}
- else
- {
- for (i = 0; i < NumDevicesThreaded; i++)
- if ((FD_ISSET(ThreadDevFunc[i].fd, &ReadyInputDevices))
- && ThreadDevFunc[i].f)
- (*ThreadDevFunc[i].f)(ThreadDevFunc[i].closure);
- }
+ /* Call the device drivers to generate input events for us */
+ for (i = 0; i < NumDevicesThreaded; i++)
+ if ((FD_ISSET(ThreadDevFunc[i].fd, &ReadyInputDevices))
+ && ThreadDevFunc[i].f)
+ (*ThreadDevFunc[i].f)(ThreadDevFunc[i].closure);
- /* Send a null byte to the main thread so it wakes select up to
- * process the events in mieqProcessInputEvents() */
+ /* Kick main thread to process the generated input events */
+ DebugF("inputthread: WaitforInput() notifying main thread\n");
PipeWrite(InputThreadWritePipe);
}
}