xfree86: add a hook to replace the new console handler.
This hook is only necessary for the keyboard driver to remove the race condition between drain_console() and the driver's ReadInput (Bug 29969). The idea is that a driver that needs to handle events from the console calls xf86ReplaceConsoleHandler() with it's own ReadInput (or NULL) and thus removes the drain_console call. It's the driver's responsibility to restore the previous behaviour when the driver is unloaded. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> CC: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
da31ca747f
commit
9dca441670
|
@ -203,6 +203,7 @@ extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, po
|
||||||
extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler);
|
extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler);
|
||||||
extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler);
|
extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler);
|
||||||
extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler);
|
extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler);
|
||||||
|
extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, pointer data);
|
||||||
extern _X_EXPORT void xf86InterceptSignals(int *signo);
|
extern _X_EXPORT void xf86InterceptSignals(int *signo);
|
||||||
extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void));
|
extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void));
|
||||||
extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new);
|
extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new);
|
||||||
|
|
|
@ -600,6 +600,26 @@ xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
|
||||||
return ih;
|
return ih;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the handler for the console's fd. Replaces (and returns) the previous
|
||||||
|
* handler or NULL, whichever appropriate.
|
||||||
|
* proc may be NULL if the server should not handle events on the console.
|
||||||
|
*/
|
||||||
|
InputHandlerProc
|
||||||
|
xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
|
||||||
|
{
|
||||||
|
static InputHandlerProc handler = NULL;
|
||||||
|
InputHandlerProc old_handler = handler;
|
||||||
|
|
||||||
|
if (old_handler)
|
||||||
|
xf86RemoveGeneralHandler(old_handler);
|
||||||
|
|
||||||
|
xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
|
||||||
|
handler = proc;
|
||||||
|
|
||||||
|
return old_handler;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
removeInputHandler(IHPtr ih)
|
removeInputHandler(IHPtr ih)
|
||||||
{
|
{
|
||||||
|
|
|
@ -277,9 +277,7 @@ xf86OpenConsole(void)
|
||||||
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
|
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
|
||||||
|
|
||||||
/* need to keep the buffer clean, else the kernel gets angry */
|
/* need to keep the buffer clean, else the kernel gets angry */
|
||||||
if (xf86Info.allowEmptyInput)
|
xf86SetConsoleHandler(drain_console, NULL);
|
||||||
console_handler = xf86AddGeneralHandler(xf86Info.consoleFd,
|
|
||||||
drain_console, NULL);
|
|
||||||
|
|
||||||
/* we really should have a InitOSInputDevices() function instead
|
/* we really should have a InitOSInputDevices() function instead
|
||||||
* of Init?$#*&Device(). So I just place it here */
|
* of Init?$#*&Device(). So I just place it here */
|
||||||
|
|
Loading…
Reference in New Issue