2 * Xephyr - A kdrive X server thats runs in a host X window.
3 * Authored by Matthew Allum <mallum@o-hand.com>
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.
27 #include <kdrive-config.h>
31 #include "glx_extinit.h"
33 extern Window EphyrPreExistingHostWin
;
34 extern Bool EphyrWantGrayScale
;
35 extern Bool EphyrWantResize
;
36 extern Bool kdHasPointer
;
40 extern Bool ephyrNoDRI
;
42 extern Bool ephyrNoXV
;
45 extern KdPointerDriver LinuxEvdevMouseDriver
;
46 extern KdKeyboardDriver LinuxEvdevKeyboardDriver
;
49 void processScreenArg(const char *screen_size
, char *parent_id
);
55 KdCardInfoAdd(&ephyrFuncs
, 0);
58 static const ExtensionModule ephyrExtensions
[] = {
60 { GlxExtensionInit
, "GLX", &noGlxExtension
},
65 void ephyrExtensionInit(void)
69 for (i
= 0; i
< ARRAY_SIZE(ephyrExtensions
); i
++)
70 LoadExtension(&ephyrExtensions
[i
], TRUE
);
75 InitOutput(ScreenInfo
* pScreenInfo
, int argc
, char **argv
)
77 if (serverGeneration
== 1)
80 KdInitOutput(pScreenInfo
, argc
, argv
);
84 InitInput(int argc
, char **argv
)
89 KdAddKeyboardDriver(&EphyrKeyboardDriver
);
91 KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver
);
93 KdAddPointerDriver(&EphyrMouseDriver
);
95 KdAddPointerDriver(&LinuxEvdevMouseDriver
);
101 FatalError("Couldn't create Xephyr keyboard\n");
102 ki
->driver
= &EphyrKeyboardDriver
;
109 FatalError("Couldn't create Xephyr pointer\n");
110 pi
->driver
= &EphyrMouseDriver
;
123 #ifdef DDXBEFORERESET
135 ErrorF("\nXephyr Option Usage:\n");
136 ErrorF("-parent <XID> Use existing window as Xephyr root win\n");
137 ErrorF("-sw-cursor Render cursors in software in Xephyr\n");
138 ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
139 ErrorF("-grayscale Simulate 8bit grayscale\n");
140 ErrorF("-resizeable Make Xephyr windows resizeable\n");
142 ("-fakexa Simulate acceleration using software rendering\n");
143 ErrorF("-verbosity <level> Set log verbosity level\n");
145 ErrorF("-nodri do not use DRI\n");
147 ErrorF("-noxv do not use XV\n");
148 ErrorF("-name [name] define the name in the WM_CLASS property\n");
150 ("-title [title] set the window title in the WM_NAME property\n");
157 processScreenArg(const char *screen_size
, char *parent_id
)
161 InitCard(0); /*Put each screen on a separate card */
162 card
= KdCardInfoLast();
165 KdScreenInfo
*screen
;
166 unsigned long p_id
= 0;
168 screen
= KdScreenInfoAdd(card
);
169 KdParseScreen(screen
, screen_size
);
170 screen
->driver
= calloc(1, sizeof(EphyrScrPriv
));
172 FatalError("Couldn't alloc screen private\n");
175 p_id
= strtol(parent_id
, NULL
, 0);
177 EPHYR_DBG("screen number:%d\n", screen
->mynum
);
178 hostx_add_screen(screen
, p_id
, screen
->mynum
);
181 ErrorF("No matching card found!\n");
186 ddxProcessArgument(int argc
, char **argv
, int i
)
188 static char *parent
= NULL
;
190 EPHYR_DBG("mark argv[%d]='%s'", i
, argv
[i
]);
193 hostx_use_resname(basename(argv
[0]), 0);
196 if (!strcmp(argv
[i
], "-parent")) {
200 /* If parent is specified and a screen argument follows, don't do
201 * anything, let the -screen handling init the rest */
202 for (j
= i
; j
< argc
; j
++) {
203 if (!strcmp(argv
[j
], "-screen")) {
204 parent
= argv
[i
+ 1];
209 processScreenArg("100x100", argv
[i
+ 1]);
216 else if (!strcmp(argv
[i
], "-screen")) {
217 if ((i
+ 1) < argc
) {
218 processScreenArg(argv
[i
+ 1], parent
);
226 else if (!strcmp(argv
[i
], "-sw-cursor")) {
227 hostx_use_sw_cursor();
230 else if (!strcmp(argv
[i
], "-host-cursor")) {
231 /* Compatibility with the old command line argument, now the default. */
234 else if (!strcmp(argv
[i
], "-fullscreen")) {
235 hostx_use_fullscreen();
238 else if (!strcmp(argv
[i
], "-grayscale")) {
239 EphyrWantGrayScale
= 1;
242 else if (!strcmp(argv
[i
], "-resizeable")) {
246 else if (!strcmp(argv
[i
], "-fakexa")) {
247 ephyrFuncs
.initAccel
= ephyrDrawInit
;
248 ephyrFuncs
.enableAccel
= ephyrDrawEnable
;
249 ephyrFuncs
.disableAccel
= ephyrDrawDisable
;
250 ephyrFuncs
.finiAccel
= ephyrDrawFini
;
253 else if (!strcmp(argv
[i
], "-verbosity")) {
254 if (i
+ 1 < argc
&& argv
[i
+ 1][0] != '-') {
255 int verbosity
= atoi(argv
[i
+ 1]);
257 LogSetParameter(XLOG_VERBOSITY
, verbosity
);
258 EPHYR_LOG("set verbosiry to %d\n", verbosity
);
267 else if (!strcmp(argv
[i
], "-nodri")) {
269 EPHYR_LOG("no direct rendering enabled\n");
273 else if (!strcmp(argv
[i
], "-noxv")) {
275 EPHYR_LOG("no XVideo enabled\n");
278 else if (!strcmp(argv
[i
], "-name")) {
279 if (i
+ 1 < argc
&& argv
[i
+ 1][0] != '-') {
280 hostx_use_resname(argv
[i
+ 1], 1);
288 else if (!strcmp(argv
[i
], "-title")) {
289 if (i
+ 1 < argc
&& argv
[i
+ 1][0] != '-') {
290 hostx_set_title(argv
[i
+ 1]);
298 else if (argv
[i
][0] == ':') {
299 hostx_set_display_name(argv
[i
]);
301 /* Xnest compatibility */
302 else if (!strcmp(argv
[i
], "-display")) {
303 hostx_set_display_name(argv
[i
+ 1]);
306 else if (!strcmp(argv
[i
], "-sync") ||
307 !strcmp(argv
[i
], "-full") ||
308 !strcmp(argv
[i
], "-sss") || !strcmp(argv
[i
], "-install")) {
311 else if (!strcmp(argv
[i
], "-bw") ||
312 !strcmp(argv
[i
], "-class") ||
313 !strcmp(argv
[i
], "-geometry") || !strcmp(argv
[i
], "-scrns")) {
316 /* end Xnest compat */
318 return KdProcessArgument(argc
, argv
, i
);
326 if (hostx_want_host_cursor()) {
327 ephyrFuncs
.initCursor
= &ephyrCursorInit
;
328 ephyrFuncs
.enableCursor
= &ephyrCursorEnable
;
331 KdOsInit(&EphyrOsFuncs
);
334 /* 'Fake' cursor stuff, could be improved */
337 ephyrRealizeCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, CursorPtr pCursor
)
343 ephyrUnrealizeCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, CursorPtr pCursor
)
349 ephyrSetCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, CursorPtr pCursor
, int x
,
356 ephyrMoveCursor(DeviceIntPtr pDev
, ScreenPtr pScreen
, int x
, int y
)
362 ephyrDeviceCursorInitialize(DeviceIntPtr pDev
, ScreenPtr pScreen
)
368 ephyrDeviceCursorCleanup(DeviceIntPtr pDev
, ScreenPtr pScreen
)
372 miPointerSpriteFuncRec EphyrPointerSpriteFuncs
= {
374 ephyrUnrealizeCursor
,
377 ephyrDeviceCursorInitialize
,
378 ephyrDeviceCursorCleanup
382 ephyrCursorInit(ScreenPtr pScreen
)
384 miPointerInitialize(pScreen
,
385 &EphyrPointerSpriteFuncs
,
386 &ephyrPointerScreenFuncs
, FALSE
);
392 ephyrCursorEnable(ScreenPtr pScreen
)
397 KdCardFuncs ephyrFuncs
= {
398 ephyrCardInit
, /* cardinit */
399 ephyrScreenInitialize
, /* scrinit */
400 ephyrInitScreen
, /* initScreen */
401 ephyrFinishInitScreen
, /* finishInitScreen */
402 ephyrCreateResources
, /* createRes */
403 ephyrPreserve
, /* preserve */
404 ephyrEnable
, /* enable */
405 ephyrDPMS
, /* dpms */
406 ephyrDisable
, /* disable */
407 ephyrRestore
, /* restore */
408 ephyrScreenFini
, /* scrfini */
409 ephyrCardFini
, /* cardfini */
412 0, /* enableCursor */
413 0, /* disableCursor */
415 0, /* recolorCursor */
419 0, /* disableAccel */
422 ephyrGetColors
, /* getColors */
423 ephyrPutColors
, /* putColors */