xf86Events: add Enable/DisableInputDeviceForVTSwitch functions
Factor this code out into functions so that it can be re-used for the systemd-logind device pause/resume paths. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
48b489769e
commit
bf83843b92
|
@ -215,6 +215,8 @@ extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode;
|
|||
|
||||
/* xf86Events.c */
|
||||
|
||||
typedef struct _InputInfoRec *InputInfoPtr;
|
||||
|
||||
extern _X_EXPORT void SetTimeSinceLastInputEvent(void);
|
||||
extern _X_EXPORT void *xf86AddInputHandler(int fd, InputHandlerProc proc,
|
||||
void *data);
|
||||
|
@ -236,6 +238,8 @@ extern _X_EXPORT void xf86PrintBacktrace(void);
|
|||
extern _X_EXPORT Bool xf86VTOwner(void);
|
||||
extern _X_EXPORT void xf86VTLeave(void);
|
||||
extern _X_EXPORT void xf86VTEnter(void);
|
||||
extern _X_EXPORT void xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo);
|
||||
extern _X_EXPORT void xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo);
|
||||
|
||||
/* xf86Helper.c */
|
||||
|
||||
|
|
|
@ -407,6 +407,28 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo)
|
||||
{
|
||||
if (!pInfo->dev)
|
||||
return;
|
||||
|
||||
if (!pInfo->dev->enabled)
|
||||
pInfo->flags |= XI86_DEVICE_DISABLED;
|
||||
|
||||
xf86ReleaseKeys(pInfo->dev);
|
||||
ProcessInputEvents();
|
||||
DisableDevice(pInfo->dev, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo)
|
||||
{
|
||||
if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
|
||||
EnableDevice(pInfo->dev, TRUE);
|
||||
pInfo->flags &= ~XI86_DEVICE_DISABLED;
|
||||
}
|
||||
|
||||
void
|
||||
xf86VTLeave(void)
|
||||
{
|
||||
|
@ -436,15 +458,8 @@ xf86VTLeave(void)
|
|||
else
|
||||
xf86DisableGeneralHandler(ih);
|
||||
}
|
||||
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
|
||||
if (pInfo->dev) {
|
||||
if (!pInfo->dev->enabled)
|
||||
pInfo->flags |= XI86_DEVICE_DISABLED;
|
||||
xf86ReleaseKeys(pInfo->dev);
|
||||
ProcessInputEvents();
|
||||
DisableDevice(pInfo->dev, TRUE);
|
||||
}
|
||||
}
|
||||
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
|
||||
xf86DisableInputDeviceForVTSwitch(pInfo);
|
||||
|
||||
OsBlockSIGIO();
|
||||
for (i = 0; i < xf86NumScreens; i++)
|
||||
|
@ -494,13 +509,8 @@ switch_failed:
|
|||
}
|
||||
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
|
||||
|
||||
pInfo = xf86InputDevs;
|
||||
while (pInfo) {
|
||||
if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
|
||||
EnableDevice(pInfo->dev, TRUE);
|
||||
pInfo->flags &= ~XI86_DEVICE_DISABLED;
|
||||
pInfo = pInfo->next;
|
||||
}
|
||||
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
|
||||
xf86EnableInputDeviceForVTSwitch(pInfo);
|
||||
for (ih = InputHandlers; ih; ih = ih->next) {
|
||||
if (ih->is_input)
|
||||
xf86EnableInputHandler(ih);
|
||||
|
@ -546,14 +556,8 @@ xf86VTEnter(void)
|
|||
/* Turn screen saver off when switching back */
|
||||
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
|
||||
|
||||
pInfo = xf86InputDevs;
|
||||
while (pInfo) {
|
||||
if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
|
||||
EnableDevice(pInfo->dev, TRUE);
|
||||
pInfo->flags &= ~XI86_DEVICE_DISABLED;
|
||||
pInfo = pInfo->next;
|
||||
}
|
||||
|
||||
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
|
||||
xf86EnableInputDeviceForVTSwitch(pInfo);
|
||||
for (ih = InputHandlers; ih; ih = ih->next) {
|
||||
if (ih->is_input)
|
||||
xf86EnableInputHandler(ih);
|
||||
|
|
Loading…
Reference in New Issue
Block a user