[PATCH xserver 1/4] xfree86: Add VT client tracking
Adam Jackson
ajax at redhat.com
Thu Jun 29 14:24:33 UTC 2017
A VT client is one that needs to be put to sleep when we don't own the
VT, and woken up when we regain it.
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
hw/xfree86/common/xf86.h | 3 +++
hw/xfree86/common/xf86Events.c | 55 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 674e83cb1..3b66d20ff 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -222,6 +222,9 @@ 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 Bool xf86SetupVTClients(void);
+extern _X_EXPORT void xf86SetVTClient(ClientPtr client);
+extern _X_EXPORT int xf86SetAndSleepVTClient(ClientPtr client);
extern _X_EXPORT void xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo);
extern _X_EXPORT void xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo);
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 53ec74f26..76fb6192c 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -393,6 +393,59 @@ xf86UpdateHasVTProperty(Bool hasVT)
}
}
+static DevPrivateKeyRec VTClientPrivateKey;
+
+static int *
+clientVTSleep(ClientPtr client)
+{
+ return dixGetPrivateAddr(&client->devPrivates, &VTClientPrivateKey);
+}
+
+Bool
+xf86SetupVTClients(void)
+{
+ return dixRegisterPrivateKey(&VTClientPrivateKey, PRIVATE_CLIENT,
+ sizeof(int));
+}
+
+static void
+xf86SleepVTClients(void)
+{
+ for (int i = 1; i < currentMaxClients; i++) {
+ ClientPtr client = clients[i];
+
+ if (*clientVTSleep(client))
+ IgnoreClient(client);
+ }
+}
+
+static void
+xf86WakeVTClients(void)
+{
+ for (int i = 1; i < currentMaxClients; i++) {
+ ClientPtr client = clients[i];
+
+ if (*clientVTSleep(client))
+ AttendClient(client);
+ }
+}
+
+void
+xf86SetVTClient(ClientPtr client)
+{
+ *clientVTSleep(client) = TRUE;
+}
+
+int
+xf86SetAndSleepVTClient(ClientPtr client)
+{
+ xf86SetVTClient(client);
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+ return Success;
+}
+
void
xf86VTLeave(void)
{
@@ -451,6 +504,7 @@ xf86VTLeave(void)
xf86DisableIO();
xf86UpdateHasVTProperty(FALSE);
+ xf86SleepVTClients();
return;
@@ -535,6 +589,7 @@ xf86VTEnter(void)
xf86platformVTProbe();
#endif
+ xf86WakeVTClients();
xf86UpdateHasVTProperty(TRUE);
input_unlock();
--
2.13.0
More information about the xorg-devel
mailing list