First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / os-support / usl / usl_vtsw.c
blob812e5bddbe5f911d20321fbd7bc1ffc187ebc3af
1 /*
2 * Copyright 2005 by Kean Johnston <jkj@sco.com>
3 * Copyright 1993 by David Wexelblat <dwex@goblin.org>
4 * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of David Wexelblat not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. David Wexelblat makes no representations
13 * about the suitability of this software for any purpose. It is provided
14 * "as is" without express or implied warranty.
16 * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
26 #include "X.h"
28 #include "xf86.h"
29 #include "xf86Priv.h"
30 #include "xf86_OSlib.h"
33 * Handle the VT-switching interface for SCO UnixWare / OpenServer 6
37 * This function is the signal handler for the VT-switching signal. It
38 * is only referenced inside the OS-support layer. NOTE: we do NOT need
39 * to re-arm the signal here, since we used sigaction() to set the signal
40 * disposition in usl_init.c. If we had used signal(), we would need to
41 * re-arm the signal here. All we need to do now is record the fact that
42 * we got the signal. XFree86 handles the rest.
44 void
45 xf86VTRequest(int sig)
47 xf86Info.vtRequestsPending = TRUE;
48 return;
51 Bool
52 xf86VTSwitchPending(void)
54 return(xf86Info.vtRequestsPending ? TRUE : FALSE);
57 static int usl_ledstatus = -1;
58 static unsigned int usl_ledstate = 0;
60 Bool
61 xf86VTSwitchAway(void)
63 usl_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &usl_ledstate);
65 xf86Info.vtRequestsPending = FALSE;
66 if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) {
67 return(FALSE);
68 } else {
69 return(TRUE);
73 Bool
74 xf86VTSwitchTo(void)
76 xf86Info.vtRequestsPending = FALSE;
77 if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
78 return(FALSE);
79 } else {
80 if (usl_ledstatus >= 0) {
81 ioctl (xf86Info.consoleFd, KDSETLED, usl_ledstate);
83 usl_ledstatus = -1;
86 * Convince the console driver this screen is in graphics mode,
87 * otherwise it assumes it can do more to the screen than it should.
89 if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
90 ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
93 return TRUE;