Args.c revision 706f2543
1/* 2 3Copyright 1993 by Davor Matic 4 5Permission to use, copy, modify, distribute, and sell this software 6and its documentation for any purpose is hereby granted without fee, 7provided that the above copyright notice appear in all copies and that 8both that copyright notice and this permission notice appear in 9supporting documentation. Davor Matic makes no representations about 10the suitability of this software for any purpose. It is provided "as 11is" without express or implied warranty. 12 13*/ 14 15#ifdef HAVE_XNEST_CONFIG_H 16#include <xnest-config.h> 17#endif 18 19#include <X11/X.h> 20#include <X11/Xproto.h> 21#include "screenint.h" 22#include "input.h" 23#include "misc.h" 24#include "scrnintstr.h" 25#include "servermd.h" 26 27#include "Xnest.h" 28 29#include "Display.h" 30#include "Args.h" 31 32char *xnestDisplayName = NULL; 33Bool xnestSynchronize = False; 34Bool xnestFullGeneration = False; 35int xnestDefaultClass; 36Bool xnestUserDefaultClass = False; 37int xnestDefaultDepth; 38Bool xnestUserDefaultDepth = False; 39Bool xnestSoftwareScreenSaver = False; 40int xnestX; 41int xnestY; 42unsigned int xnestWidth; 43unsigned int xnestHeight; 44int xnestUserGeometry = 0; 45int xnestBorderWidth; 46Bool xnestUserBorderWidth = False; 47char *xnestWindowName = NULL; 48int xnestNumScreens = 0; 49Bool xnestDoDirectColormaps = False; 50Window xnestParentWindow = 0; 51 52int 53ddxProcessArgument (int argc, char *argv[], int i) 54{ 55 if (!strcmp(argv[i], "-display")) { 56 if (++i < argc) { 57 xnestDisplayName = argv[i]; 58 return 2; 59 } 60 return 0; 61 } 62 if (!strcmp(argv[i], "-sync")) { 63 xnestSynchronize = True; 64 return 1; 65 } 66 if (!strcmp(argv[i], "-full")) { 67 xnestFullGeneration = True; 68 return 1; 69 } 70 if (!strcmp(argv[i], "-class")) { 71 if (++i < argc) { 72 if (!strcmp(argv[i], "StaticGray")) { 73 xnestDefaultClass = StaticGray; 74 xnestUserDefaultClass = True; 75 return 2; 76 } 77 else if (!strcmp(argv[i], "GrayScale")) { 78 xnestDefaultClass = GrayScale; 79 xnestUserDefaultClass = True; 80 return 2; 81 } 82 else if (!strcmp(argv[i], "StaticColor")) { 83 xnestDefaultClass = StaticColor; 84 xnestUserDefaultClass = True; 85 return 2; 86 } 87 else if (!strcmp(argv[i], "PseudoColor")) { 88 xnestDefaultClass = PseudoColor; 89 xnestUserDefaultClass = True; 90 return 2; 91 } 92 else if (!strcmp(argv[i], "TrueColor")) { 93 xnestDefaultClass = TrueColor; 94 xnestUserDefaultClass = True; 95 return 2; 96 } 97 else if (!strcmp(argv[i], "DirectColor")) { 98 xnestDefaultClass = DirectColor; 99 xnestUserDefaultClass = True; 100 return 2; 101 } 102 } 103 return 0; 104 } 105 if (!strcmp(argv[i], "-cc")) { 106 if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultClass) == 1) { 107 if (xnestDefaultClass >= 0 && xnestDefaultClass <= 5) { 108 xnestUserDefaultClass = True; 109 /* lex the OS layer process it as well, so return 0 */ 110 } 111 } 112 return 0; 113 } 114 if (!strcmp(argv[i], "-depth")) { 115 if (++i < argc && sscanf(argv[i], "%i", &xnestDefaultDepth) == 1) { 116 if (xnestDefaultDepth > 0) { 117 xnestUserDefaultDepth = True; 118 return 2; 119 } 120 } 121 return 0; 122 } 123 if (!strcmp(argv[i], "-sss")) { 124 xnestSoftwareScreenSaver = True; 125 return 1; 126 } 127 if (!strcmp(argv[i], "-geometry")) { 128 if (++i < argc) { 129 xnestUserGeometry = XParseGeometry(argv[i], 130 &xnestX, &xnestY, 131 &xnestWidth, &xnestHeight); 132 if (xnestUserGeometry) return 2; 133 } 134 return 0; 135 } 136 if (!strcmp(argv[i], "-bw")) { 137 if (++i < argc && sscanf(argv[i], "%i", &xnestBorderWidth) == 1) { 138 if (xnestBorderWidth >= 0) { 139 xnestUserBorderWidth = True; 140 return 2; 141 } 142 } 143 return 0; 144 } 145 if (!strcmp(argv[i], "-name")) { 146 if (++i < argc) { 147 xnestWindowName = argv[i]; 148 return 2; 149 } 150 return 0; 151 } 152 if (!strcmp(argv[i], "-scrns")) { 153 if (++i < argc && sscanf(argv[i], "%i", &xnestNumScreens) == 1) { 154 if (xnestNumScreens > 0) { 155 if (xnestNumScreens > MAXSCREENS) { 156 ErrorF("Maximum number of screens is %d.\n", MAXSCREENS); 157 xnestNumScreens = MAXSCREENS; 158 } 159 return 2; 160 } 161 } 162 return 0; 163 } 164 if (!strcmp(argv[i], "-install")) { 165 xnestDoDirectColormaps = True; 166 return 1; 167 } 168 if (!strcmp(argv[i], "-parent")) { 169 if (++i < argc) { 170 xnestParentWindow = (XID) strtol (argv[i], (char**)NULL, 0); 171 return 2; 172 } 173 } 174 return 0; 175} 176 177void ddxUseMsg(void) 178{ 179 ErrorF("-display string display name of the real server\n"); 180 ErrorF("-sync sinchronize with the real server\n"); 181 ErrorF("-full utilize full regeneration\n"); 182 ErrorF("-class string default visual class\n"); 183 ErrorF("-depth int default depth\n"); 184 ErrorF("-sss use software screen saver\n"); 185 ErrorF("-geometry WxH+X+Y window size and position\n"); 186 ErrorF("-bw int window border width\n"); 187 ErrorF("-name string window name\n"); 188 ErrorF("-scrns int number of screens to generate\n"); 189 ErrorF("-install instal colormaps directly\n"); 190} 191