ephyrinit.c revision 05b261ec
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 6 * 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. 16 * 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. 24 */ 25 26#ifdef HAVE_CONFIG_H 27#include <kdrive-config.h> 28#endif 29#include "ephyr.h" 30 31extern Window EphyrPreExistingHostWin; 32extern Bool EphyrWantGrayScale; 33extern Bool kdHasPointer; 34extern Bool kdHasKbd; 35 36void 37InitCard (char *name) 38{ 39 KdCardAttr attr; 40 41 EPHYR_DBG("mark"); 42 43 44 KdCardInfoAdd (&ephyrFuncs, &attr, 0); 45} 46 47void 48InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv) 49{ 50#ifdef GLXEXT 51 noGlxExtension=TRUE; 52#endif 53 KdInitOutput (pScreenInfo, argc, argv); 54} 55 56void 57InitInput (int argc, char **argv) 58{ 59 KdKeyboardInfo *ki; 60 KdPointerInfo *pi; 61 62 KdAddKeyboardDriver(&EphyrKeyboardDriver); 63#ifdef linux 64 KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver); 65#endif 66 KdAddPointerDriver(&EphyrMouseDriver); 67#ifdef linux 68 KdAddPointerDriver(&LinuxEvdevMouseDriver); 69#endif 70 71 if (!kdHasKbd) { 72 ki = KdNewKeyboard(); 73 if (!ki) 74 FatalError("Couldn't create Xephyr keyboard\n"); 75 ki->driver = &EphyrKeyboardDriver; 76 KdAddKeyboard(ki); 77 } 78 79 if (!kdHasPointer) { 80 pi = KdNewPointer(); 81 if (!pi) 82 FatalError("Couldn't create Xephyr pointer\n"); 83 pi->driver = &EphyrMouseDriver; 84 KdAddPointer(pi); 85 } 86 87 KdInitInput(); 88} 89 90void 91ddxUseMsg (void) 92{ 93 KdUseMsg(); 94 95 ErrorF("\nXephyr Option Usage:\n"); 96 ErrorF("-parent XID Use existing window as Xephyr root win\n"); 97 ErrorF("-host-cursor Re-use exisiting X host server cursor\n"); 98 ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n"); 99 ErrorF("-grayscale Simulate 8bit grayscale\n"); 100 ErrorF("-fakexa Simulate acceleration using software rendering\n"); 101 ErrorF("\n"); 102 103 exit(1); 104} 105 106int 107ddxProcessArgument (int argc, char **argv, int i) 108{ 109 EPHYR_DBG("mark"); 110 111 if (!strcmp (argv[i], "-parent")) 112 { 113 if(i+1 < argc) 114 { 115 hostx_use_preexisting_window(strtol(argv[i+1], NULL, 0)); 116 return 2; 117 } 118 119 UseMsg(); 120 exit(1); 121 } 122 else if (!strcmp (argv[i], "-host-cursor")) 123 { 124 hostx_use_host_cursor(); 125 return 1; 126 } 127 else if (!strcmp (argv[i], "-fullscreen")) 128 { 129 hostx_use_fullscreen(); 130 return 1; 131 } 132 else if (!strcmp (argv[i], "-grayscale")) 133 { 134 EphyrWantGrayScale = 1; 135 return 1; 136 } 137 else if (!strcmp (argv[i], "-fakexa")) 138 { 139 ephyrFuncs.initAccel = ephyrDrawInit; 140 ephyrFuncs.enableAccel = ephyrDrawEnable; 141 ephyrFuncs.disableAccel = ephyrDrawDisable; 142 ephyrFuncs.finiAccel = ephyrDrawFini; 143 return 1; 144 } 145 else if (argv[i][0] == ':') 146 { 147 hostx_set_display_name(argv[i]); 148 } 149 150 return KdProcessArgument (argc, argv, i); 151} 152 153void 154OsVendorInit (void) 155{ 156 EPHYR_DBG("mark"); 157 158 if (hostx_want_host_cursor()) 159 { 160 ephyrFuncs.initCursor = &ephyrCursorInit; 161 ephyrFuncs.enableCursor = &ephyrCursorEnable; 162 } 163 164 KdOsInit (&EphyrOsFuncs); 165} 166 167/* 'Fake' cursor stuff, could be improved */ 168 169static Bool 170ephyrRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) 171{ 172 return TRUE; 173} 174 175static Bool 176ephyrUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) 177{ 178 return TRUE; 179} 180 181static void 182ephyrSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y) 183{ 184 ; 185} 186 187static void 188ephyrMoveCursor(ScreenPtr pScreen, int x, int y) 189{ 190 ; 191} 192 193miPointerSpriteFuncRec EphyrPointerSpriteFuncs = { 194 ephyrRealizeCursor, 195 ephyrUnrealizeCursor, 196 ephyrSetCursor, 197 ephyrMoveCursor, 198}; 199 200 201Bool 202ephyrCursorInit(ScreenPtr pScreen) 203{ 204 miPointerInitialize(pScreen, &EphyrPointerSpriteFuncs, 205 &kdPointerScreenFuncs, FALSE); 206 207 return TRUE; 208} 209 210void 211ephyrCursorEnable(ScreenPtr pScreen) 212{ 213 ; 214} 215 216KdCardFuncs ephyrFuncs = { 217 ephyrCardInit, /* cardinit */ 218 ephyrScreenInit, /* scrinit */ 219 ephyrInitScreen, /* initScreen */ 220 ephyrFinishInitScreen, /* finishInitScreen */ 221 ephyrCreateResources, /* createRes */ 222 ephyrPreserve, /* preserve */ 223 ephyrEnable, /* enable */ 224 ephyrDPMS, /* dpms */ 225 ephyrDisable, /* disable */ 226 ephyrRestore, /* restore */ 227 ephyrScreenFini, /* scrfini */ 228 ephyrCardFini, /* cardfini */ 229 230 0, /* initCursor */ 231 0, /* enableCursor */ 232 0, /* disableCursor */ 233 0, /* finiCursor */ 234 0, /* recolorCursor */ 235 236 0, /* initAccel */ 237 0, /* enableAccel */ 238 0, /* disableAccel */ 239 0, /* finiAccel */ 240 241 ephyrGetColors, /* getColors */ 242 ephyrPutColors, /* putColors */ 243}; 244