summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/solaris/sun_VTsw.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/os-support/solaris/sun_VTsw.c')
-rw-r--r--hw/xfree86/os-support/solaris/sun_VTsw.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/hw/xfree86/os-support/solaris/sun_VTsw.c b/hw/xfree86/os-support/solaris/sun_VTsw.c
new file mode 100644
index 000000000..0dc76b8b5
--- /dev/null
+++ b/hw/xfree86/os-support/solaris/sun_VTsw.c
@@ -0,0 +1,110 @@
1/*
2 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, and/or sell copies of the Software, and to permit persons
9 * to whom the Software is furnished to do so, provided that the above
10 * copyright notice(s) and this permission notice appear in all copies of
11 * the Software and that both the above copyright notice(s) and this
12 * permission notice appear in supporting documentation.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
17 * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18 * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
19 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
20 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 *
24 * Except as contained in this notice, the name of a copyright holder
25 * shall not be used in advertising or otherwise to promote the sale, use
26 * or other dealings in this Software without prior written authorization
27 * of the copyright holder.
28 */
29
30#ifdef HAVE_XORG_CONFIG_H
31#include <xorg-config.h>
32#endif
33
34#include <X11/X.h>
35
36#include "xf86.h"
37#include "xf86Priv.h"
38#include "xf86_OSlib.h"
39
40#include <door.h>
41#include <sys/vtdaemon.h>
42
43/*
44 * Handle the VT-switching interface for Solaris/OpenSolaris
45 */
46
47void
48xf86VTRequest(int sig)
49{
50 if (xf86Info.vtPendingNum != -1)
51 {
52 ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
53 xf86Info.vtPendingNum = -1;
54
55 return;
56 }
57
58 xf86Info.vtRequestsPending = TRUE;
59 return;
60}
61
62Bool
63xf86VTSwitchPending(void)
64{
65 return(xf86Info.vtRequestsPending ? TRUE : FALSE);
66}
67
68Bool
69xf86VTSwitchAway(void)
70{
71 int door_fd;
72 vt_cmd_arg_t vt_door_arg;
73 door_arg_t door_arg;
74
75 xf86Info.vtRequestsPending = FALSE;
76
77 vt_door_arg.vt_ev = VT_EV_HOTKEYS;
78 vt_door_arg.vt_num = xf86Info.vtPendingNum;
79 door_arg.data_ptr = (char *)&vt_door_arg;
80 door_arg.data_size = sizeof (vt_cmd_arg_t);
81 door_arg.rbuf = NULL;
82 door_arg.rsize = 0;
83 door_arg.desc_ptr = NULL;
84 door_arg.desc_num = 0;
85
86 if ((door_fd = open(VT_DAEMON_DOOR_FILE, O_RDONLY)) < 0)
87 return (FALSE);
88
89 if (door_call(door_fd, &door_arg) != 0) {
90 close(door_fd);
91 return (FALSE);
92 }
93
94 close(door_fd);
95 return (TRUE);
96}
97
98Bool
99xf86VTSwitchTo(void)
100{
101 xf86Info.vtRequestsPending = FALSE;
102 if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
103 {
104 return(FALSE);
105 }
106 else
107 {
108 return(TRUE);
109 }
110}