[PATCH] Set a flag property on the root window to say if the X server VT is active
Michael Thayer
michael.thayer at oracle.com
Tue Mar 25 07:37:19 PDT 2014
An X11 client may need to know whether the X server virtual terminal is
currently the active one. This change adds a root window property which
provides that information. Intended interface user: the VirtualBox Guest
Additions.
Signed-off-by: Michael Thayer <michael.thayer at oracle.com>
---
This is an updated version of my previous patch to address Daniel's concerns.
Regards,
Michael
hw/xfree86/common/xf86Events.c | 28 ++++++++++++++++++++++++++++
hw/xfree86/common/xf86Init.c | 16 +++++++++++++++-
hw/xfree86/common/xf86Privstr.h | 4 ++++
3 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 06af739..35a673d 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -56,6 +56,7 @@
#include <X11/X.h>
#include <X11/Xpoll.h>
#include <X11/Xproto.h>
+#include <X11/Xatom.h>
#include "misc.h"
#include "compiler.h"
#include "xf86.h"
@@ -431,6 +432,29 @@ xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo)
pInfo->flags &= ~XI86_DEVICE_DISABLED;
}
+/*
+ * xf86UpdateHasVTProperty --
+ * Update a flag property on the root window to say whether the server VT
+ * is currently the active one as some clients need to know this.
+ */
+static void
+xf86UpdateHasVTProperty(Bool hasVT)
+{
+ Atom property_name;
+ int32_t value = hasVT ? 1 : 0;
+ int i;
+
+ property_name = MakeAtom(HAS_VT_ATOM_NAME, sizeof(HAS_VT_ATOM_NAME) - 1,
+ FALSE);
+ if (property_name == BAD_RESOURCE)
+ FatalError("Failed to retrieve \"HAS_VT\" atom\n");
+ for (i = 0; i < xf86NumScreens; i++) {
+ ChangeWindowProperty(xf86ScrnToScreen(xf86Screens[i])->root,
+ property_name, XA_INTEGER, 32,
+ PropModeReplace, 1, &value, TRUE);
+ }
+}
+
void
xf86VTLeave(void)
{
@@ -490,6 +514,8 @@ xf86VTLeave(void)
if (xorgHWAccess)
xf86DisableIO();
+ xf86UpdateHasVTProperty(FALSE);
+
return;
switch_failed:
@@ -574,6 +600,8 @@ xf86VTEnter(void)
xf86platformVTProbe();
#endif
+ xf86UpdateHasVTProperty(TRUE);
+
OsReleaseSIGIO();
}
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 4579ff5..5a45004 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -387,6 +387,11 @@ InstallSignalHandlers(void)
}
}
+/* The memory storing the initial value of the XFree86_has_VT root window
+ * property. This has to remain available until server start-up, so we just
+ * use a global. */
+static CARD32 HasVTValue = 1;
+
/*
* InitOutput --
* Initialize screenInfo for all actually accessible framebuffers.
@@ -731,7 +736,9 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
if (xf86Info.vtno >= 0) {
#define VT_ATOM_NAME "XFree86_VT"
Atom VTAtom = -1;
+ Atom HasVTAtom = -1;
CARD32 *VT = NULL;
+ CARD32 *HasVT = &HasVTValue;
int ret;
/* This memory needs to stay available until the screen has been
@@ -744,6 +751,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
*VT = xf86Info.vtno;
VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
+ HasVTAtom = MakeAtom(HAS_VT_ATOM_NAME,
+ sizeof(HAS_VT_ATOM_NAME) - 1, TRUE);
for (i = 0, ret = Success; i < xf86NumScreens && ret == Success;
i++) {
@@ -751,9 +760,14 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
VTAtom, XA_INTEGER, 32, 1,
VT);
+ if (ret == Success)
+ ret = xf86RegisterRootWindowProperty(xf86Screens[i]
+ ->scrnIndex,
+ HasVTAtom, XA_INTEGER,
+ 32, 1, HasVT);
if (ret != Success)
xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
- "Failed to register VT property\n");
+ "Failed to register VT properties\n");
}
}
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index f7a9c9f..410ef17 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -163,4 +163,8 @@ typedef struct _RootWinProp {
#define WSCONS 32
#endif
+/* Root window property to tell clients whether our VT is currently active.
+ * Name chosen to match the "XFree86_VT" property. */
+#define HAS_VT_ATOM_NAME "XFree86_has_VT"
+
#endif /* _XF86PRIVSTR_H */
--
ORACLE Deutschland B.V. & Co. KG Michael Thayer
Werkstrasse 24 VirtualBox engineering
71384 Weinstadt, Germany mailto:michael.thayer at oracle.com
Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603
Geschäftsführer: Jürgen Kunz
Komplementärin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Alexander van der Ven, Astrid Kepper, Val Maher
More information about the xorg-devel
mailing list