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>
This commit is contained in:
parent
b851ca968b
commit
62ab410226
|
@ -56,6 +56,7 @@
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include <X11/Xpoll.h>
|
#include <X11/Xpoll.h>
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include "xf86.h"
|
#include "xf86.h"
|
||||||
|
@ -431,6 +432,29 @@ xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo)
|
||||||
pInfo->flags &= ~XI86_DEVICE_DISABLED;
|
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
|
void
|
||||||
xf86VTLeave(void)
|
xf86VTLeave(void)
|
||||||
{
|
{
|
||||||
|
@ -490,6 +514,8 @@ xf86VTLeave(void)
|
||||||
if (xorgHWAccess)
|
if (xorgHWAccess)
|
||||||
xf86DisableIO();
|
xf86DisableIO();
|
||||||
|
|
||||||
|
xf86UpdateHasVTProperty(FALSE);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch_failed:
|
switch_failed:
|
||||||
|
@ -574,6 +600,8 @@ xf86VTEnter(void)
|
||||||
xf86platformVTProbe();
|
xf86platformVTProbe();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
xf86UpdateHasVTProperty(TRUE);
|
||||||
|
|
||||||
OsReleaseSIGIO();
|
OsReleaseSIGIO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 --
|
* InitOutput --
|
||||||
* Initialize screenInfo for all actually accessible framebuffers.
|
* Initialize screenInfo for all actually accessible framebuffers.
|
||||||
|
@ -731,7 +736,9 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
|
||||||
if (xf86Info.vtno >= 0) {
|
if (xf86Info.vtno >= 0) {
|
||||||
#define VT_ATOM_NAME "XFree86_VT"
|
#define VT_ATOM_NAME "XFree86_VT"
|
||||||
Atom VTAtom = -1;
|
Atom VTAtom = -1;
|
||||||
|
Atom HasVTAtom = -1;
|
||||||
CARD32 *VT = NULL;
|
CARD32 *VT = NULL;
|
||||||
|
CARD32 *HasVT = &HasVTValue;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* This memory needs to stay available until the screen has been
|
/* 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;
|
*VT = xf86Info.vtno;
|
||||||
|
|
||||||
VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
|
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;
|
for (i = 0, ret = Success; i < xf86NumScreens && ret == Success;
|
||||||
i++) {
|
i++) {
|
||||||
|
@ -751,9 +760,14 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
|
||||||
xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
|
xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
|
||||||
VTAtom, XA_INTEGER, 32, 1,
|
VTAtom, XA_INTEGER, 32, 1,
|
||||||
VT);
|
VT);
|
||||||
|
if (ret == Success)
|
||||||
|
ret = xf86RegisterRootWindowProperty(xf86Screens[i]
|
||||||
|
->scrnIndex,
|
||||||
|
HasVTAtom, XA_INTEGER,
|
||||||
|
32, 1, HasVT);
|
||||||
if (ret != Success)
|
if (ret != Success)
|
||||||
xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
|
xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
|
||||||
"Failed to register VT property\n");
|
"Failed to register VT properties\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,4 +163,8 @@ typedef struct _RootWinProp {
|
||||||
#define WSCONS 32
|
#define WSCONS 32
|
||||||
#endif
|
#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 */
|
#endif /* _XF86PRIVSTR_H */
|
||||||
|
|
Loading…
Reference in New Issue