xfree86: move -novtswitch & -sharevts argument handling up to common layer

Stop duplicating in each os-support variant before it gets replicated
even further.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Alexandr Shadchin <Alexandr.Shadchin@gmail.com>
This commit is contained in:
Alan Coopersmith 2011-05-19 22:39:09 -07:00
parent 0caeef6146
commit 93abda6bdd
5 changed files with 28 additions and 30 deletions

View File

@ -103,6 +103,8 @@ xf86InfoRec xf86Info = {
.vtPendingNum = -1, .vtPendingNum = -1,
#endif #endif
.dontVTSwitch = FALSE, .dontVTSwitch = FALSE,
.autoVTSwitch = TRUE,
.ShareVTs = FALSE,
.dontZap = FALSE, .dontZap = FALSE,
.dontZoom = FALSE, .dontZoom = FALSE,
.notrapSignals = FALSE, .notrapSignals = FALSE,

View File

@ -1352,6 +1352,16 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86xkbdirFlag = TRUE; xf86xkbdirFlag = TRUE;
return 0; 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 */ /* OS-specific processing */
return xf86ProcessArgument(argc, argv, i); return xf86ProcessArgument(argc, argv, i);
@ -1408,6 +1418,8 @@ ddxUseMsg(void)
ErrorF("-version show the server version\n"); ErrorF("-version show the server version\n");
ErrorF("-showDefaultModulePath show the server default module path\n"); ErrorF("-showDefaultModulePath show the server default module path\n");
ErrorF("-showDefaultLibPath show the server default library 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 */ /* OS-specific usage */
xf86UseMsg(); xf86UseMsg();
ErrorF("\n"); ErrorF("\n");

View File

@ -66,6 +66,8 @@ typedef struct {
int vtPendingNum; int vtPendingNum;
#endif #endif
Bool dontVTSwitch; Bool dontVTSwitch;
Bool autoVTSwitch;
Bool ShareVTs;
Bool dontZap; Bool dontZap;
Bool dontZoom; Bool dontZoom;
Bool notrapSignals; /* don't exit cleanly - die at fault */ Bool notrapSignals; /* don't exit cleanly - die at fault */

View File

@ -45,7 +45,6 @@ static int devConsoleFd = -1;
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
static int VTnum = -1; static int VTnum = -1;
static int initialVT = -1; static int initialVT = -1;
static Bool ShareVTs = FALSE;
#endif #endif
#ifdef PCCONS_SUPPORT #ifdef PCCONS_SUPPORT
@ -266,7 +265,7 @@ xf86OpenConsole()
} }
#endif #endif
acquire_vt: acquire_vt:
if (!ShareVTs) { if (!xf86Info.ShareVTs) {
/* /*
* now get the VT * now get the VT
*/ */
@ -304,7 +303,7 @@ acquire_vt:
{ {
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed"); FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
} }
} else { /* ShareVTs */ } else { /* xf86Info.ShareVTs */
close(xf86Info.consoleFd); close(xf86Info.consoleFd);
} }
break; break;
@ -320,7 +319,8 @@ acquire_vt:
{ {
/* serverGeneration != 1 */ /* serverGeneration != 1 */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) #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) if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{ {
@ -393,7 +393,7 @@ xf86OpenSyscons()
if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
initialVT = -1; initialVT = -1;
#endif #endif
if (ShareVTs) if (xf86Info.ShareVTs)
xf86Info.vtno = initialVT; xf86Info.vtno = initialVT;
if (xf86Info.vtno == -1) if (xf86Info.vtno == -1)
@ -655,7 +655,7 @@ xf86CloseConsole()
struct vt_mode VT; struct vt_mode VT;
#endif #endif
if (ShareVTs) return; if (xf86Info.ShareVTs) return;
switch (xf86Info.consType) switch (xf86Info.consType)
{ {
@ -723,11 +723,6 @@ xf86ProcessArgument(int argc, char *argv[], int i)
return 1; return 1;
} }
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) #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 ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{ {
if (sscanf(argv[i], "vt%2d", &VTnum) == 0 || if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||

View File

@ -39,8 +39,6 @@
#include <sys/stat.h> #include <sys/stat.h>
static Bool KeepTty = FALSE; static Bool KeepTty = FALSE;
static Bool VTSwitch = TRUE;
static Bool ShareVTs = FALSE;
static int activeVT = -1; static int activeVT = -1;
static char vtname[11]; static char vtname[11];
@ -109,7 +107,7 @@ xf86OpenConsole(void)
"xf86OpenConsole: Cannot open /dev/tty0 (%s)\n", "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
strerror(errno)); strerror(errno));
if (ShareVTs) if (xf86Info.ShareVTs)
{ {
SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts)); SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
if (ret < 0) if (ret < 0)
@ -184,7 +182,7 @@ xf86OpenConsole(void)
} }
#endif #endif
if (!ShareVTs) if (!xf86Info.ShareVTs)
{ {
struct termios nTty; struct termios nTty;
@ -240,7 +238,7 @@ xf86OpenConsole(void)
* of Init?$#*&Device(). So I just place it here */ * of Init?$#*&Device(). So I just place it here */
} }
} else { /* serverGeneration != 1 */ } else { /* serverGeneration != 1 */
if (!ShareVTs && VTSwitch) if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch)
{ {
/* now get the VT */ /* now get the VT */
switch_to(xf86Info.vtno, "xf86OpenConsole"); switch_to(xf86Info.vtno, "xf86OpenConsole");
@ -254,7 +252,7 @@ xf86CloseConsole(void)
struct vt_mode VT; struct vt_mode VT;
int ret; int ret;
if (ShareVTs) { if (xf86Info.ShareVTs) {
close(xf86Info.consoleFd); close(xf86Info.consoleFd);
return; return;
} }
@ -286,7 +284,7 @@ xf86CloseConsole(void)
strerror(errno)); strerror(errno));
} }
if (VTSwitch) if (xf86Info.autoVTSwitch)
{ {
/* /*
* Perform a switch back to the active VT when we were started * 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; KeepTty = TRUE;
return 1; 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 ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{ {
if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0) if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0)
@ -340,6 +329,4 @@ xf86UseMsg(void)
ErrorF("vtXX use the specified VT number\n"); ErrorF("vtXX use the specified VT number\n");
ErrorF("-keeptty "); ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n"); 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");
} }