summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-12-19 14:10:18 +0100
committerKeith Packard <keithp@keithp.com>2014-01-29 15:29:56 -0800
commitbf83843b92ce21d11f6ff1a407ff3d014e017c9b (patch)
treedf038767203e03a5e7615fbb858ad28ca9d3dd59
parent48b489769e78fa20911630173ab708feecb0fb0e (diff)
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>
-rw-r--r--hw/xfree86/common/xf86.h4
-rw-r--r--hw/xfree86/common/xf86Events.c52
2 files changed, 32 insertions, 24 deletions
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 537d1d12a..cec31354e 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -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 */
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index e0ec76825..7b53949fa 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -408,6 +408,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)
{
int i;
@@ -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);