2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
|
|
|
|
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
2005-01-14 19:42:26 +01:00
|
|
|
* documentation, and that the names of Orest Zborowski and David Wexelblat
|
|
|
|
* not be used in advertising or publicity pertaining to distribution of
|
2003-11-14 16:54:54 +01:00
|
|
|
* the software without specific, written prior permission. Orest Zborowski
|
2005-01-14 19:42:26 +01:00
|
|
|
* and David Wexelblat make no representations about the suitability of this
|
|
|
|
* software for any purpose. It is provided "as is" without express or
|
2003-11-14 16:54:54 +01:00
|
|
|
* implied warranty.
|
|
|
|
*
|
2005-01-14 19:42:26 +01:00
|
|
|
* OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
|
|
|
|
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
|
|
|
|
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
2003-11-14 16:54:54 +01:00
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xmd.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#include "compiler.h"
|
|
|
|
|
|
|
|
#include "xf86.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "xf86Priv.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "xf86_OSlib.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "lnx.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-01-14 19:42:26 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef USE_DEV_FB
|
|
|
|
extern char *getenv(const char *);
|
|
|
|
#include <linux/fb.h>
|
|
|
|
char *fb_dev_name;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static Bool KeepTty = FALSE;
|
|
|
|
static int VTnum = -1;
|
2005-07-04 20:41:04 +02:00
|
|
|
static Bool VTSwitch = TRUE;
|
|
|
|
static Bool ShareVTs = FALSE;
|
2003-11-14 16:54:54 +01:00
|
|
|
static int activeVT = -1;
|
|
|
|
|
2005-01-14 19:42:26 +01:00
|
|
|
static int vtPermSave[4];
|
|
|
|
static char vtname[11];
|
xfree86: if AllowEmptyInput is true, enable RAW mode on the console.
Usually, the console is set to RAW in the kbd driver. If we hotplug all input
devices (i.e. the evdev driver for keyboards) and the console is left as-is.
As a result, the evdev driver must put an EVIOCGRAB on the device to avoid
characters leaking onto the console. This again breaks many things, amongst
them lirc, in-kernel mouse button emulation and HAL.
This patch sets the console to RAW if AllowEmptyInput is on.
Use-cases:
1. AEI is off
1.1. Only kbd driver is used - behaviour as-is.
1.2. kbd and evdev driver is used: if evdev does not grab the device,
duplicate events are generated.
2. AEI is on
2.1. Only evdev driver is used - behaviour as-is, but evdev does not need
to grab the device anymore.
2.2. evdev and kbd are used: duplicate key events are generated if evdev
does not grab the device.
1.2 is a marginal use-case that can be fixed by adding a "grab" option to the
evdev driver (update of xorg.conf is needed).
2.2 is an issue. If we have no ServerLayout section, AEI is on, but devices
specified in the xorg.conf are still added [1], resulting in duplicate events.
This is a common configuration and needs sorting out.
[1] 2eaed4a10fe5bf727579bca4ab8d4a47c8763a7d
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2008-10-12 13:28:30 +02:00
|
|
|
static struct termios tty_attr; /* tty state to restore */
|
|
|
|
static int tty_mode; /* kbd mode to restore */
|
2005-01-14 19:42:26 +01:00
|
|
|
|
|
|
|
static int
|
|
|
|
saveVtPerms(void)
|
|
|
|
{
|
|
|
|
/* We need to use stat to get permissions. */
|
|
|
|
struct stat svtp;
|
|
|
|
|
|
|
|
/* Do them numerically ordered, hard coded tty0 first. */
|
|
|
|
if (stat("/dev/tty0", &svtp) != 0)
|
|
|
|
return 0;
|
|
|
|
vtPermSave[0] = (int)svtp.st_uid;
|
|
|
|
vtPermSave[1] = (int)svtp.st_gid;
|
|
|
|
|
|
|
|
/* Now check the console we are dealing with. */
|
|
|
|
if (stat(vtname, &svtp) != 0)
|
|
|
|
return 0;
|
|
|
|
vtPermSave[2] = (int)svtp.st_uid;
|
|
|
|
vtPermSave[3] = (int)svtp.st_gid;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
restoreVtPerms(void)
|
|
|
|
{
|
|
|
|
/* Set the terminal permissions back to before we started. */
|
|
|
|
chown("/dev/tty0", vtPermSave[0], vtPermSave[1]);
|
|
|
|
chown(vtname, vtPermSave[2], vtPermSave[3]);
|
|
|
|
}
|
|
|
|
|
2008-11-05 17:51:06 +01:00
|
|
|
static void *console_handler;
|
|
|
|
|
|
|
|
static void
|
|
|
|
drain_console(int fd, void *closure)
|
|
|
|
{
|
|
|
|
tcflush(fd, TCIOFLUSH);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:49:22 +01:00
|
|
|
xf86OpenConsole(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
int i, fd = -1;
|
2003-11-14 16:54:54 +01:00
|
|
|
struct vt_mode VT;
|
|
|
|
struct vt_stat vts;
|
2003-11-14 17:49:22 +01:00
|
|
|
MessageType from = X_PROBED;
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef USE_DEV_FB
|
|
|
|
struct fb_var_screeninfo var;
|
|
|
|
int fbfd;
|
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
|
|
|
|
char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
if (serverGeneration == 1) {
|
|
|
|
|
|
|
|
/* when KeepTty check if we're run with euid==0 */
|
|
|
|
if (KeepTty && geteuid() != 0)
|
|
|
|
FatalError("xf86OpenConsole:"
|
|
|
|
" Server must be suid root for option \"KeepTTY\"\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* setup the virtual terminal manager
|
|
|
|
*/
|
2003-11-14 17:49:22 +01:00
|
|
|
if (VTnum != -1) {
|
2003-11-14 16:54:54 +01:00
|
|
|
xf86Info.vtno = VTnum;
|
2003-11-14 17:49:22 +01:00
|
|
|
from = X_CMDLINE;
|
|
|
|
} else {
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
i=0;
|
2005-01-28 17:13:00 +01:00
|
|
|
while (tty0[i] != NULL) {
|
2003-11-14 17:49:22 +01:00
|
|
|
if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
if (fd < 0)
|
2003-11-14 16:54:54 +01:00
|
|
|
FatalError(
|
|
|
|
"xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
|
|
|
|
strerror(errno));
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (ShareVTs)
|
|
|
|
{
|
|
|
|
if (ioctl(fd, VT_GETSTATE, &vts) == 0)
|
|
|
|
xf86Info.vtno = vts.v_active;
|
|
|
|
else
|
|
|
|
FatalError("xf86OpenConsole: Cannot find the current"
|
|
|
|
" VT (%s)\n", strerror(errno));
|
|
|
|
} else {
|
|
|
|
if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
|
|
|
|
(xf86Info.vtno == -1))
|
|
|
|
FatalError("xf86OpenConsole: Cannot find a free VT: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_DEV_FB
|
2005-07-04 20:41:04 +02:00
|
|
|
if (!ShareVTs)
|
|
|
|
{
|
|
|
|
fb_dev_name=getenv("FRAMEBUFFER");
|
|
|
|
if (!fb_dev_name)
|
|
|
|
fb_dev_name="/dev/fb0current";
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
|
|
|
|
FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
|
|
|
|
fb_dev_name, strerror(errno));
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var) < 0)
|
|
|
|
FatalError("xf86OpenConsole: Unable to get screen info %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
if (!KeepTty) {
|
2005-01-28 17:13:00 +01:00
|
|
|
pid_t ppid = getppid();
|
|
|
|
pid_t ppgid;
|
|
|
|
ppgid = getpgid(ppid);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* change to parent process group that pgid != pid so
|
|
|
|
* that setsid() doesn't fail and we become process
|
|
|
|
* group leader
|
|
|
|
*/
|
|
|
|
if (setpgid(0,ppgid) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
|
|
|
|
/* become process group leader */
|
|
|
|
if ((setsid() < 0))
|
|
|
|
xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
|
|
|
|
strerror(errno));
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
i=0;
|
2005-01-28 17:13:00 +01:00
|
|
|
while (vcs[i] != NULL) {
|
2003-11-14 17:49:22 +01:00
|
|
|
sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
|
|
|
|
if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
if (xf86Info.consoleFd < 0)
|
|
|
|
FatalError("xf86OpenConsole: Cannot open virtual console"
|
|
|
|
" %d (%s)\n", xf86Info.vtno, strerror(errno));
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (!ShareVTs)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Grab the vt ownership before we overwrite it.
|
|
|
|
* Hard coded /dev/tty0 into this function as well for below.
|
|
|
|
*/
|
|
|
|
if (!saveVtPerms())
|
|
|
|
xf86Msg(X_WARNING,
|
|
|
|
"xf86OpenConsole: Could not save ownership of VT\n");
|
2005-01-14 19:42:26 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
/* change ownership of the vt */
|
|
|
|
if (chown(vtname, getuid(), getgid()) < 0)
|
|
|
|
xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n",
|
|
|
|
vtname, strerror(errno));
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
/*
|
|
|
|
* the current VT device we're running on is not "console", we want
|
|
|
|
* to grab all consoles too
|
|
|
|
*
|
|
|
|
* Why is this needed??
|
|
|
|
*/
|
|
|
|
if (chown("/dev/tty0", getuid(), getgid()) < 0)
|
|
|
|
xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Linux doesn't switch to an active vt after the last close of a vt,
|
|
|
|
* so we do this ourselves by remembering which is active now.
|
|
|
|
*/
|
2005-01-28 17:13:00 +01:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
|
|
|
|
xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
else
|
2003-11-14 16:54:54 +01:00
|
|
|
activeVT = vts.v_active;
|
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
#if 0
|
|
|
|
if (!KeepTty) {
|
2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* Detach from the controlling tty to avoid char loss
|
|
|
|
*/
|
2005-01-28 17:13:00 +01:00
|
|
|
if ((i = open("/dev/tty",O_RDWR)) >= 0) {
|
2003-11-14 16:54:54 +01:00
|
|
|
ioctl(i, TIOCNOTTY, 0);
|
|
|
|
close(i);
|
|
|
|
}
|
|
|
|
}
|
2005-01-28 17:13:00 +01:00
|
|
|
#endif
|
2005-07-04 20:41:04 +02:00
|
|
|
|
|
|
|
if (!ShareVTs)
|
|
|
|
{
|
2005-01-28 17:13:00 +01:00
|
|
|
#if defined(DO_OS_FONTRESTORE)
|
2005-07-04 20:41:04 +02:00
|
|
|
lnx_savefont();
|
2005-01-28 17:13:00 +01:00
|
|
|
#endif
|
2005-07-04 20:41:04 +02:00
|
|
|
/*
|
2007-04-10 01:04:56 +02:00
|
|
|
* now get the VT. This _must_ succeed, or else fail completely.
|
2005-07-04 20:41:04 +02:00
|
|
|
*/
|
|
|
|
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
|
2007-04-10 01:04:56 +02:00
|
|
|
FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n",
|
|
|
|
strerror(errno));
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
|
2007-04-10 01:04:56 +02:00
|
|
|
FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
|
|
|
|
strerror(errno));
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
|
|
|
|
FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
|
|
|
|
strerror(errno));
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
signal(SIGUSR1, xf86VTRequest);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
VT.mode = VT_PROCESS;
|
|
|
|
VT.relsig = SIGUSR1;
|
|
|
|
VT.acqsig = SIGUSR1;
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
|
|
|
|
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
|
|
|
|
strerror(errno));
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
|
|
|
|
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
|
|
|
|
strerror(errno));
|
2003-11-14 17:49:22 +01:00
|
|
|
|
xfree86: if AllowEmptyInput is true, enable RAW mode on the console.
Usually, the console is set to RAW in the kbd driver. If we hotplug all input
devices (i.e. the evdev driver for keyboards) and the console is left as-is.
As a result, the evdev driver must put an EVIOCGRAB on the device to avoid
characters leaking onto the console. This again breaks many things, amongst
them lirc, in-kernel mouse button emulation and HAL.
This patch sets the console to RAW if AllowEmptyInput is on.
Use-cases:
1. AEI is off
1.1. Only kbd driver is used - behaviour as-is.
1.2. kbd and evdev driver is used: if evdev does not grab the device,
duplicate events are generated.
2. AEI is on
2.1. Only evdev driver is used - behaviour as-is, but evdev does not need
to grab the device anymore.
2.2. evdev and kbd are used: duplicate key events are generated if evdev
does not grab the device.
1.2 is a marginal use-case that can be fixed by adding a "grab" option to the
evdev driver (update of xorg.conf is needed).
2.2 is an issue. If we have no ServerLayout section, AEI is on, but devices
specified in the xorg.conf are still added [1], resulting in duplicate events.
This is a common configuration and needs sorting out.
[1] 2eaed4a10fe5bf727579bca4ab8d4a47c8763a7d
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2008-10-12 13:28:30 +02:00
|
|
|
/* Set the keyboard to RAW mode. If we're using the keyboard
|
|
|
|
* driver, the driver does it for us. If we have AEI on, then
|
|
|
|
* we're expecting the devices to be added (i.e. evdev) and we
|
|
|
|
* have to set it manually.
|
|
|
|
*/
|
|
|
|
if (xf86Info.allowEmptyInput)
|
|
|
|
{
|
|
|
|
struct termios nTty;
|
|
|
|
|
|
|
|
tcgetattr(xf86Info.consoleFd, &tty_attr);
|
|
|
|
ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode);
|
|
|
|
|
|
|
|
if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0)
|
|
|
|
FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
|
|
|
|
nTty = tty_attr;
|
|
|
|
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
|
|
|
|
nTty.c_oflag = 0;
|
|
|
|
nTty.c_cflag = CREAD | CS8;
|
|
|
|
nTty.c_lflag = 0;
|
|
|
|
nTty.c_cc[VTIME]=0;
|
|
|
|
nTty.c_cc[VMIN]=1;
|
|
|
|
cfsetispeed(&nTty, 9600);
|
|
|
|
cfsetospeed(&nTty, 9600);
|
|
|
|
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
|
2008-11-05 17:51:06 +01:00
|
|
|
|
|
|
|
/* need to keep the buffer clean, else the kernel gets angry */
|
|
|
|
console_handler = xf86AddGeneralHandler(xf86Info.consoleFd,
|
|
|
|
drain_console, NULL);
|
xfree86: if AllowEmptyInput is true, enable RAW mode on the console.
Usually, the console is set to RAW in the kbd driver. If we hotplug all input
devices (i.e. the evdev driver for keyboards) and the console is left as-is.
As a result, the evdev driver must put an EVIOCGRAB on the device to avoid
characters leaking onto the console. This again breaks many things, amongst
them lirc, in-kernel mouse button emulation and HAL.
This patch sets the console to RAW if AllowEmptyInput is on.
Use-cases:
1. AEI is off
1.1. Only kbd driver is used - behaviour as-is.
1.2. kbd and evdev driver is used: if evdev does not grab the device,
duplicate events are generated.
2. AEI is on
2.1. Only evdev driver is used - behaviour as-is, but evdev does not need
to grab the device anymore.
2.2. evdev and kbd are used: duplicate key events are generated if evdev
does not grab the device.
1.2 is a marginal use-case that can be fixed by adding a "grab" option to the
evdev driver (update of xorg.conf is needed).
2.2 is an issue. If we have no ServerLayout section, AEI is on, but devices
specified in the xorg.conf are still added [1], resulting in duplicate events.
This is a common configuration and needs sorting out.
[1] 2eaed4a10fe5bf727579bca4ab8d4a47c8763a7d
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2008-10-12 13:28:30 +02:00
|
|
|
}
|
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
/* we really should have a InitOSInputDevices() function instead
|
|
|
|
* of Init?$#*&Device(). So I just place it here */
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef USE_DEV_FB
|
2005-07-04 20:41:04 +02:00
|
|
|
/* copy info to new console */
|
|
|
|
var.yoffset=0;
|
|
|
|
var.xoffset=0;
|
|
|
|
if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
|
|
|
|
FatalError("Unable to set screen info\n");
|
|
|
|
close(fbfd);
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2005-07-04 20:41:04 +02:00
|
|
|
} else { /* ShareVTs */
|
|
|
|
close(xf86Info.consoleFd);
|
|
|
|
}
|
2005-08-26 09:35:55 +02:00
|
|
|
signal(SIGUSR2, xf86ReloadInputDevs);
|
2005-01-28 17:13:00 +01:00
|
|
|
} else { /* serverGeneration != 1 */
|
2005-07-04 20:41:04 +02:00
|
|
|
if (!ShareVTs && VTSwitch)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* now get the VT
|
|
|
|
*/
|
|
|
|
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
}
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n",
|
|
|
|
strerror(errno));
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:49:22 +01:00
|
|
|
xf86CloseConsole()
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
struct vt_mode VT;
|
2005-01-14 19:42:26 +01:00
|
|
|
#if defined(DO_OS_FONTRESTORE)
|
|
|
|
struct vt_stat vts;
|
|
|
|
int vtno = -1;
|
2005-07-04 20:41:04 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ShareVTs) return;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2008-11-05 17:51:06 +01:00
|
|
|
if (console_handler) {
|
|
|
|
xf86RemoveGeneralHandler(console_handler);
|
|
|
|
console_handler = NULL;
|
|
|
|
};
|
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
#if defined(DO_OS_FONTRESTORE)
|
2005-01-28 17:13:00 +01:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETSTATE failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
else
|
2005-01-14 19:42:26 +01:00
|
|
|
vtno = vts.v_active;
|
|
|
|
#endif
|
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
/* Back to text mode ... */
|
|
|
|
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
|
|
|
|
strerror(errno));
|
xfree86: if AllowEmptyInput is true, enable RAW mode on the console.
Usually, the console is set to RAW in the kbd driver. If we hotplug all input
devices (i.e. the evdev driver for keyboards) and the console is left as-is.
As a result, the evdev driver must put an EVIOCGRAB on the device to avoid
characters leaking onto the console. This again breaks many things, amongst
them lirc, in-kernel mouse button emulation and HAL.
This patch sets the console to RAW if AllowEmptyInput is on.
Use-cases:
1. AEI is off
1.1. Only kbd driver is used - behaviour as-is.
1.2. kbd and evdev driver is used: if evdev does not grab the device,
duplicate events are generated.
2. AEI is on
2.1. Only evdev driver is used - behaviour as-is, but evdev does not need
to grab the device anymore.
2.2. evdev and kbd are used: duplicate key events are generated if evdev
does not grab the device.
1.2 is a marginal use-case that can be fixed by adding a "grab" option to the
evdev driver (update of xorg.conf is needed).
2.2 is an issue. If we have no ServerLayout section, AEI is on, but devices
specified in the xorg.conf are still added [1], resulting in duplicate events.
This is a common configuration and needs sorting out.
[1] 2eaed4a10fe5bf727579bca4ab8d4a47c8763a7d
Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2008-10-12 13:28:30 +02:00
|
|
|
|
|
|
|
ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
|
|
|
|
tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
|
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
else {
|
|
|
|
/* set dflt vt handling */
|
2003-11-14 16:54:54 +01:00
|
|
|
VT.mode = VT_AUTO;
|
2005-01-28 17:13:00 +01:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
|
|
|
|
strerror(errno));
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2005-01-14 19:42:26 +01:00
|
|
|
|
2005-07-04 20:41:04 +02:00
|
|
|
if (VTSwitch)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Perform a switch back to the active VT when we were started
|
|
|
|
*/
|
|
|
|
if (activeVT >= 0) {
|
|
|
|
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
|
|
|
|
xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
|
|
|
|
strerror(errno));
|
2007-04-10 01:04:56 +02:00
|
|
|
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0)
|
|
|
|
xf86Msg(X_WARNING,
|
|
|
|
"xf86CloseConsole: VT_WAITACTIVE failed: %s\n",
|
|
|
|
strerror(errno));
|
2005-07-04 20:41:04 +02:00
|
|
|
activeVT = -1;
|
|
|
|
}
|
2005-01-28 17:13:00 +01:00
|
|
|
|
2005-01-14 19:42:26 +01:00
|
|
|
#if defined(DO_OS_FONTRESTORE)
|
2005-07-04 20:41:04 +02:00
|
|
|
if (xf86Info.vtno == vtno) /* check if we are active */
|
|
|
|
lnx_restorefont();
|
|
|
|
lnx_freefontdata();
|
2005-01-14 19:42:26 +01:00
|
|
|
#endif
|
2005-07-04 20:41:04 +02:00
|
|
|
}
|
2005-01-28 17:13:00 +01:00
|
|
|
close(xf86Info.consoleFd); /* make the vt-manager happy */
|
2005-01-14 19:42:26 +01:00
|
|
|
|
|
|
|
restoreVtPerms(); /* restore the permissions */
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2003-11-14 17:49:22 +01:00
|
|
|
xf86ProcessArgument(int argc, char *argv[], int i)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
/*
|
2005-01-14 19:42:26 +01:00
|
|
|
* Keep server from detaching from controlling tty. This is useful
|
2003-11-14 16:54:54 +01:00
|
|
|
* when debugging (so the server can receive keyboard signals.
|
|
|
|
*/
|
|
|
|
if (!strcmp(argv[i], "-keeptty"))
|
|
|
|
{
|
|
|
|
KeepTty = TRUE;
|
|
|
|
return(1);
|
|
|
|
}
|
2005-07-04 20:41:04 +02:00
|
|
|
if (!strcmp(argv[i], "-novtswitch"))
|
|
|
|
{
|
|
|
|
VTSwitch = FALSE;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[i], "-sharevts"))
|
|
|
|
{
|
|
|
|
ShareVTs = TRUE;
|
|
|
|
return(1);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
|
|
|
|
{
|
|
|
|
if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
|
|
|
|
{
|
|
|
|
UseMsg();
|
|
|
|
VTnum = -1;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-14 17:49:22 +01:00
|
|
|
xf86UseMsg()
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ErrorF("vtXX use the specified VT number\n");
|
|
|
|
ErrorF("-keeptty ");
|
|
|
|
ErrorF("don't detach controlling tty (for debugging only)\n");
|
2005-07-04 20:41:04 +02:00
|
|
|
ErrorF("-novtswitch don't immediately switch to new VT\n");
|
|
|
|
ErrorF("-sharevts share VTs with another X server\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
return;
|
|
|
|
}
|