diff options
author | Keith Packard <keithp@keithp.com> | 2015-12-08 11:37:51 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-05-26 16:07:54 -0700 |
commit | 30ac7567980a1eb79d084a63e0e74e1d9a3af673 (patch) | |
tree | 6864c1ea181723bf9bde36638193ca65e0f8929d /include | |
parent | 728c9570a05f03bd90343ff6f5b1a8fd3988864c (diff) |
Create a threaded mechanism for input [v7]
The current SIGIO signal handler method, used at generation of input events,
has a bunch of oddities. This patch introduces an alternative way using a
thread, which is used to select() all input device file descriptors.
A mutex was used to control the access to input structures by the main and input
threads. Two pipes to emit alert events (such hotplug ones) and guarantee the
proper communication between them was also used.
Co-authored-by: Fernando Carrijo <fcarrijo@freedesktop.org>
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
v2: Fix non-Xorg link. Enable where supported by default.
This also splits out the actual enabling of input threads to
DDX-specific patches which follow
v3: Make the input lock recursive
v4: Use regular RECURSIVE_MUTEXes instead of rolling our own
Respect the --disable-input-thread configuration option by
providing stubs that expose the same API/ABI.
Respond to style comments from Peter Hutterer.
v5: use __func__ in inputthread debug and error mesages.
Respond to style comments from Peter Hutterer.
v6: use AX_PTHREAD instead of inlining pthread tests.
Suggested by Emil Velikov <emil.l.velikov@gmail.com>
v7: Use pthread_sigmask instead of sigprocmask when using threads
Suggested by Adam Jackson <ajax@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/dix-config.h.in | 3 | ||||
-rw-r--r-- | include/input.h | 20 | ||||
-rw-r--r-- | include/misc.h | 1 | ||||
-rw-r--r-- | include/os.h | 5 |
4 files changed, 23 insertions, 6 deletions
diff --git a/include/dix-config.h.in b/include/dix-config.h.in index a164c15b5..fc7d1a12c 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -524,4 +524,7 @@ /* Have posix_fallocate() */ #undef HAVE_POSIX_FALLOCATE +/* Use input thread */ +#undef INPUTTHREAD + #endif /* _DIX_CONFIG_H_ */ diff --git a/include/input.h b/include/input.h index 9069a1cb5..e0f6b9b01 100644 --- a/include/input.h +++ b/include/input.h @@ -56,6 +56,7 @@ SOFTWARE. #include "xkbrules.h" #include "events.h" #include "list.h" +#include "os.h" #include <X11/extensions/XI2.h> #define DEVICE_INIT 0 @@ -714,13 +715,20 @@ extern _X_HIDDEN void input_constrain_cursor(DeviceIntPtr pDev, ScreenPtr screen int *out_x, int *out_y, int *nevents, InternalEvent* events); -static inline void input_lock(void) { -} +extern _X_EXPORT void input_lock(void); +extern _X_EXPORT void input_unlock(void); +extern _X_EXPORT void input_force_unlock(void); -static inline void input_unlock(void) { -} +extern void InputThreadPreInit(void); +extern void InputThreadInit(void); +extern void InputThreadFini(void); -static inline void input_force_unlock(void) { -} +extern int InputThreadRegisterDev(int fd, + NotifyFdProcPtr readInputProc, + void *readInputArgs); + +extern int InputThreadUnregisterDev(int fd); + +extern _X_EXPORT Bool InputThreadEnable; #endif /* INPUT_H */ diff --git a/include/misc.h b/include/misc.h index 56e138c6b..006f76822 100644 --- a/include/misc.h +++ b/include/misc.h @@ -79,6 +79,7 @@ OF THIS SOFTWARE. #include <stddef.h> #include <stdint.h> +#include <pthread.h> #ifndef MAXSCREENS #define MAXSCREENS 16 diff --git a/include/os.h b/include/os.h index e9b3709a1..20224f127 100644 --- a/include/os.h +++ b/include/os.h @@ -706,4 +706,9 @@ xorg_backtrace(void); extern _X_EXPORT int os_move_fd(int fd); +#include <signal.h> + +extern _X_EXPORT int +xthread_sigmask(int how, const sigset_t *set, sigset_t *oldest); + #endif /* OS_H */ |