First import
[xorg_rtime.git] / xorg-server-1.4 / hw / kdrive / ephyr / ephyrinit.c
bloba76da03b4e3be38a423c2a98cd9d3c4c0a96c787
1 /*
2 * Xephyr - A kdrive X server thats runs in a host X window.
3 * Authored by Matthew Allum <mallum@o-hand.com>
4 *
5 * Copyright © 2004 Nokia
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of Nokia not be used in
12 * advertising or publicity pertaining to distribution of the software without
13 * specific, written prior permission. Nokia makes no
14 * representations about the suitability of this software for any purpose. It
15 * is provided "as is" without express or implied warranty.
17 * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19 * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23 * PERFORMANCE OF THIS SOFTWARE.
26 #ifdef HAVE_CONFIG_H
27 #include <kdrive-config.h>
28 #endif
29 #include "ephyr.h"
31 extern Window EphyrPreExistingHostWin;
32 extern Bool EphyrWantGrayScale;
33 extern Bool kdHasPointer;
34 extern Bool kdHasKbd;
36 void
37 InitCard (char *name)
39 KdCardAttr attr;
41 EPHYR_DBG("mark");
44 KdCardInfoAdd (&ephyrFuncs, &attr, 0);
47 void
48 InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
50 KdInitOutput (pScreenInfo, argc, argv);
53 void
54 InitInput (int argc, char **argv)
56 KdKeyboardInfo *ki;
57 KdPointerInfo *pi;
59 KdAddKeyboardDriver(&EphyrKeyboardDriver);
60 #ifdef linux
61 KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
62 #endif
63 KdAddPointerDriver(&EphyrMouseDriver);
64 #ifdef linux
65 KdAddPointerDriver(&LinuxEvdevMouseDriver);
66 #endif
68 if (!kdHasKbd) {
69 ki = KdNewKeyboard();
70 if (!ki)
71 FatalError("Couldn't create Xephyr keyboard\n");
72 ki->driver = &EphyrKeyboardDriver;
73 KdAddKeyboard(ki);
76 if (!kdHasPointer) {
77 pi = KdNewPointer();
78 if (!pi)
79 FatalError("Couldn't create Xephyr pointer\n");
80 pi->driver = &EphyrMouseDriver;
81 KdAddPointer(pi);
84 KdInitInput();
87 void
88 ddxUseMsg (void)
90 KdUseMsg();
92 ErrorF("\nXephyr Option Usage:\n");
93 ErrorF("-parent XID Use existing window as Xephyr root win\n");
94 ErrorF("-host-cursor Re-use exisiting X host server cursor\n");
95 ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
96 ErrorF("-grayscale Simulate 8bit grayscale\n");
97 ErrorF("-fakexa Simulate acceleration using software rendering\n");
98 ErrorF("\n");
100 exit(1);
104 ddxProcessArgument (int argc, char **argv, int i)
106 EPHYR_DBG("mark");
108 if (!strcmp (argv[i], "-parent"))
110 if(i+1 < argc)
112 hostx_use_preexisting_window(strtol(argv[i+1], NULL, 0));
113 return 2;
116 UseMsg();
117 exit(1);
119 else if (!strcmp (argv[i], "-host-cursor"))
121 hostx_use_host_cursor();
122 return 1;
124 else if (!strcmp (argv[i], "-fullscreen"))
126 hostx_use_fullscreen();
127 return 1;
129 else if (!strcmp (argv[i], "-grayscale"))
131 EphyrWantGrayScale = 1;
132 return 1;
134 else if (!strcmp (argv[i], "-fakexa"))
136 ephyrFuncs.initAccel = ephyrDrawInit;
137 ephyrFuncs.enableAccel = ephyrDrawEnable;
138 ephyrFuncs.disableAccel = ephyrDrawDisable;
139 ephyrFuncs.finiAccel = ephyrDrawFini;
140 return 1;
142 else if (argv[i][0] == ':')
144 hostx_set_display_name(argv[i]);
147 return KdProcessArgument (argc, argv, i);
150 void
151 OsVendorInit (void)
153 EPHYR_DBG("mark");
155 if (hostx_want_host_cursor())
157 ephyrFuncs.initCursor = &ephyrCursorInit;
158 ephyrFuncs.enableCursor = &ephyrCursorEnable;
161 KdOsInit (&EphyrOsFuncs);
164 /* 'Fake' cursor stuff, could be improved */
166 static Bool
167 ephyrRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
169 return TRUE;
172 static Bool
173 ephyrUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
175 return TRUE;
178 static void
179 ephyrSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
184 static void
185 ephyrMoveCursor(ScreenPtr pScreen, int x, int y)
190 miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
191 ephyrRealizeCursor,
192 ephyrUnrealizeCursor,
193 ephyrSetCursor,
194 ephyrMoveCursor,
198 Bool
199 ephyrCursorInit(ScreenPtr pScreen)
201 miPointerInitialize(pScreen, &EphyrPointerSpriteFuncs,
202 &kdPointerScreenFuncs, FALSE);
204 return TRUE;
207 void
208 ephyrCursorEnable(ScreenPtr pScreen)
213 KdCardFuncs ephyrFuncs = {
214 ephyrCardInit, /* cardinit */
215 ephyrScreenInit, /* scrinit */
216 ephyrInitScreen, /* initScreen */
217 ephyrFinishInitScreen, /* finishInitScreen */
218 ephyrCreateResources, /* createRes */
219 ephyrPreserve, /* preserve */
220 ephyrEnable, /* enable */
221 ephyrDPMS, /* dpms */
222 ephyrDisable, /* disable */
223 ephyrRestore, /* restore */
224 ephyrScreenFini, /* scrfini */
225 ephyrCardFini, /* cardfini */
227 0, /* initCursor */
228 0, /* enableCursor */
229 0, /* disableCursor */
230 0, /* finiCursor */
231 0, /* recolorCursor */
233 0, /* initAccel */
234 0, /* enableAccel */
235 0, /* disableAccel */
236 0, /* finiAccel */
238 ephyrGetColors, /* getColors */
239 ephyrPutColors, /* putColors */