| 1 | /* |
| 2 | |
| 3 | Copyright 1993, 1998 The Open Group |
| 4 | Copyright (C) Colin Harrison 2005-2008 |
| 5 | |
| 6 | Permission to use, copy, modify, distribute, and sell this software and its |
| 7 | documentation for any purpose is hereby granted without fee, provided that |
| 8 | the above copyright notice appear in all copies and that both that |
| 9 | copyright notice and this permission notice appear in supporting |
| 10 | documentation. |
| 11 | |
| 12 | The above copyright notice and this permission notice shall be included |
| 13 | in all copies or substantial portions of the Software. |
| 14 | |
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 | IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 19 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 20 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 21 | OTHER DEALINGS IN THE SOFTWARE. |
| 22 | |
| 23 | Except as contained in this notice, the name of The Open Group shall |
| 24 | not be used in advertising or otherwise to promote the sale, use or |
| 25 | other dealings in this Software without prior written authorization |
| 26 | from The Open Group. |
| 27 | |
| 28 | */ |
| 29 | |
| 30 | #ifdef HAVE_XWIN_CONFIG_H |
| 31 | #include <xwin-config.h> |
| 32 | #endif |
| 33 | |
| 34 | #include <../xfree86/common/xorgVersion.h> |
| 35 | #include "win.h" |
| 36 | #include "winconfig.h" |
| 37 | #include "winmsg.h" |
| 38 | #include "winmonitors.h" |
| 39 | |
| 40 | /* |
| 41 | * References to external symbols |
| 42 | */ |
| 43 | |
| 44 | #ifdef XWIN_CLIPBOARD |
| 45 | extern Bool g_fUnicodeClipboard; |
| 46 | extern Bool g_fClipboard; |
| 47 | #endif |
| 48 | |
| 49 | /* |
| 50 | * Function prototypes |
| 51 | */ |
| 52 | |
| 53 | void |
| 54 | winLogCommandLine(int argc, char *argv[]); |
| 55 | |
| 56 | void |
| 57 | winLogVersionInfo(void); |
| 58 | |
| 59 | /* |
| 60 | * Process arguments on the command line |
| 61 | */ |
| 62 | |
| 63 | static int iLastScreen = -1; |
| 64 | static winScreenInfo defaultScreenInfo; |
| 65 | |
| 66 | static void |
| 67 | winInitializeScreenDefaults(void) |
| 68 | { |
| 69 | DWORD dwWidth, dwHeight; |
| 70 | static Bool fInitializedScreenDefaults = FALSE; |
| 71 | |
| 72 | /* Bail out early if default screen has already been initialized */ |
| 73 | if (fInitializedScreenDefaults) |
| 74 | return; |
| 75 | |
| 76 | /* Zero the memory used for storing the screen info */ |
| 77 | memset(&defaultScreenInfo, 0, sizeof(winScreenInfo)); |
| 78 | |
| 79 | /* Get default width and height */ |
| 80 | /* |
| 81 | * NOTE: These defaults will cause the window to cover only |
| 82 | * the primary monitor in the case that we have multiple monitors. |
| 83 | */ |
| 84 | dwWidth = GetSystemMetrics(SM_CXSCREEN); |
| 85 | dwHeight = GetSystemMetrics(SM_CYSCREEN); |
| 86 | |
| 87 | winErrorFVerb(2, |
| 88 | "winInitializeScreenDefaults - primary monitor w %d h %d\n", |
| 89 | (int) dwWidth, (int) dwHeight); |
| 90 | |
| 91 | /* Set a default DPI, if no '-dpi' option was used */ |
| 92 | if (monitorResolution == 0) { |
| 93 | HDC hdc = GetDC(NULL); |
| 94 | |
| 95 | if (hdc) { |
| 96 | int dpiX = GetDeviceCaps(hdc, LOGPIXELSX); |
| 97 | int dpiY = GetDeviceCaps(hdc, LOGPIXELSY); |
| 98 | |
| 99 | winErrorFVerb(2, |
| 100 | "winInitializeScreenDefaults - native DPI x %d y %d\n", |
| 101 | dpiX, dpiY); |
| 102 | |
| 103 | monitorResolution = dpiY; |
| 104 | ReleaseDC(NULL, hdc); |
| 105 | } |
| 106 | else { |
| 107 | winErrorFVerb(1, |
| 108 | "winInitializeScreenDefaults - Failed to retrieve native DPI, falling back to default of %d DPI\n", |
| 109 | WIN_DEFAULT_DPI); |
| 110 | monitorResolution = WIN_DEFAULT_DPI; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | defaultScreenInfo.iMonitor = 1; |
| 115 | defaultScreenInfo.hMonitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY); |
| 116 | defaultScreenInfo.dwWidth = dwWidth; |
| 117 | defaultScreenInfo.dwHeight = dwHeight; |
| 118 | defaultScreenInfo.dwUserWidth = dwWidth; |
| 119 | defaultScreenInfo.dwUserHeight = dwHeight; |
| 120 | defaultScreenInfo.fUserGaveHeightAndWidth = |
| 121 | WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH; |
| 122 | defaultScreenInfo.fUserGavePosition = FALSE; |
| 123 | defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP; |
| 124 | defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES; |
| 125 | #ifdef XWIN_EMULATEPSEUDO |
| 126 | defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; |
| 127 | #endif |
| 128 | defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH; |
| 129 | defaultScreenInfo.pfb = NULL; |
| 130 | defaultScreenInfo.fFullScreen = FALSE; |
| 131 | defaultScreenInfo.fDecoration = TRUE; |
| 132 | #ifdef XWIN_MULTIWINDOWEXTWM |
| 133 | defaultScreenInfo.fMWExtWM = FALSE; |
| 134 | defaultScreenInfo.fInternalWM = FALSE; |
| 135 | #endif |
| 136 | defaultScreenInfo.fRootless = FALSE; |
| 137 | #ifdef XWIN_MULTIWINDOW |
| 138 | defaultScreenInfo.fMultiWindow = FALSE; |
| 139 | #endif |
| 140 | #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) |
| 141 | defaultScreenInfo.fMultiMonitorOverride = FALSE; |
| 142 | #endif |
| 143 | defaultScreenInfo.fMultipleMonitors = FALSE; |
| 144 | defaultScreenInfo.fLessPointer = FALSE; |
| 145 | defaultScreenInfo.iResizeMode = resizeWithRandr; |
| 146 | defaultScreenInfo.fNoTrayIcon = FALSE; |
| 147 | defaultScreenInfo.iE3BTimeout = WIN_E3B_DEFAULT; |
| 148 | defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL; |
| 149 | defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL; |
| 150 | defaultScreenInfo.fIgnoreInput = FALSE; |
| 151 | defaultScreenInfo.fExplicitScreen = FALSE; |
| 152 | |
| 153 | /* Note that the default screen has been initialized */ |
| 154 | fInitializedScreenDefaults = TRUE; |
| 155 | } |
| 156 | |
| 157 | static void |
| 158 | winInitializeScreen(int i) |
| 159 | { |
| 160 | winErrorFVerb(3, "winInitializeScreen - %d\n", i); |
| 161 | |
| 162 | /* Initialize default screen values, if needed */ |
| 163 | winInitializeScreenDefaults(); |
| 164 | |
| 165 | /* Copy the default screen info */ |
| 166 | g_ScreenInfo[i] = defaultScreenInfo; |
| 167 | |
| 168 | /* Set the screen number */ |
| 169 | g_ScreenInfo[i].dwScreen = i; |
| 170 | } |
| 171 | |
| 172 | void |
| 173 | winInitializeScreens(int maxscreens) |
| 174 | { |
| 175 | int i; |
| 176 | |
| 177 | winErrorFVerb(3, "winInitializeScreens - %i\n", maxscreens); |
| 178 | |
| 179 | if (maxscreens > g_iNumScreens) { |
| 180 | /* Reallocate the memory for DDX-specific screen info */ |
| 181 | g_ScreenInfo = |
| 182 | realloc(g_ScreenInfo, maxscreens * sizeof(winScreenInfo)); |
| 183 | |
| 184 | /* Set default values for any new screens */ |
| 185 | for (i = g_iNumScreens; i < maxscreens; i++) |
| 186 | winInitializeScreen(i); |
| 187 | |
| 188 | /* Keep a count of the number of screens */ |
| 189 | g_iNumScreens = maxscreens; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | /* See Porting Layer Definition - p. 57 */ |
| 194 | /* |
| 195 | * INPUT |
| 196 | * argv: pointer to an array of null-terminated strings, one for |
| 197 | * each token in the X Server command line; the first token |
| 198 | * is 'XWin.exe', or similar. |
| 199 | * argc: a count of the number of tokens stored in argv. |
| 200 | * i: a zero-based index into argv indicating the current token being |
| 201 | * processed. |
| 202 | * |
| 203 | * OUTPUT |
| 204 | * return: return the number of tokens processed correctly. |
| 205 | * |
| 206 | * NOTE |
| 207 | * When looking for n tokens, check that i + n is less than argc. Or, |
| 208 | * you may check if i is greater than or equal to argc, in which case |
| 209 | * you should display the UseMsg () and return 0. |
| 210 | */ |
| 211 | |
| 212 | /* Check if enough arguments are given for the option */ |
| 213 | #define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; } |
| 214 | |
| 215 | /* Compare the current option with the string. */ |
| 216 | #define IS_OPTION(name) (strcmp (argv[i], name) == 0) |
| 217 | |
| 218 | int |
| 219 | ddxProcessArgument(int argc, char *argv[], int i) |
| 220 | { |
| 221 | static Bool s_fBeenHere = FALSE; |
| 222 | winScreenInfo *screenInfoPtr = NULL; |
| 223 | |
| 224 | /* Initialize once */ |
| 225 | if (!s_fBeenHere) { |
| 226 | #ifdef DDXOSVERRORF |
| 227 | /* |
| 228 | * This initialises our hook into VErrorF () for catching log messages |
| 229 | * that are generated before OsInit () is called. |
| 230 | */ |
| 231 | OsVendorVErrorFProc = OsVendorVErrorF; |
| 232 | #endif |
| 233 | |
| 234 | s_fBeenHere = TRUE; |
| 235 | |
| 236 | /* Initialize only if option is not -help */ |
| 237 | if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") && |
| 238 | !IS_OPTION("-version") && !IS_OPTION("--version")) { |
| 239 | |
| 240 | /* Log the version information */ |
| 241 | winLogVersionInfo(); |
| 242 | |
| 243 | /* Log the command line */ |
| 244 | winLogCommandLine(argc, argv); |
| 245 | |
| 246 | /* |
| 247 | * Initialize default screen settings. We have to do this before |
| 248 | * OsVendorInit () gets called, otherwise we will overwrite |
| 249 | * settings changed by parameters such as -fullscreen, etc. |
| 250 | */ |
| 251 | winErrorFVerb(2, "ddxProcessArgument - Initializing default " |
| 252 | "screens\n"); |
| 253 | winInitializeScreenDefaults(); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | #if CYGDEBUG |
| 258 | winDebug("ddxProcessArgument - arg: %s\n", argv[i]); |
| 259 | #endif |
| 260 | |
| 261 | /* |
| 262 | * Look for the '-help' and similar options |
| 263 | */ |
| 264 | if (IS_OPTION("-help") || IS_OPTION("-h") || IS_OPTION("--help")) { |
| 265 | /* Reset logfile. We don't need that helpmessage in the logfile */ |
| 266 | g_pszLogFile = NULL; |
| 267 | g_fNoHelpMessageBox = TRUE; |
| 268 | UseMsg(); |
| 269 | exit(0); |
| 270 | return 1; |
| 271 | } |
| 272 | |
| 273 | if (IS_OPTION("-version") || IS_OPTION("--version")) { |
| 274 | /* Reset logfile. We don't need that versioninfo in the logfile */ |
| 275 | g_pszLogFile = NULL; |
| 276 | winLogVersionInfo(); |
| 277 | exit(0); |
| 278 | return 1; |
| 279 | } |
| 280 | |
| 281 | /* |
| 282 | * Look for the '-screen scr_num [width height]' argument |
| 283 | */ |
| 284 | if (IS_OPTION("-screen")) { |
| 285 | int iArgsProcessed = 1; |
| 286 | int nScreenNum; |
| 287 | int iWidth, iHeight, iX, iY; |
| 288 | int iMonitor; |
| 289 | |
| 290 | #if CYGDEBUG |
| 291 | winDebug("ddxProcessArgument - screen - argc: %d i: %d\n", argc, i); |
| 292 | #endif |
| 293 | |
| 294 | /* Display the usage message if the argument is malformed */ |
| 295 | if (i + 1 >= argc) { |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | /* Grab screen number */ |
| 300 | nScreenNum = atoi(argv[i + 1]); |
| 301 | |
| 302 | /* Validate the specified screen number */ |
| 303 | if (nScreenNum < 0) { |
| 304 | ErrorF("ddxProcessArgument - screen - Invalid screen number %d\n", |
| 305 | nScreenNum); |
| 306 | UseMsg(); |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | /* |
| 311 | Initialize default values for any new screens |
| 312 | |
| 313 | Note that default values can't change after a -screen option is |
| 314 | seen, so it's safe to do this for each screen as it is introduced |
| 315 | */ |
| 316 | winInitializeScreens(nScreenNum + 1); |
| 317 | |
| 318 | /* look for @m where m is monitor number */ |
| 319 | if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) { |
| 320 | struct GetMonitorInfoData data; |
| 321 | |
| 322 | if (!QueryMonitor(iMonitor, &data)) { |
| 323 | ErrorF |
| 324 | ("ddxProcessArgument - screen - Querying monitors failed\n"); |
| 325 | } |
| 326 | else if (data.bMonitorSpecifiedExists == TRUE) { |
| 327 | winErrorFVerb(2, |
| 328 | "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", |
| 329 | iMonitor); |
| 330 | iArgsProcessed = 3; |
| 331 | g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; |
| 332 | g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; |
| 333 | g_ScreenInfo[nScreenNum].iMonitor = iMonitor; |
| 334 | g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; |
| 335 | g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth; |
| 336 | g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight; |
| 337 | g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth; |
| 338 | g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight; |
| 339 | g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; |
| 340 | g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; |
| 341 | } |
| 342 | else { |
| 343 | /* monitor does not exist, error out */ |
| 344 | ErrorF |
| 345 | ("ddxProcessArgument - screen - Invalid monitor number %d\n", |
| 346 | iMonitor); |
| 347 | UseMsg(); |
| 348 | exit(0); |
| 349 | return 0; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | /* Look for 'WxD' or 'W D' */ |
| 354 | else if (i + 2 < argc |
| 355 | && 2 == sscanf(argv[i + 2], "%dx%d", |
| 356 | (int *) &iWidth, (int *) &iHeight)) { |
| 357 | winErrorFVerb(2, |
| 358 | "ddxProcessArgument - screen - Found ``WxD'' arg\n"); |
| 359 | iArgsProcessed = 3; |
| 360 | g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; |
| 361 | g_ScreenInfo[nScreenNum].dwWidth = iWidth; |
| 362 | g_ScreenInfo[nScreenNum].dwHeight = iHeight; |
| 363 | g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; |
| 364 | g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; |
| 365 | /* Look for WxD+X+Y */ |
| 366 | if (2 == sscanf(argv[i + 2], "%*dx%*d+%d+%d", |
| 367 | (int *) &iX, (int *) &iY)) { |
| 368 | winErrorFVerb(2, |
| 369 | "ddxProcessArgument - screen - Found ``X+Y'' arg\n"); |
| 370 | g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; |
| 371 | g_ScreenInfo[nScreenNum].dwInitialX = iX; |
| 372 | g_ScreenInfo[nScreenNum].dwInitialY = iY; |
| 373 | |
| 374 | /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */ |
| 375 | if (1 == sscanf(argv[i + 2], "%*dx%*d+%*d+%*d@%d", |
| 376 | (int *) &iMonitor)) { |
| 377 | struct GetMonitorInfoData data; |
| 378 | |
| 379 | if (!QueryMonitor(iMonitor, &data)) { |
| 380 | ErrorF |
| 381 | ("ddxProcessArgument - screen - Querying monitors failed\n"); |
| 382 | } |
| 383 | else if (data.bMonitorSpecifiedExists == TRUE) { |
| 384 | g_ScreenInfo[nScreenNum].iMonitor = iMonitor; |
| 385 | g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; |
| 386 | g_ScreenInfo[nScreenNum].dwInitialX += |
| 387 | data.monitorOffsetX; |
| 388 | g_ScreenInfo[nScreenNum].dwInitialY += |
| 389 | data.monitorOffsetY; |
| 390 | } |
| 391 | else { |
| 392 | /* monitor does not exist, error out */ |
| 393 | ErrorF |
| 394 | ("ddxProcessArgument - screen - Invalid monitor number %d\n", |
| 395 | iMonitor); |
| 396 | UseMsg(); |
| 397 | exit(0); |
| 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /* look for WxD@m where m is monitor number */ |
| 405 | else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", (int *) &iMonitor)) { |
| 406 | struct GetMonitorInfoData data; |
| 407 | |
| 408 | if (!QueryMonitor(iMonitor, &data)) { |
| 409 | ErrorF |
| 410 | ("ddxProcessArgument - screen - Querying monitors failed\n"); |
| 411 | } |
| 412 | else if (data.bMonitorSpecifiedExists == TRUE) { |
| 413 | winErrorFVerb(2, |
| 414 | "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", |
| 415 | iMonitor); |
| 416 | g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; |
| 417 | g_ScreenInfo[nScreenNum].iMonitor = iMonitor; |
| 418 | g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; |
| 419 | g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; |
| 420 | g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; |
| 421 | } |
| 422 | else { |
| 423 | /* monitor does not exist, error out */ |
| 424 | ErrorF |
| 425 | ("ddxProcessArgument - screen - Invalid monitor number %d\n", |
| 426 | iMonitor); |
| 427 | UseMsg(); |
| 428 | exit(0); |
| 429 | return 0; |
| 430 | } |
| 431 | |
| 432 | } |
| 433 | } |
| 434 | else if (i + 3 < argc && 1 == sscanf(argv[i + 2], "%d", (int *) &iWidth) |
| 435 | && 1 == sscanf(argv[i + 3], "%d", (int *) &iHeight)) { |
| 436 | winErrorFVerb(2, |
| 437 | "ddxProcessArgument - screen - Found ``W D'' arg\n"); |
| 438 | iArgsProcessed = 4; |
| 439 | g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; |
| 440 | g_ScreenInfo[nScreenNum].dwWidth = iWidth; |
| 441 | g_ScreenInfo[nScreenNum].dwHeight = iHeight; |
| 442 | g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; |
| 443 | g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; |
| 444 | if (i + 5 < argc && 1 == sscanf(argv[i + 4], "%d", (int *) &iX) |
| 445 | && 1 == sscanf(argv[i + 5], "%d", (int *) &iY)) { |
| 446 | winErrorFVerb(2, |
| 447 | "ddxProcessArgument - screen - Found ``X Y'' arg\n"); |
| 448 | iArgsProcessed = 6; |
| 449 | g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; |
| 450 | g_ScreenInfo[nScreenNum].dwInitialX = iX; |
| 451 | g_ScreenInfo[nScreenNum].dwInitialY = iY; |
| 452 | } |
| 453 | } |
| 454 | else { |
| 455 | winErrorFVerb(2, |
| 456 | "ddxProcessArgument - screen - Did not find size arg. " |
| 457 | "dwWidth: %d dwHeight: %d\n", |
| 458 | (int) g_ScreenInfo[nScreenNum].dwWidth, |
| 459 | (int) g_ScreenInfo[nScreenNum].dwHeight); |
| 460 | iArgsProcessed = 2; |
| 461 | g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; |
| 462 | } |
| 463 | |
| 464 | /* Flag that this screen was explicity specified by the user */ |
| 465 | g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE; |
| 466 | |
| 467 | /* |
| 468 | * Keep track of the last screen number seen, as parameters seen |
| 469 | * before a screen number apply to all screens, whereas parameters |
| 470 | * seen after a screen number apply to that screen number only. |
| 471 | */ |
| 472 | iLastScreen = nScreenNum; |
| 473 | |
| 474 | return iArgsProcessed; |
| 475 | } |
| 476 | |
| 477 | /* |
| 478 | * Is this parameter attached to a screen or global? |
| 479 | * |
| 480 | * If the parameter is for all screens (appears before |
| 481 | * any -screen option), store it in the default screen |
| 482 | * info |
| 483 | * |
| 484 | * If the parameter is for a single screen (appears |
| 485 | * after a -screen option), store it in the screen info |
| 486 | * for that screen |
| 487 | * |
| 488 | */ |
| 489 | if (iLastScreen == -1) { |
| 490 | screenInfoPtr = &defaultScreenInfo; |
| 491 | } |
| 492 | else { |
| 493 | screenInfoPtr = &(g_ScreenInfo[iLastScreen]); |
| 494 | } |
| 495 | |
| 496 | /* |
| 497 | * Look for the '-engine n' argument |
| 498 | */ |
| 499 | if (IS_OPTION("-engine")) { |
| 500 | DWORD dwEngine = 0; |
| 501 | CARD8 c8OnBits = 0; |
| 502 | |
| 503 | /* Display the usage message if the argument is malformed */ |
| 504 | if (++i >= argc) { |
| 505 | UseMsg(); |
| 506 | return 0; |
| 507 | } |
| 508 | |
| 509 | /* Grab the argument */ |
| 510 | dwEngine = atoi(argv[i]); |
| 511 | |
| 512 | /* Count the one bits in the engine argument */ |
| 513 | c8OnBits = winCountBits(dwEngine); |
| 514 | |
| 515 | /* Argument should only have a single bit on */ |
| 516 | if (c8OnBits != 1) { |
| 517 | UseMsg(); |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | screenInfoPtr->dwEnginePreferred = dwEngine; |
| 522 | |
| 523 | /* Indicate that we have processed the argument */ |
| 524 | return 2; |
| 525 | } |
| 526 | |
| 527 | /* |
| 528 | * Look for the '-fullscreen' argument |
| 529 | */ |
| 530 | if (IS_OPTION("-fullscreen")) { |
| 531 | #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) |
| 532 | if (!screenInfoPtr->fMultiMonitorOverride) |
| 533 | screenInfoPtr->fMultipleMonitors = FALSE; |
| 534 | #endif |
| 535 | screenInfoPtr->fFullScreen = TRUE; |
| 536 | |
| 537 | /* Indicate that we have processed this argument */ |
| 538 | return 1; |
| 539 | } |
| 540 | |
| 541 | /* |
| 542 | * Look for the '-lesspointer' argument |
| 543 | */ |
| 544 | if (IS_OPTION("-lesspointer")) { |
| 545 | screenInfoPtr->fLessPointer = TRUE; |
| 546 | |
| 547 | /* Indicate that we have processed this argument */ |
| 548 | return 1; |
| 549 | } |
| 550 | |
| 551 | /* |
| 552 | * Look for the '-nodecoration' argument |
| 553 | */ |
| 554 | if (IS_OPTION("-nodecoration")) { |
| 555 | #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) |
| 556 | if (!screenInfoPtr->fMultiMonitorOverride) |
| 557 | screenInfoPtr->fMultipleMonitors = FALSE; |
| 558 | #endif |
| 559 | screenInfoPtr->fDecoration = FALSE; |
| 560 | |
| 561 | /* Indicate that we have processed this argument */ |
| 562 | return 1; |
| 563 | } |
| 564 | |
| 565 | #ifdef XWIN_MULTIWINDOWEXTWM |
| 566 | /* |
| 567 | * Look for the '-mwextwm' argument |
| 568 | */ |
| 569 | if (IS_OPTION("-mwextwm")) { |
| 570 | if (!screenInfoPtr->fMultiMonitorOverride) |
| 571 | screenInfoPtr->fMultipleMonitors = TRUE; |
| 572 | screenInfoPtr->fMWExtWM = TRUE; |
| 573 | |
| 574 | /* Indicate that we have processed this argument */ |
| 575 | return 1; |
| 576 | } |
| 577 | /* |
| 578 | * Look for the '-internalwm' argument |
| 579 | */ |
| 580 | if (IS_OPTION("-internalwm")) { |
| 581 | if (!screenInfoPtr->fMultiMonitorOverride) |
| 582 | screenInfoPtr->fMultipleMonitors = TRUE; |
| 583 | screenInfoPtr->fMWExtWM = TRUE; |
| 584 | screenInfoPtr->fInternalWM = TRUE; |
| 585 | |
| 586 | /* Indicate that we have processed this argument */ |
| 587 | return 1; |
| 588 | } |
| 589 | #endif |
| 590 | |
| 591 | /* |
| 592 | * Look for the '-rootless' argument |
| 593 | */ |
| 594 | if (IS_OPTION("-rootless")) { |
| 595 | #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) |
| 596 | if (!screenInfoPtr->fMultiMonitorOverride) |
| 597 | screenInfoPtr->fMultipleMonitors = FALSE; |
| 598 | #endif |
| 599 | screenInfoPtr->fRootless = TRUE; |
| 600 | |
| 601 | /* Indicate that we have processed this argument */ |
| 602 | return 1; |
| 603 | } |
| 604 | |
| 605 | #ifdef XWIN_MULTIWINDOW |
| 606 | /* |
| 607 | * Look for the '-multiwindow' argument |
| 608 | */ |
| 609 | if (IS_OPTION("-multiwindow")) { |
| 610 | #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) |
| 611 | if (!screenInfoPtr->fMultiMonitorOverride) |
| 612 | screenInfoPtr->fMultipleMonitors = TRUE; |
| 613 | #endif |
| 614 | screenInfoPtr->fMultiWindow = TRUE; |
| 615 | |
| 616 | /* Indicate that we have processed this argument */ |
| 617 | return 1; |
| 618 | } |
| 619 | #endif |
| 620 | |
| 621 | /* |
| 622 | * Look for the '-multiplemonitors' argument |
| 623 | */ |
| 624 | if (IS_OPTION("-multiplemonitors") |
| 625 | || IS_OPTION("-multimonitors")) { |
| 626 | #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) |
| 627 | screenInfoPtr->fMultiMonitorOverride = TRUE; |
| 628 | #endif |
| 629 | screenInfoPtr->fMultipleMonitors = TRUE; |
| 630 | |
| 631 | /* Indicate that we have processed this argument */ |
| 632 | return 1; |
| 633 | } |
| 634 | |
| 635 | /* |
| 636 | * Look for the '-nomultiplemonitors' argument |
| 637 | */ |
| 638 | if (IS_OPTION("-nomultiplemonitors") |
| 639 | || IS_OPTION("-nomultimonitors")) { |
| 640 | #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) |
| 641 | screenInfoPtr->fMultiMonitorOverride = TRUE; |
| 642 | #endif |
| 643 | screenInfoPtr->fMultipleMonitors = FALSE; |
| 644 | |
| 645 | /* Indicate that we have processed this argument */ |
| 646 | return 1; |
| 647 | } |
| 648 | |
| 649 | /* |
| 650 | * Look for the '-scrollbars' argument |
| 651 | */ |
| 652 | if (IS_OPTION("-scrollbars")) { |
| 653 | |
| 654 | screenInfoPtr->iResizeMode = resizeWithScrollbars; |
| 655 | |
| 656 | /* Indicate that we have processed this argument */ |
| 657 | return 1; |
| 658 | } |
| 659 | |
| 660 | /* |
| 661 | * Look for the '-resize' argument |
| 662 | */ |
| 663 | if (IS_OPTION("-resize") || IS_OPTION("-noresize") || |
| 664 | (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0)) { |
| 665 | winResizeMode mode; |
| 666 | |
| 667 | if (IS_OPTION("-resize")) |
| 668 | mode = resizeWithRandr; |
| 669 | else if (IS_OPTION("-noresize")) |
| 670 | mode = notAllowed; |
| 671 | else if (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0) { |
| 672 | char *option = argv[i] + strlen("-resize="); |
| 673 | |
| 674 | if (strcmp(option, "randr") == 0) |
| 675 | mode = resizeWithRandr; |
| 676 | else if (strcmp(option, "scrollbars") == 0) |
| 677 | mode = resizeWithScrollbars; |
| 678 | else if (strcmp(option, "none") == 0) |
| 679 | mode = notAllowed; |
| 680 | else { |
| 681 | ErrorF("ddxProcessArgument - resize - Invalid resize mode %s\n", |
| 682 | option); |
| 683 | return 0; |
| 684 | } |
| 685 | } |
| 686 | else { |
| 687 | ErrorF("ddxProcessArgument - resize - Invalid resize option %s\n", |
| 688 | argv[i]); |
| 689 | return 0; |
| 690 | } |
| 691 | |
| 692 | screenInfoPtr->iResizeMode = mode; |
| 693 | |
| 694 | /* Indicate that we have processed this argument */ |
| 695 | return 1; |
| 696 | } |
| 697 | |
| 698 | #ifdef XWIN_CLIPBOARD |
| 699 | /* |
| 700 | * Look for the '-clipboard' argument |
| 701 | */ |
| 702 | if (IS_OPTION("-clipboard")) { |
| 703 | /* Now the default, we still accept the arg for backwards compatibility */ |
| 704 | g_fClipboard = TRUE; |
| 705 | |
| 706 | /* Indicate that we have processed this argument */ |
| 707 | return 1; |
| 708 | } |
| 709 | |
| 710 | /* |
| 711 | * Look for the '-noclipboard' argument |
| 712 | */ |
| 713 | if (IS_OPTION("-noclipboard")) { |
| 714 | g_fClipboard = FALSE; |
| 715 | |
| 716 | /* Indicate that we have processed this argument */ |
| 717 | return 1; |
| 718 | } |
| 719 | #endif |
| 720 | |
| 721 | /* |
| 722 | * Look for the '-ignoreinput' argument |
| 723 | */ |
| 724 | if (IS_OPTION("-ignoreinput")) { |
| 725 | screenInfoPtr->fIgnoreInput = TRUE; |
| 726 | |
| 727 | /* Indicate that we have processed this argument */ |
| 728 | return 1; |
| 729 | } |
| 730 | |
| 731 | /* |
| 732 | * Look for the '-emulate3buttons' argument |
| 733 | */ |
| 734 | if (IS_OPTION("-emulate3buttons")) { |
| 735 | int iArgsProcessed = 1; |
| 736 | int iE3BTimeout = WIN_DEFAULT_E3B_TIME; |
| 737 | |
| 738 | /* Grab the optional timeout value */ |
| 739 | if (i + 1 < argc && 1 == sscanf(argv[i + 1], "%d", &iE3BTimeout)) { |
| 740 | /* Indicate that we have processed the next argument */ |
| 741 | iArgsProcessed++; |
| 742 | } |
| 743 | else { |
| 744 | /* |
| 745 | * sscanf () won't modify iE3BTimeout if it doesn't find |
| 746 | * the specified format; however, I want to be explicit |
| 747 | * about setting the default timeout in such cases to |
| 748 | * prevent some programs (me) from getting confused. |
| 749 | */ |
| 750 | iE3BTimeout = WIN_DEFAULT_E3B_TIME; |
| 751 | } |
| 752 | |
| 753 | screenInfoPtr->iE3BTimeout = iE3BTimeout; |
| 754 | |
| 755 | /* Indicate that we have processed this argument */ |
| 756 | return iArgsProcessed; |
| 757 | } |
| 758 | |
| 759 | /* |
| 760 | * Look for the '-noemulate3buttons' argument |
| 761 | */ |
| 762 | if (IS_OPTION("-noemulate3buttons")) { |
| 763 | screenInfoPtr->iE3BTimeout = WIN_E3B_OFF; |
| 764 | |
| 765 | /* Indicate that we have processed this argument */ |
| 766 | return 1; |
| 767 | } |
| 768 | |
| 769 | /* |
| 770 | * Look for the '-depth n' argument |
| 771 | */ |
| 772 | if (IS_OPTION("-depth")) { |
| 773 | DWORD dwBPP = 0; |
| 774 | |
| 775 | /* Display the usage message if the argument is malformed */ |
| 776 | if (++i >= argc) { |
| 777 | UseMsg(); |
| 778 | return 0; |
| 779 | } |
| 780 | |
| 781 | /* Grab the argument */ |
| 782 | dwBPP = atoi(argv[i]); |
| 783 | |
| 784 | screenInfoPtr->dwBPP = dwBPP; |
| 785 | |
| 786 | /* Indicate that we have processed the argument */ |
| 787 | return 2; |
| 788 | } |
| 789 | |
| 790 | /* |
| 791 | * Look for the '-refresh n' argument |
| 792 | */ |
| 793 | if (IS_OPTION("-refresh")) { |
| 794 | DWORD dwRefreshRate = 0; |
| 795 | |
| 796 | /* Display the usage message if the argument is malformed */ |
| 797 | if (++i >= argc) { |
| 798 | UseMsg(); |
| 799 | return 0; |
| 800 | } |
| 801 | |
| 802 | /* Grab the argument */ |
| 803 | dwRefreshRate = atoi(argv[i]); |
| 804 | |
| 805 | screenInfoPtr->dwRefreshRate = dwRefreshRate; |
| 806 | |
| 807 | /* Indicate that we have processed the argument */ |
| 808 | return 2; |
| 809 | } |
| 810 | |
| 811 | /* |
| 812 | * Look for the '-clipupdates num_boxes' argument |
| 813 | */ |
| 814 | if (IS_OPTION("-clipupdates")) { |
| 815 | DWORD dwNumBoxes = 0; |
| 816 | |
| 817 | /* Display the usage message if the argument is malformed */ |
| 818 | if (++i >= argc) { |
| 819 | UseMsg(); |
| 820 | return 0; |
| 821 | } |
| 822 | |
| 823 | /* Grab the argument */ |
| 824 | dwNumBoxes = atoi(argv[i]); |
| 825 | |
| 826 | screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes; |
| 827 | |
| 828 | /* Indicate that we have processed the argument */ |
| 829 | return 2; |
| 830 | } |
| 831 | |
| 832 | #ifdef XWIN_EMULATEPSEUDO |
| 833 | /* |
| 834 | * Look for the '-emulatepseudo' argument |
| 835 | */ |
| 836 | if (IS_OPTION("-emulatepseudo")) { |
| 837 | screenInfoPtr->fEmulatePseudo = TRUE; |
| 838 | |
| 839 | /* Indicate that we have processed this argument */ |
| 840 | return 1; |
| 841 | } |
| 842 | #endif |
| 843 | |
| 844 | /* |
| 845 | * Look for the '-nowinkill' argument |
| 846 | */ |
| 847 | if (IS_OPTION("-nowinkill")) { |
| 848 | screenInfoPtr->fUseWinKillKey = FALSE; |
| 849 | |
| 850 | /* Indicate that we have processed this argument */ |
| 851 | return 1; |
| 852 | } |
| 853 | |
| 854 | /* |
| 855 | * Look for the '-winkill' argument |
| 856 | */ |
| 857 | if (IS_OPTION("-winkill")) { |
| 858 | screenInfoPtr->fUseWinKillKey = TRUE; |
| 859 | |
| 860 | /* Indicate that we have processed this argument */ |
| 861 | return 1; |
| 862 | } |
| 863 | |
| 864 | /* |
| 865 | * Look for the '-nounixkill' argument |
| 866 | */ |
| 867 | if (IS_OPTION("-nounixkill")) { |
| 868 | screenInfoPtr->fUseUnixKillKey = FALSE; |
| 869 | |
| 870 | /* Indicate that we have processed this argument */ |
| 871 | return 1; |
| 872 | } |
| 873 | |
| 874 | /* |
| 875 | * Look for the '-unixkill' argument |
| 876 | */ |
| 877 | if (IS_OPTION("-unixkill")) { |
| 878 | screenInfoPtr->fUseUnixKillKey = TRUE; |
| 879 | |
| 880 | /* Indicate that we have processed this argument */ |
| 881 | return 1; |
| 882 | } |
| 883 | |
| 884 | /* |
| 885 | * Look for the '-notrayicon' argument |
| 886 | */ |
| 887 | if (IS_OPTION("-notrayicon")) { |
| 888 | screenInfoPtr->fNoTrayIcon = TRUE; |
| 889 | |
| 890 | /* Indicate that we have processed this argument */ |
| 891 | return 1; |
| 892 | } |
| 893 | |
| 894 | /* |
| 895 | * Look for the '-trayicon' argument |
| 896 | */ |
| 897 | if (IS_OPTION("-trayicon")) { |
| 898 | screenInfoPtr->fNoTrayIcon = FALSE; |
| 899 | |
| 900 | /* Indicate that we have processed this argument */ |
| 901 | return 1; |
| 902 | } |
| 903 | |
| 904 | /* |
| 905 | * Look for the '-fp' argument |
| 906 | */ |
| 907 | if (IS_OPTION("-fp")) { |
| 908 | CHECK_ARGS(1); |
| 909 | g_cmdline.fontPath = argv[++i]; |
| 910 | return 0; /* Let DIX parse this again */ |
| 911 | } |
| 912 | |
| 913 | /* |
| 914 | * Look for the '-query' argument |
| 915 | */ |
| 916 | if (IS_OPTION("-query")) { |
| 917 | CHECK_ARGS(1); |
| 918 | g_fXdmcpEnabled = TRUE; |
| 919 | g_pszQueryHost = argv[++i]; |
| 920 | return 0; /* Let DIX parse this again */ |
| 921 | } |
| 922 | |
| 923 | /* |
| 924 | * Look for the '-auth' argument |
| 925 | */ |
| 926 | if (IS_OPTION("-auth")) { |
| 927 | g_fAuthEnabled = TRUE; |
| 928 | return 0; /* Let DIX parse this again */ |
| 929 | } |
| 930 | |
| 931 | /* |
| 932 | * Look for the '-indirect' or '-broadcast' arguments |
| 933 | */ |
| 934 | if (IS_OPTION("-indirect") |
| 935 | || IS_OPTION("-broadcast")) { |
| 936 | g_fXdmcpEnabled = TRUE; |
| 937 | return 0; /* Let DIX parse this again */ |
| 938 | } |
| 939 | |
| 940 | /* |
| 941 | * Look for the '-config' argument |
| 942 | */ |
| 943 | if (IS_OPTION("-config") |
| 944 | || IS_OPTION("-xf86config")) { |
| 945 | CHECK_ARGS(1); |
| 946 | #ifdef XWIN_XF86CONFIG |
| 947 | g_cmdline.configFile = argv[++i]; |
| 948 | #else |
| 949 | winMessageBoxF("The %s option is not supported in this " |
| 950 | "release.\n" |
| 951 | "Ignoring this option and continuing.\n", |
| 952 | MB_ICONINFORMATION, argv[i]); |
| 953 | #endif |
| 954 | return 2; |
| 955 | } |
| 956 | |
| 957 | /* |
| 958 | * Look for the '-configdir' argument |
| 959 | */ |
| 960 | if (IS_OPTION("-configdir")) { |
| 961 | CHECK_ARGS(1); |
| 962 | #ifdef XWIN_XF86CONFIG |
| 963 | g_cmdline.configDir = argv[++i]; |
| 964 | #else |
| 965 | winMessageBoxF("The %s option is not supported in this " |
| 966 | "release.\n" |
| 967 | "Ignoring this option and continuing.\n", |
| 968 | MB_ICONINFORMATION, argv[i]); |
| 969 | #endif |
| 970 | return 2; |
| 971 | } |
| 972 | |
| 973 | /* |
| 974 | * Look for the '-keyboard' argument |
| 975 | */ |
| 976 | if (IS_OPTION("-keyboard")) { |
| 977 | #ifdef XWIN_XF86CONFIG |
| 978 | CHECK_ARGS(1); |
| 979 | g_cmdline.keyboard = argv[++i]; |
| 980 | #else |
| 981 | winMessageBoxF("The -keyboard option is not supported in this " |
| 982 | "release.\n" |
| 983 | "Ignoring this option and continuing.\n", |
| 984 | MB_ICONINFORMATION); |
| 985 | #endif |
| 986 | return 2; |
| 987 | } |
| 988 | |
| 989 | /* |
| 990 | * Look for the '-logfile' argument |
| 991 | */ |
| 992 | if (IS_OPTION("-logfile")) { |
| 993 | CHECK_ARGS(1); |
| 994 | g_pszLogFile = argv[++i]; |
| 995 | #ifdef RELOCATE_PROJECTROOT |
| 996 | g_fLogFileChanged = TRUE; |
| 997 | #endif |
| 998 | return 2; |
| 999 | } |
| 1000 | |
| 1001 | /* |
| 1002 | * Look for the '-logverbose' argument |
| 1003 | */ |
| 1004 | if (IS_OPTION("-logverbose")) { |
| 1005 | CHECK_ARGS(1); |
| 1006 | g_iLogVerbose = atoi(argv[++i]); |
| 1007 | return 2; |
| 1008 | } |
| 1009 | |
| 1010 | #ifdef XWIN_CLIPBOARD |
| 1011 | /* |
| 1012 | * Look for the '-nounicodeclipboard' argument |
| 1013 | */ |
| 1014 | if (IS_OPTION("-nounicodeclipboard")) { |
| 1015 | g_fUnicodeClipboard = FALSE; |
| 1016 | /* Indicate that we have processed the argument */ |
| 1017 | return 1; |
| 1018 | } |
| 1019 | #endif |
| 1020 | |
| 1021 | if (IS_OPTION("-xkbrules")) { |
| 1022 | CHECK_ARGS(1); |
| 1023 | g_cmdline.xkbRules = argv[++i]; |
| 1024 | return 2; |
| 1025 | } |
| 1026 | if (IS_OPTION("-xkbmodel")) { |
| 1027 | CHECK_ARGS(1); |
| 1028 | g_cmdline.xkbModel = argv[++i]; |
| 1029 | return 2; |
| 1030 | } |
| 1031 | if (IS_OPTION("-xkblayout")) { |
| 1032 | CHECK_ARGS(1); |
| 1033 | g_cmdline.xkbLayout = argv[++i]; |
| 1034 | return 2; |
| 1035 | } |
| 1036 | if (IS_OPTION("-xkbvariant")) { |
| 1037 | CHECK_ARGS(1); |
| 1038 | g_cmdline.xkbVariant = argv[++i]; |
| 1039 | return 2; |
| 1040 | } |
| 1041 | if (IS_OPTION("-xkboptions")) { |
| 1042 | CHECK_ARGS(1); |
| 1043 | g_cmdline.xkbOptions = argv[++i]; |
| 1044 | return 2; |
| 1045 | } |
| 1046 | |
| 1047 | if (IS_OPTION("-keyhook")) { |
| 1048 | g_fKeyboardHookLL = TRUE; |
| 1049 | return 1; |
| 1050 | } |
| 1051 | |
| 1052 | if (IS_OPTION("-nokeyhook")) { |
| 1053 | g_fKeyboardHookLL = FALSE; |
| 1054 | return 1; |
| 1055 | } |
| 1056 | |
| 1057 | if (IS_OPTION("-swcursor")) { |
| 1058 | g_fSoftwareCursor = TRUE; |
| 1059 | return 1; |
| 1060 | } |
| 1061 | |
| 1062 | if (IS_OPTION("-silent-dup-error")) { |
| 1063 | g_fSilentDupError = TRUE; |
| 1064 | return 1; |
| 1065 | } |
| 1066 | |
| 1067 | if (IS_OPTION("-wgl")) { |
| 1068 | g_fNativeGl = TRUE; |
| 1069 | return 1; |
| 1070 | } |
| 1071 | |
| 1072 | if (IS_OPTION("-nowgl")) { |
| 1073 | g_fNativeGl = FALSE; |
| 1074 | return 1; |
| 1075 | } |
| 1076 | |
| 1077 | return 0; |
| 1078 | } |
| 1079 | |
| 1080 | /* |
| 1081 | * winLogCommandLine - Write entire command line to the log file |
| 1082 | */ |
| 1083 | |
| 1084 | void |
| 1085 | winLogCommandLine(int argc, char *argv[]) |
| 1086 | { |
| 1087 | int i; |
| 1088 | int iSize = 0; |
| 1089 | int iCurrLen = 0; |
| 1090 | |
| 1091 | #define CHARS_PER_LINE 60 |
| 1092 | |
| 1093 | /* Bail if command line has already been logged */ |
| 1094 | if (g_pszCommandLine) |
| 1095 | return; |
| 1096 | |
| 1097 | /* Count how much memory is needed for concatenated command line */ |
| 1098 | for (i = 0, iCurrLen = 0; i < argc; ++i) |
| 1099 | if (argv[i]) { |
| 1100 | /* Adds two characters for lines that overflow */ |
| 1101 | if ((strlen(argv[i]) < CHARS_PER_LINE |
| 1102 | && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) |
| 1103 | || strlen(argv[i]) > CHARS_PER_LINE) { |
| 1104 | iCurrLen = 0; |
| 1105 | iSize += 2; |
| 1106 | } |
| 1107 | |
| 1108 | /* Add space for item and trailing space */ |
| 1109 | iSize += strlen(argv[i]) + 1; |
| 1110 | |
| 1111 | /* Update current line length */ |
| 1112 | iCurrLen += strlen(argv[i]); |
| 1113 | } |
| 1114 | |
| 1115 | /* Allocate memory for concatenated command line */ |
| 1116 | g_pszCommandLine = malloc(iSize + 1); |
| 1117 | if (!g_pszCommandLine) |
| 1118 | FatalError("winLogCommandLine - Could not allocate memory for " |
| 1119 | "command line string. Exiting.\n"); |
| 1120 | |
| 1121 | /* Set first character to concatenated command line to null */ |
| 1122 | g_pszCommandLine[0] = '\0'; |
| 1123 | |
| 1124 | /* Loop through all args */ |
| 1125 | for (i = 0, iCurrLen = 0; i < argc; ++i) { |
| 1126 | /* Add a character for lines that overflow */ |
| 1127 | if ((strlen(argv[i]) < CHARS_PER_LINE |
| 1128 | && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) |
| 1129 | || strlen(argv[i]) > CHARS_PER_LINE) { |
| 1130 | iCurrLen = 0; |
| 1131 | |
| 1132 | /* Add line break if it fits */ |
| 1133 | strncat(g_pszCommandLine, "\n ", iSize - strlen(g_pszCommandLine)); |
| 1134 | } |
| 1135 | |
| 1136 | strncat(g_pszCommandLine, argv[i], iSize - strlen(g_pszCommandLine)); |
| 1137 | strncat(g_pszCommandLine, " ", iSize - strlen(g_pszCommandLine)); |
| 1138 | |
| 1139 | /* Save new line length */ |
| 1140 | iCurrLen += strlen(argv[i]); |
| 1141 | } |
| 1142 | |
| 1143 | ErrorF("XWin was started with the following command line:\n\n" |
| 1144 | "%s\n\n", g_pszCommandLine); |
| 1145 | } |
| 1146 | |
| 1147 | /* |
| 1148 | * winLogVersionInfo - Log version information |
| 1149 | */ |
| 1150 | |
| 1151 | void |
| 1152 | winLogVersionInfo(void) |
| 1153 | { |
| 1154 | static Bool s_fBeenHere = FALSE; |
| 1155 | |
| 1156 | if (s_fBeenHere) |
| 1157 | return; |
| 1158 | s_fBeenHere = TRUE; |
| 1159 | |
| 1160 | ErrorF("Welcome to the XWin X Server\n"); |
| 1161 | ErrorF("Vendor: %s\n", XVENDORNAME); |
| 1162 | ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR, |
| 1163 | XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP); |
| 1164 | if (strlen(BUILDERSTRING)) |
| 1165 | ErrorF("%s\n", BUILDERSTRING); |
| 1166 | ErrorF("Contact: %s\n", BUILDERADDR); |
| 1167 | ErrorF("\n"); |
| 1168 | } |