diff options
Diffstat (limited to 'xorg-server/hw/xfree86/common')
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Events.c | 28 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Globals.c | 2 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Helper.c | 31 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Init.c | 16 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Module.h | 2 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86Privstr.h | 4 |
6 files changed, 79 insertions, 4 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c index 06af73903..35a673d15 100644 --- a/xorg-server/hw/xfree86/common/xf86Events.c +++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c index 7df7a80c4..984c39bca 100644 --- a/xorg-server/hw/xfree86/common/xf86Globals.c +++ b/xorg-server/hw/xfree86/common/xf86Globals.c @@ -143,7 +143,7 @@ const char *xf86ConfigFile = NULL; const char *xf86ConfigDir = NULL; const char *xf86ModulePath = DEFAULT_MODULE_PATH; MessageType xf86ModPathFrom = X_DEFAULT; -const char *xf86LogFile = DEFAULT_LOGPREFIX; +const char *xf86LogFile = DEFAULT_LOGDIR "/" DEFAULT_LOGPREFIX; MessageType xf86LogFileFrom = X_DEFAULT; Bool xf86LogFileWasOpened = FALSE; serverLayoutRec xf86ConfigLayout = { NULL, }; diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index 12a877159..e2b32a074 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -1217,16 +1217,45 @@ xf86ErrorF(const char *format, ...) va_end(ap); } +/* Note temporarily modifies the passed in buffer! */ +static void xf86_mkdir_p(char *path) +{ + char *sep = path; + + while ((sep = strchr(sep + 1, '/'))) { + *sep = 0; + (void)mkdir(path, 0777); + *sep = '/'; + } + (void)mkdir(path, 0777); +} + void xf86LogInit(void) { - char *lf = NULL; + char *env, *lf = NULL; + char buf[PATH_MAX]; #define LOGSUFFIX ".log" #define LOGOLDSUFFIX ".old" /* Get the log file name */ if (xf86LogFileFrom == X_DEFAULT) { + /* When not running as root, we won't be able to write to /var/log */ + if (geteuid() != 0) { + if ((env = getenv("XDG_DATA_HOME"))) + snprintf(buf, sizeof(buf), "%s/%s", env, + DEFAULT_XDG_DATA_HOME_LOGDIR); + else if ((env = getenv("HOME"))) + snprintf(buf, sizeof(buf), "%s/%s/%s", env, + DEFAULT_XDG_DATA_HOME, DEFAULT_XDG_DATA_HOME_LOGDIR); + + if (env) { + xf86_mkdir_p(buf); + strlcat(buf, "/" DEFAULT_LOGPREFIX, sizeof(buf)); + xf86LogFile = buf; + } + } /* Append the display number and ".log" */ if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1) FatalError("Cannot allocate space for the log file name\n"); diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c index 4579ff591..5a45004f5 100644 --- a/xorg-server/hw/xfree86/common/xf86Init.c +++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h index e8c24f26c..62ac95d5a 100644 --- a/xorg-server/hw/xfree86/common/xf86Module.h +++ b/xorg-server/hw/xfree86/common/xf86Module.h @@ -80,7 +80,7 @@ typedef enum { * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(16, 0) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(17, 0) #define ABI_XINPUT_VERSION SET_ABI_VERSION(21, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(8, 0) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) diff --git a/xorg-server/hw/xfree86/common/xf86Privstr.h b/xorg-server/hw/xfree86/common/xf86Privstr.h index f7a9c9f1c..410ef17ac 100644 --- a/xorg-server/hw/xfree86/common/xf86Privstr.h +++ b/xorg-server/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 */ |