[PATCH 1/4] xfree86: move -novtswitch & -sharevts argument handling up to common layer
Alan Coopersmith
alan.coopersmith at oracle.com
Fri Aug 26 19:19:56 PDT 2011
Stop duplicating in each os-support variant before it gets replicated
even further.
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
hw/xfree86/common/xf86Globals.c | 2 ++
hw/xfree86/common/xf86Init.c | 12 ++++++++++++
hw/xfree86/common/xf86Privstr.h | 2 ++
hw/xfree86/os-support/bsd/bsd_init.c | 17 ++++++-----------
hw/xfree86/os-support/linux/lnx_init.c | 25 ++++++-------------------
5 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 16d5557..f2e88c2 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -103,6 +103,8 @@ xf86InfoRec xf86Info = {
.vtPendingNum = -1,
#endif
.dontVTSwitch = FALSE,
+ .autoVTSwitch = TRUE,
+ .ShareVTs = FALSE,
.dontZap = FALSE,
.dontZoom = FALSE,
.notrapSignals = FALSE,
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 71926f8..93ea333 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1352,6 +1352,16 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86xkbdirFlag = TRUE;
return 0;
}
+ if (!strcmp(argv[i], "-novtswitch"))
+ {
+ xf86Info.autoVTSwitch = FALSE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ xf86Info.ShareVTs = TRUE;
+ return 1;
+ }
/* OS-specific processing */
return xf86ProcessArgument(argc, argv, i);
@@ -1408,6 +1418,8 @@ ddxUseMsg(void)
ErrorF("-version show the server version\n");
ErrorF("-showDefaultModulePath show the server default module path\n");
ErrorF("-showDefaultLibPath show the server default library path\n");
+ ErrorF("-novtswitch don't automatically switch VT at reset & exit\n");
+ ErrorF("-sharevts share VTs with another X server\n");
/* OS-specific usage */
xf86UseMsg();
ErrorF("\n");
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 608f9bd..cdc67cb 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -66,6 +66,8 @@ typedef struct {
int vtPendingNum;
#endif
Bool dontVTSwitch;
+ Bool autoVTSwitch;
+ Bool ShareVTs;
Bool dontZap;
Bool dontZoom;
Bool notrapSignals; /* don't exit cleanly - die at fault */
diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c
index 123eb17..837a2f4 100644
--- a/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/hw/xfree86/os-support/bsd/bsd_init.c
@@ -45,7 +45,6 @@ static int devConsoleFd = -1;
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
static int VTnum = -1;
static int initialVT = -1;
-static Bool ShareVTs = FALSE;
#endif
#ifdef PCCONS_SUPPORT
@@ -266,7 +265,7 @@ xf86OpenConsole()
}
#endif
acquire_vt:
- if (!ShareVTs) {
+ if (!xf86Info.ShareVTs) {
/*
* now get the VT
*/
@@ -304,7 +303,7 @@ acquire_vt:
{
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
}
- } else { /* ShareVTs */
+ } else { /* xf86Info.ShareVTs */
close(xf86Info.consoleFd);
}
break;
@@ -320,7 +319,8 @@ acquire_vt:
{
/* serverGeneration != 1 */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+ if (!xf86Info.ShareVTs &&
+ (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT))
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
@@ -393,7 +393,7 @@ xf86OpenSyscons()
if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
initialVT = -1;
#endif
- if (ShareVTs)
+ if (xf86Info.ShareVTs)
xf86Info.vtno = initialVT;
if (xf86Info.vtno == -1)
@@ -655,7 +655,7 @@ xf86CloseConsole()
struct vt_mode VT;
#endif
- if (ShareVTs) return;
+ if (xf86Info.ShareVTs) return;
switch (xf86Info.consType)
{
@@ -723,11 +723,6 @@ xf86ProcessArgument(int argc, char *argv[], int i)
return 1;
}
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!strcmp(argv[i], "-sharevts"))
- {
- ShareVTs = TRUE;
- return 1;
- }
if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{
if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 77dfb2f..9c91740 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -39,8 +39,6 @@
#include <sys/stat.h>
static Bool KeepTty = FALSE;
-static Bool VTSwitch = TRUE;
-static Bool ShareVTs = FALSE;
static int activeVT = -1;
static char vtname[11];
@@ -109,7 +107,7 @@ xf86OpenConsole(void)
"xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
strerror(errno));
- if (ShareVTs)
+ if (xf86Info.ShareVTs)
{
SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
if (ret < 0)
@@ -184,7 +182,7 @@ xf86OpenConsole(void)
}
#endif
- if (!ShareVTs)
+ if (!xf86Info.ShareVTs)
{
struct termios nTty;
@@ -240,7 +238,7 @@ xf86OpenConsole(void)
* of Init?$#*&Device(). So I just place it here */
}
} else { /* serverGeneration != 1 */
- if (!ShareVTs && VTSwitch)
+ if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch)
{
/* now get the VT */
switch_to(xf86Info.vtno, "xf86OpenConsole");
@@ -254,7 +252,7 @@ xf86CloseConsole(void)
struct vt_mode VT;
int ret;
- if (ShareVTs) {
+ if (xf86Info.ShareVTs) {
close(xf86Info.consoleFd);
return;
}
@@ -286,7 +284,7 @@ xf86CloseConsole(void)
strerror(errno));
}
- if (VTSwitch)
+ if (xf86Info.autoVTSwitch)
{
/*
* Perform a switch back to the active VT when we were started
@@ -311,16 +309,7 @@ xf86ProcessArgument(int argc, char *argv[], int i)
KeepTty = TRUE;
return 1;
}
- if (!strcmp(argv[i], "-novtswitch"))
- {
- VTSwitch = FALSE;
- return 1;
- }
- if (!strcmp(argv[i], "-sharevts"))
- {
- ShareVTs = TRUE;
- return 1;
- }
+
if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{
if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0)
@@ -340,6 +329,4 @@ xf86UseMsg(void)
ErrorF("vtXX use the specified VT number\n");
ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n");
- ErrorF("-novtswitch don't immediately switch to new VT\n");
- ErrorF("-sharevts share VTs with another X server\n");
}
--
1.7.3.2
More information about the xorg-devel
mailing list