コード例 #1
0
void
xf86CloseConsole(void)
{
    struct vt_mode   VT;

    if (ShareVTs) {
        close(xf86Info.consoleFd);
        return;
    }

    if (console_handler) {
	xf86RemoveGeneralHandler(console_handler);
	console_handler = NULL;
    };

    /* Back to text mode ... */
    if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
	xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
		strerror(errno));

    ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
    tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);

    if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) 
	xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
		strerror(errno));
    else {
	/* set dflt vt handling */
	VT.mode = VT_AUTO;
	if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) 
	    xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
		    strerror(errno));
    }

    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));
	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0)
		xf86Msg(X_WARNING,
			"xf86CloseConsole: VT_WAITACTIVE failed: %s\n",
			strerror(errno));
	    activeVT = -1;
        }
    }
    close(xf86Info.consoleFd);	/* make the vt-manager happy */

    restoreVtPerms();		/* restore the permissions */
}
コード例 #2
0
static void
lnxCloseAPM(void)
{
    int fd;

    DebugF("APM: Closing device\n");
    if (APMihPtr) {
        fd = xf86RemoveGeneralHandler(APMihPtr);
        close(fd);
        APMihPtr = NULL;
    }
}
コード例 #3
0
ファイル: xf86Events.c プロジェクト: 4eremuxa/xserver
/**
 * Set the handler for the console's fd. Replaces (and returns) the previous
 * handler or NULL, whichever appropriate.
 * proc may be NULL if the server should not handle events on the console.
 */
InputHandlerProc
xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
{
    static IHPtr handler = NULL;
    IHPtr old_handler = handler;

    if (old_handler)
        xf86RemoveGeneralHandler(old_handler);

    handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);

    return (old_handler) ? old_handler->ihproc : NULL;
}
コード例 #4
0
static void
bsdCloseAPM(void)
{
    int kq;

    if (APMihPtr) {
        kq = xf86RemoveGeneralHandler(APMihPtr);
        close(devFd);
        devFd = -1;
        close(kq);
        if (ctlFd >= 0) {
            close(ctlFd);
            ctlFd = -1;
        }
        APMihPtr = NULL;
    }
}