diff options
author | Michael Thayer <michael.thayer@oracle.com> | 2014-03-31 11:19:16 +0200 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-04-03 16:46:20 -0700 |
commit | 62ab4102260fd3342a0e5ae3a4f77b430af64f4e (patch) | |
tree | fa4fc2ded2e63e4c92c4153dd2f7f26ab40d64bd /hw/xfree86 | |
parent | b851ca968b7cce6d1a6438c05d3d5c8832249704 (diff) |
Set a flag property on the root window to say if the X server VT is active
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@oracle.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'hw/xfree86')
-rw-r--r-- | hw/xfree86/common/xf86Events.c | 28 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Init.c | 16 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Privstr.h | 4 |
3 files changed, 47 insertions, 1 deletions
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 06af73903..35a673d15 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 4579ff591..5a45004f5 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 f7a9c9f1c..410ef17ac 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 */ |