winprocarg.c revision 05b261ec
1/* 2 3Copyright 1993, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included 12in all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall 23not be used in advertising or otherwise to promote the sale, use or 24other dealings in this Software without prior written authorization 25from The Open Group. 26 27*/ 28 29#ifdef HAVE_XWIN_CONFIG_H 30#include <xwin-config.h> 31#endif 32#ifdef XVENDORNAME 33#define VENDOR_STRING XVENDORNAME 34#define VERSION_STRING XORG_RELEASE 35#define VENDOR_CONTACT BUILDERADDR 36#endif 37#include "win.h" 38#include "winconfig.h" 39#include "winprefs.h" 40#include "winmsg.h" 41 42/* 43 * References to external symbols 44 */ 45 46extern int g_iNumScreens; 47extern winScreenInfo g_ScreenInfo[]; 48extern int g_iLastScreen; 49extern Bool g_fInitializedDefaultScreens; 50#ifdef XWIN_CLIPBOARD 51extern Bool g_fUnicodeClipboard; 52extern Bool g_fClipboard; 53#endif 54extern int g_iLogVerbose; 55extern char * g_pszLogFile; 56#ifdef RELOCATE_PROJECTROOT 57extern Bool g_fLogFileChanged; 58#endif 59extern Bool g_fXdmcpEnabled; 60extern char * g_pszCommandLine; 61extern Bool g_fKeyboardHookLL; 62extern Bool g_fNoHelpMessageBox; 63extern Bool g_fSoftwareCursor; 64extern Bool g_fSilentDupError; 65 66/* globals required by callback function for monitor information */ 67struct GetMonitorInfoData { 68 int requestedMonitor; 69 int monitorNum; 70 Bool bUserSpecifiedMonitor; 71 Bool bMonitorSpecifiedExists; 72 int monitorOffsetX; 73 int monitorOffsetY; 74 int monitorHeight; 75 int monitorWidth; 76}; 77 78typedef wBOOL (*ENUMDISPLAYMONITORSPROC)(HDC,LPCRECT,MONITORENUMPROC,LPARAM); 79ENUMDISPLAYMONITORSPROC _EnumDisplayMonitors; 80 81wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data); 82 83static Bool QueryMonitor(int index, struct GetMonitorInfoData *data) 84{ 85 /* Load EnumDisplayMonitors from DLL */ 86 HMODULE user32; 87 FARPROC func; 88 user32 = LoadLibrary("user32.dll"); 89 if (user32 == NULL) 90 { 91 winW32Error(2, "Could not open user32.dll"); 92 return FALSE; 93 } 94 func = GetProcAddress(user32, "EnumDisplayMonitors"); 95 if (func == NULL) 96 { 97 winW32Error(2, "Could not resolve EnumDisplayMonitors: "); 98 return FALSE; 99 } 100 _EnumDisplayMonitors = (ENUMDISPLAYMONITORSPROC)func; 101 102 /* prepare data */ 103 if (data == NULL) 104 return FALSE; 105 memset(data, 0, sizeof(*data)); 106 data->requestedMonitor = index; 107 108 /* query information */ 109 _EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data); 110 111 /* cleanup */ 112 FreeLibrary(user32); 113 return TRUE; 114} 115 116/* 117 * Function prototypes 118 */ 119 120void 121winLogCommandLine (int argc, char *argv[]); 122 123void 124winLogVersionInfo (void); 125 126#ifdef DDXOSVERRORF 127void OsVendorVErrorF (const char *pszFormat, va_list va_args); 128#endif 129 130void 131winInitializeDefaultScreens (void); 132 133/* 134 * Process arguments on the command line 135 */ 136 137void 138winInitializeDefaultScreens (void) 139{ 140 int i; 141 DWORD dwWidth, dwHeight; 142 143 /* Bail out early if default screens have already been initialized */ 144 if (g_fInitializedDefaultScreens) 145 return; 146 147 /* Zero the memory used for storing the screen info */ 148 ZeroMemory (g_ScreenInfo, MAXSCREENS * sizeof (winScreenInfo)); 149 150 /* Get default width and height */ 151 /* 152 * NOTE: These defaults will cause the window to cover only 153 * the primary monitor in the case that we have multiple monitors. 154 */ 155 dwWidth = GetSystemMetrics (SM_CXSCREEN); 156 dwHeight = GetSystemMetrics (SM_CYSCREEN); 157 158 winErrorFVerb (2, "winInitializeDefaultScreens - w %d h %d\n", 159 (int) dwWidth, (int) dwHeight); 160 161 /* Set a default DPI, if no parameter was passed */ 162 if (monitorResolution == 0) 163 monitorResolution = WIN_DEFAULT_DPI; 164 165 for (i = 0; i < MAXSCREENS; ++i) 166 { 167 g_ScreenInfo[i].dwScreen = i; 168 g_ScreenInfo[i].dwWidth = dwWidth; 169 g_ScreenInfo[i].dwHeight = dwHeight; 170 g_ScreenInfo[i].dwUserWidth = dwWidth; 171 g_ScreenInfo[i].dwUserHeight = dwHeight; 172 g_ScreenInfo[i].fUserGaveHeightAndWidth 173 = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH; 174 g_ScreenInfo[i].fUserGavePosition = FALSE; 175 g_ScreenInfo[i].dwBPP = WIN_DEFAULT_BPP; 176 g_ScreenInfo[i].dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES; 177#ifdef XWIN_EMULATEPSEUDO 178 g_ScreenInfo[i].fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; 179#endif 180 g_ScreenInfo[i].dwRefreshRate = WIN_DEFAULT_REFRESH; 181 g_ScreenInfo[i].pfb = NULL; 182 g_ScreenInfo[i].fFullScreen = FALSE; 183 g_ScreenInfo[i].fDecoration = TRUE; 184#ifdef XWIN_MULTIWINDOWEXTWM 185 g_ScreenInfo[i].fMWExtWM = FALSE; 186 g_ScreenInfo[i].fInternalWM = FALSE; 187#endif 188 g_ScreenInfo[i].fRootless = FALSE; 189#ifdef XWIN_MULTIWINDOW 190 g_ScreenInfo[i].fMultiWindow = FALSE; 191#endif 192#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 193 g_ScreenInfo[i].fMultiMonitorOverride = FALSE; 194#endif 195 g_ScreenInfo[i].fMultipleMonitors = FALSE; 196 g_ScreenInfo[i].fLessPointer = FALSE; 197 g_ScreenInfo[i].fScrollbars = FALSE; 198 g_ScreenInfo[i].fNoTrayIcon = FALSE; 199 g_ScreenInfo[i].iE3BTimeout = WIN_E3B_OFF; 200 g_ScreenInfo[i].dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI) 201 * 25.4; 202 g_ScreenInfo[i].dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI) 203 * 25.4; 204 g_ScreenInfo[i].fUseWinKillKey = WIN_DEFAULT_WIN_KILL; 205 g_ScreenInfo[i].fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL; 206 g_ScreenInfo[i].fIgnoreInput = FALSE; 207 g_ScreenInfo[i].fExplicitScreen = FALSE; 208 } 209 210 /* Signal that the default screens have been initialized */ 211 g_fInitializedDefaultScreens = TRUE; 212 213 winErrorFVerb (2, "winInitializeDefaultScreens - Returning\n"); 214} 215 216/* See Porting Layer Definition - p. 57 */ 217/* 218 * INPUT 219 * argv: pointer to an array of null-terminated strings, one for 220 * each token in the X Server command line; the first token 221 * is 'XWin.exe', or similar. 222 * argc: a count of the number of tokens stored in argv. 223 * i: a zero-based index into argv indicating the current token being 224 * processed. 225 * 226 * OUTPUT 227 * return: return the number of tokens processed correctly. 228 * 229 * NOTE 230 * When looking for n tokens, check that i + n is less than argc. Or, 231 * you may check if i is greater than or equal to argc, in which case 232 * you should display the UseMsg () and return 0. 233 */ 234 235/* Check if enough arguments are given for the option */ 236#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; } 237 238/* Compare the current option with the string. */ 239#define IS_OPTION(name) (strcmp (argv[i], name) == 0) 240 241int 242ddxProcessArgument (int argc, char *argv[], int i) 243{ 244 static Bool s_fBeenHere = FALSE; 245 246 /* Initialize once */ 247 if (!s_fBeenHere) 248 { 249#ifdef DDXOSVERRORF 250 /* 251 * This initialises our hook into VErrorF () for catching log messages 252 * that are generated before OsInit () is called. 253 */ 254 OsVendorVErrorFProc = OsVendorVErrorF; 255#endif 256 257 s_fBeenHere = TRUE; 258 259 /* Initialize only if option is not -help */ 260 if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") && 261 !IS_OPTION("-version") && !IS_OPTION("--version")) 262 { 263 264 /* Log the version information */ 265 winLogVersionInfo (); 266 267 /* Log the command line */ 268 winLogCommandLine (argc, argv); 269 270 /* 271 * Initialize default screen settings. We have to do this before 272 * OsVendorInit () gets called, otherwise we will overwrite 273 * settings changed by parameters such as -fullscreen, etc. 274 */ 275 winErrorFVerb (2, "ddxProcessArgument - Initializing default " 276 "screens\n"); 277 winInitializeDefaultScreens (); 278 } 279 } 280 281#if CYGDEBUG 282 winDebug ("ddxProcessArgument - arg: %s\n", argv[i]); 283#endif 284 285 /* 286 * Look for the '-help' and similar options 287 */ 288 if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help")) 289 { 290 /* Reset logfile. We don't need that helpmessage in the logfile */ 291 g_pszLogFile = NULL; 292 g_fNoHelpMessageBox = TRUE; 293 UseMsg(); 294 exit (0); 295 return 1; 296 } 297 298 if (IS_OPTION ("-version") || IS_OPTION("--version")) 299 { 300 /* Reset logfile. We don't need that versioninfo in the logfile */ 301 g_pszLogFile = NULL; 302 winLogVersionInfo (); 303 exit (0); 304 return 1; 305 } 306 307 /* 308 * Look for the '-screen scr_num [width height]' argument 309 */ 310 if (IS_OPTION ("-screen")) 311 { 312 int iArgsProcessed = 1; 313 int nScreenNum; 314 int iWidth, iHeight, iX, iY; 315 int iMonitor; 316 317#if CYGDEBUG 318 winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n", 319 argc, i); 320#endif 321 322 /* Display the usage message if the argument is malformed */ 323 if (i + 1 >= argc) 324 { 325 return 0; 326 } 327 328 /* Grab screen number */ 329 nScreenNum = atoi (argv[i + 1]); 330 331 /* Validate the specified screen number */ 332 if (nScreenNum < 0 || nScreenNum >= MAXSCREENS) 333 { 334 ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n", 335 nScreenNum); 336 UseMsg (); 337 return 0; 338 } 339 340 /* look for @m where m is monitor number */ 341 if (i + 2 < argc 342 && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) 343 { 344 struct GetMonitorInfoData data; 345 if (!QueryMonitor(iMonitor, &data)) 346 { 347 ErrorF ("ddxProcessArgument - screen - " 348 "Querying monitors is not supported on NT4 and Win95\n"); 349 } else if (data.bMonitorSpecifiedExists == TRUE) 350 { 351 winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); 352 iArgsProcessed = 3; 353 g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 354 g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 355 g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth; 356 g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight; 357 g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth; 358 g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight; 359 g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 360 g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 361 } 362 else 363 { 364 /* monitor does not exist, error out */ 365 ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n", 366 iMonitor); 367 UseMsg (); 368 exit (0); 369 return 0; 370 } 371 } 372 373 /* Look for 'WxD' or 'W D' */ 374 else if (i + 2 < argc 375 && 2 == sscanf (argv[i + 2], "%dx%d", 376 (int *) &iWidth, 377 (int *) &iHeight)) 378 { 379 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``WxD'' arg\n"); 380 iArgsProcessed = 3; 381 g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 382 g_ScreenInfo[nScreenNum].dwWidth = iWidth; 383 g_ScreenInfo[nScreenNum].dwHeight = iHeight; 384 g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 385 g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 386 /* Look for WxD+X+Y */ 387 if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d", 388 (int *) &iX, 389 (int *) &iY)) 390 { 391 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X+Y'' arg\n"); 392 g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 393 g_ScreenInfo[nScreenNum].dwInitialX = iX; 394 g_ScreenInfo[nScreenNum].dwInitialY = iY; 395 396 /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */ 397 if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d", 398 (int *) &iMonitor)) 399 { 400 struct GetMonitorInfoData data; 401 if (!QueryMonitor(iMonitor, &data)) 402 { 403 ErrorF ("ddxProcessArgument - screen - " 404 "Querying monitors is not supported on NT4 and Win95\n"); 405 } else if (data.bMonitorSpecifiedExists == TRUE) 406 { 407 g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX; 408 g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY; 409 } 410 else 411 { 412 /* monitor does not exist, error out */ 413 ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n", 414 iMonitor); 415 UseMsg (); 416 exit (0); 417 return 0; 418 } 419 420 } 421 } 422 423 /* look for WxD@m where m is monitor number */ 424 else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", 425 (int *) &iMonitor)) 426 { 427 struct GetMonitorInfoData data; 428 if (!QueryMonitor(iMonitor, &data)) 429 { 430 ErrorF ("ddxProcessArgument - screen - " 431 "Querying monitors is not supported on NT4 and Win95\n"); 432 } else if (data.bMonitorSpecifiedExists == TRUE) 433 { 434 winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); 435 g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 436 g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 437 g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 438 } 439 else 440 { 441 /* monitor does not exist, error out */ 442 ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n", 443 iMonitor); 444 UseMsg (); 445 exit (0); 446 return 0; 447 } 448 449 } 450 } 451 else if (i + 3 < argc 452 && 1 == sscanf (argv[i + 2], "%d", 453 (int *) &iWidth) 454 && 1 == sscanf (argv[i + 3], "%d", 455 (int *) &iHeight)) 456 { 457 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``W D'' arg\n"); 458 iArgsProcessed = 4; 459 g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 460 g_ScreenInfo[nScreenNum].dwWidth = iWidth; 461 g_ScreenInfo[nScreenNum].dwHeight = iHeight; 462 g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 463 g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 464 if (i + 5 < argc 465 && 1 == sscanf (argv[i + 4], "%d", 466 (int *) &iX) 467 && 1 == sscanf (argv[i + 5], "%d", 468 (int *) &iY)) 469 { 470 winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X Y'' arg\n"); 471 iArgsProcessed = 6; 472 g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 473 g_ScreenInfo[nScreenNum].dwInitialX = iX; 474 g_ScreenInfo[nScreenNum].dwInitialY = iY; 475 } 476 } 477 else 478 { 479 winErrorFVerb (2, "ddxProcessArgument - screen - Did not find size arg. " 480 "dwWidth: %d dwHeight: %d\n", 481 (int) g_ScreenInfo[nScreenNum].dwWidth, 482 (int) g_ScreenInfo[nScreenNum].dwHeight); 483 iArgsProcessed = 2; 484 g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 485 } 486 487 /* Calculate the screen width and height in millimeters */ 488 if (g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth) 489 { 490 g_ScreenInfo[nScreenNum].dwWidth_mm 491 = (g_ScreenInfo[nScreenNum].dwWidth 492 / monitorResolution) * 25.4; 493 g_ScreenInfo[nScreenNum].dwHeight_mm 494 = (g_ScreenInfo[nScreenNum].dwHeight 495 / monitorResolution) * 25.4; 496 } 497 498 /* Flag that this screen was explicity specified by the user */ 499 g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE; 500 501 /* 502 * Keep track of the last screen number seen, as parameters seen 503 * before a screen number apply to all screens, whereas parameters 504 * seen after a screen number apply to that screen number only. 505 */ 506 g_iLastScreen = nScreenNum; 507 508 /* Keep a count of the number of screens */ 509 ++g_iNumScreens; 510 511 return iArgsProcessed; 512 } 513 514 /* 515 * Look for the '-engine n' argument 516 */ 517 if (IS_OPTION ("-engine")) 518 { 519 DWORD dwEngine = 0; 520 CARD8 c8OnBits = 0; 521 522 /* Display the usage message if the argument is malformed */ 523 if (++i >= argc) 524 { 525 UseMsg (); 526 return 0; 527 } 528 529 /* Grab the argument */ 530 dwEngine = atoi (argv[i]); 531 532 /* Count the one bits in the engine argument */ 533 c8OnBits = winCountBits (dwEngine); 534 535 /* Argument should only have a single bit on */ 536 if (c8OnBits != 1) 537 { 538 UseMsg (); 539 return 0; 540 } 541 542 /* Is this parameter attached to a screen or global? */ 543 if (-1 == g_iLastScreen) 544 { 545 int j; 546 547 /* Parameter is for all screens */ 548 for (j = 0; j < MAXSCREENS; j++) 549 { 550 g_ScreenInfo[j].dwEnginePreferred = dwEngine; 551 } 552 } 553 else 554 { 555 /* Parameter is for a single screen */ 556 g_ScreenInfo[g_iLastScreen].dwEnginePreferred = dwEngine; 557 } 558 559 /* Indicate that we have processed the argument */ 560 return 2; 561 } 562 563 /* 564 * Look for the '-fullscreen' argument 565 */ 566 if (IS_OPTION ("-fullscreen")) 567 { 568 /* Is this parameter attached to a screen or is it global? */ 569 if (-1 == g_iLastScreen) 570 { 571 int j; 572 573 /* Parameter is for all screens */ 574 for (j = 0; j < MAXSCREENS; j++) 575 { 576#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 577 if (!g_ScreenInfo[j].fMultiMonitorOverride) 578 g_ScreenInfo[j].fMultipleMonitors = FALSE; 579#endif 580 g_ScreenInfo[j].fFullScreen = TRUE; 581 } 582 } 583 else 584 { 585 /* Parameter is for a single screen */ 586#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 587 if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) 588 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; 589#endif 590 g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE; 591 } 592 593 /* Indicate that we have processed this argument */ 594 return 1; 595 } 596 597 /* 598 * Look for the '-lesspointer' argument 599 */ 600 if (IS_OPTION ("-lesspointer")) 601 { 602 /* Is this parameter attached to a screen or is it global? */ 603 if (-1 == g_iLastScreen) 604 { 605 int j; 606 607 /* Parameter is for all screens */ 608 for (j = 0; j < MAXSCREENS; j++) 609 { 610 g_ScreenInfo[j].fLessPointer = TRUE; 611 } 612 } 613 else 614 { 615 /* Parameter is for a single screen */ 616 g_ScreenInfo[g_iLastScreen].fLessPointer = TRUE; 617 } 618 619 /* Indicate that we have processed this argument */ 620 return 1; 621 } 622 623 /* 624 * Look for the '-nodecoration' argument 625 */ 626 if (IS_OPTION ("-nodecoration")) 627 { 628 /* Is this parameter attached to a screen or is it global? */ 629 if (-1 == g_iLastScreen) 630 { 631 int j; 632 633 /* Parameter is for all screens */ 634 for (j = 0; j < MAXSCREENS; j++) 635 { 636#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 637 if (!g_ScreenInfo[j].fMultiMonitorOverride) 638 g_ScreenInfo[j].fMultipleMonitors = FALSE; 639#endif 640 g_ScreenInfo[j].fDecoration = FALSE; 641 } 642 } 643 else 644 { 645 /* Parameter is for a single screen */ 646#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 647 if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) 648 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; 649#endif 650 g_ScreenInfo[g_iLastScreen].fDecoration = FALSE; 651 } 652 653 /* Indicate that we have processed this argument */ 654 return 1; 655 } 656 657#ifdef XWIN_MULTIWINDOWEXTWM 658 /* 659 * Look for the '-mwextwm' argument 660 */ 661 if (IS_OPTION ("-mwextwm")) 662 { 663 /* Is this parameter attached to a screen or is it global? */ 664 if (-1 == g_iLastScreen) 665 { 666 int j; 667 668 /* Parameter is for all screens */ 669 for (j = 0; j < MAXSCREENS; j++) 670 { 671 if (!g_ScreenInfo[j].fMultiMonitorOverride) 672 g_ScreenInfo[j].fMultipleMonitors = TRUE; 673 g_ScreenInfo[j].fMWExtWM = TRUE; 674 } 675 } 676 else 677 { 678 /* Parameter is for a single screen */ 679 if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) 680 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; 681 g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE; 682 } 683 684 /* Indicate that we have processed this argument */ 685 return 1; 686 } 687 /* 688 * Look for the '-internalwm' argument 689 */ 690 if (IS_OPTION ("-internalwm")) 691 { 692 /* Is this parameter attached to a screen or is it global? */ 693 if (-1 == g_iLastScreen) 694 { 695 int j; 696 697 /* Parameter is for all screens */ 698 for (j = 0; j < MAXSCREENS; j++) 699 { 700 if (!g_ScreenInfo[j].fMultiMonitorOverride) 701 g_ScreenInfo[j].fMultipleMonitors = TRUE; 702 g_ScreenInfo[j].fMWExtWM = TRUE; 703 g_ScreenInfo[j].fInternalWM = TRUE; 704 } 705 } 706 else 707 { 708 /* Parameter is for a single screen */ 709 if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) 710 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; 711 g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE; 712 g_ScreenInfo[g_iLastScreen].fInternalWM = TRUE; 713 } 714 715 /* Indicate that we have processed this argument */ 716 return 1; 717 } 718#endif 719 720 /* 721 * Look for the '-rootless' argument 722 */ 723 if (IS_OPTION ("-rootless")) 724 { 725 /* Is this parameter attached to a screen or is it global? */ 726 if (-1 == g_iLastScreen) 727 { 728 int j; 729 730 /* Parameter is for all screens */ 731 for (j = 0; j < MAXSCREENS; j++) 732 { 733#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 734 if (!g_ScreenInfo[j].fMultiMonitorOverride) 735 g_ScreenInfo[j].fMultipleMonitors = FALSE; 736#endif 737 g_ScreenInfo[j].fRootless = TRUE; 738 } 739 } 740 else 741 { 742 /* Parameter is for a single screen */ 743#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 744 if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) 745 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; 746#endif 747 g_ScreenInfo[g_iLastScreen].fRootless = TRUE; 748 } 749 750 /* Indicate that we have processed this argument */ 751 return 1; 752 } 753 754#ifdef XWIN_MULTIWINDOW 755 /* 756 * Look for the '-multiwindow' argument 757 */ 758 if (IS_OPTION ("-multiwindow")) 759 { 760 /* Is this parameter attached to a screen or is it global? */ 761 if (-1 == g_iLastScreen) 762 { 763 int j; 764 765 /* Parameter is for all screens */ 766 for (j = 0; j < MAXSCREENS; j++) 767 { 768#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 769 if (!g_ScreenInfo[j].fMultiMonitorOverride) 770 g_ScreenInfo[j].fMultipleMonitors = TRUE; 771#endif 772 g_ScreenInfo[j].fMultiWindow = TRUE; 773 } 774 } 775 else 776 { 777 /* Parameter is for a single screen */ 778#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 779 if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) 780 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; 781#endif 782 g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE; 783 } 784 785 /* Indicate that we have processed this argument */ 786 return 1; 787 } 788#endif 789 790 /* 791 * Look for the '-multiplemonitors' argument 792 */ 793 if (IS_OPTION ("-multiplemonitors") 794 || IS_OPTION ("-multimonitors")) 795 { 796 /* Is this parameter attached to a screen or is it global? */ 797 if (-1 == g_iLastScreen) 798 { 799 int j; 800 801 /* Parameter is for all screens */ 802 for (j = 0; j < MAXSCREENS; j++) 803 { 804#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 805 g_ScreenInfo[j].fMultiMonitorOverride = TRUE; 806#endif 807 g_ScreenInfo[j].fMultipleMonitors = TRUE; 808 } 809 } 810 else 811 { 812 /* Parameter is for a single screen */ 813#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 814 g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; 815#endif 816 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; 817 } 818 819 /* Indicate that we have processed this argument */ 820 return 1; 821 } 822 823 /* 824 * Look for the '-nomultiplemonitors' argument 825 */ 826 if (IS_OPTION ("-nomultiplemonitors") 827 || IS_OPTION ("-nomultimonitors")) 828 { 829 /* Is this parameter attached to a screen or is it global? */ 830 if (-1 == g_iLastScreen) 831 { 832 int j; 833 834 /* Parameter is for all screens */ 835 for (j = 0; j < MAXSCREENS; j++) 836 { 837#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 838 g_ScreenInfo[j].fMultiMonitorOverride = TRUE; 839#endif 840 g_ScreenInfo[j].fMultipleMonitors = FALSE; 841 } 842 } 843 else 844 { 845 /* Parameter is for a single screen */ 846#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 847 g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; 848#endif 849 g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; 850 } 851 852 /* Indicate that we have processed this argument */ 853 return 1; 854 } 855 856 857 /* 858 * Look for the '-scrollbars' argument 859 */ 860 if (IS_OPTION ("-scrollbars")) 861 { 862 /* Is this parameter attached to a screen or is it global? */ 863 if (-1 == g_iLastScreen) 864 { 865 int j; 866 867 /* Parameter is for all screens */ 868 for (j = 0; j < MAXSCREENS; j++) 869 { 870 g_ScreenInfo[j].fScrollbars = TRUE; 871 } 872 } 873 else 874 { 875 /* Parameter is for a single screen */ 876 g_ScreenInfo[g_iLastScreen].fScrollbars = TRUE; 877 } 878 879 /* Indicate that we have processed this argument */ 880 return 1; 881 } 882 883 884#ifdef XWIN_CLIPBOARD 885 /* 886 * Look for the '-clipboard' argument 887 */ 888 if (IS_OPTION ("-clipboard")) 889 { 890 g_fClipboard = TRUE; 891 892 /* Indicate that we have processed this argument */ 893 return 1; 894 } 895#endif 896 897 898 /* 899 * Look for the '-ignoreinput' argument 900 */ 901 if (IS_OPTION ("-ignoreinput")) 902 { 903 /* Is this parameter attached to a screen or is it global? */ 904 if (-1 == g_iLastScreen) 905 { 906 int j; 907 908 /* Parameter is for all screens */ 909 for (j = 0; j < MAXSCREENS; j++) 910 { 911 g_ScreenInfo[j].fIgnoreInput = TRUE; 912 } 913 } 914 else 915 { 916 /* Parameter is for a single screen */ 917 g_ScreenInfo[g_iLastScreen].fIgnoreInput = TRUE; 918 } 919 920 /* Indicate that we have processed this argument */ 921 return 1; 922 } 923 924 /* 925 * Look for the '-emulate3buttons' argument 926 */ 927 if (IS_OPTION ("-emulate3buttons")) 928 { 929 int iArgsProcessed = 1; 930 int iE3BTimeout = WIN_DEFAULT_E3B_TIME; 931 932 /* Grab the optional timeout value */ 933 if (i + 1 < argc 934 && 1 == sscanf (argv[i + 1], "%d", 935 &iE3BTimeout)) 936 { 937 /* Indicate that we have processed the next argument */ 938 iArgsProcessed++; 939 } 940 else 941 { 942 /* 943 * sscanf () won't modify iE3BTimeout if it doesn't find 944 * the specified format; however, I want to be explicit 945 * about setting the default timeout in such cases to 946 * prevent some programs (me) from getting confused. 947 */ 948 iE3BTimeout = WIN_DEFAULT_E3B_TIME; 949 } 950 951 /* Is this parameter attached to a screen or is it global? */ 952 if (-1 == g_iLastScreen) 953 { 954 int j; 955 956 /* Parameter is for all screens */ 957 for (j = 0; j < MAXSCREENS; j++) 958 { 959 g_ScreenInfo[j].iE3BTimeout = iE3BTimeout; 960 } 961 } 962 else 963 { 964 /* Parameter is for a single screen */ 965 g_ScreenInfo[g_iLastScreen].iE3BTimeout = iE3BTimeout; 966 } 967 968 /* Indicate that we have processed this argument */ 969 return iArgsProcessed; 970 } 971 972 /* 973 * Look for the '-depth n' argument 974 */ 975 if (IS_OPTION ("-depth")) 976 { 977 DWORD dwBPP = 0; 978 979 /* Display the usage message if the argument is malformed */ 980 if (++i >= argc) 981 { 982 UseMsg (); 983 return 0; 984 } 985 986 /* Grab the argument */ 987 dwBPP = atoi (argv[i]); 988 989 /* Is this parameter attached to a screen or global? */ 990 if (-1 == g_iLastScreen) 991 { 992 int j; 993 994 /* Parameter is for all screens */ 995 for (j = 0; j < MAXSCREENS; j++) 996 { 997 g_ScreenInfo[j].dwBPP = dwBPP; 998 } 999 } 1000 else 1001 { 1002 /* Parameter is for a single screen */ 1003 g_ScreenInfo[g_iLastScreen].dwBPP = dwBPP; 1004 } 1005 1006 /* Indicate that we have processed the argument */ 1007 return 2; 1008 } 1009 1010 /* 1011 * Look for the '-refresh n' argument 1012 */ 1013 if (IS_OPTION ("-refresh")) 1014 { 1015 DWORD dwRefreshRate = 0; 1016 1017 /* Display the usage message if the argument is malformed */ 1018 if (++i >= argc) 1019 { 1020 UseMsg (); 1021 return 0; 1022 } 1023 1024 /* Grab the argument */ 1025 dwRefreshRate = atoi (argv[i]); 1026 1027 /* Is this parameter attached to a screen or global? */ 1028 if (-1 == g_iLastScreen) 1029 { 1030 int j; 1031 1032 /* Parameter is for all screens */ 1033 for (j = 0; j < MAXSCREENS; j++) 1034 { 1035 g_ScreenInfo[j].dwRefreshRate = dwRefreshRate; 1036 } 1037 } 1038 else 1039 { 1040 /* Parameter is for a single screen */ 1041 g_ScreenInfo[g_iLastScreen].dwRefreshRate = dwRefreshRate; 1042 } 1043 1044 /* Indicate that we have processed the argument */ 1045 return 2; 1046 } 1047 1048 /* 1049 * Look for the '-clipupdates num_boxes' argument 1050 */ 1051 if (IS_OPTION ("-clipupdates")) 1052 { 1053 DWORD dwNumBoxes = 0; 1054 1055 /* Display the usage message if the argument is malformed */ 1056 if (++i >= argc) 1057 { 1058 UseMsg (); 1059 return 0; 1060 } 1061 1062 /* Grab the argument */ 1063 dwNumBoxes = atoi (argv[i]); 1064 1065 /* Is this parameter attached to a screen or global? */ 1066 if (-1 == g_iLastScreen) 1067 { 1068 int j; 1069 1070 /* Parameter is for all screens */ 1071 for (j = 0; j < MAXSCREENS; j++) 1072 { 1073 g_ScreenInfo[j].dwClipUpdatesNBoxes = dwNumBoxes; 1074 } 1075 } 1076 else 1077 { 1078 /* Parameter is for a single screen */ 1079 g_ScreenInfo[g_iLastScreen].dwClipUpdatesNBoxes = dwNumBoxes; 1080 } 1081 1082 /* Indicate that we have processed the argument */ 1083 return 2; 1084 } 1085 1086#ifdef XWIN_EMULATEPSEUDO 1087 /* 1088 * Look for the '-emulatepseudo' argument 1089 */ 1090 if (IS_OPTION ("-emulatepseudo")) 1091 { 1092 /* Is this parameter attached to a screen or is it global? */ 1093 if (-1 == g_iLastScreen) 1094 { 1095 int j; 1096 1097 /* Parameter is for all screens */ 1098 for (j = 0; j < MAXSCREENS; j++) 1099 { 1100 g_ScreenInfo[j].fEmulatePseudo = TRUE; 1101 } 1102 } 1103 else 1104 { 1105 /* Parameter is for a single screen */ 1106 g_ScreenInfo[g_iLastScreen].fEmulatePseudo = TRUE; 1107 } 1108 1109 /* Indicate that we have processed this argument */ 1110 return 1; 1111 } 1112#endif 1113 1114 /* 1115 * Look for the '-nowinkill' argument 1116 */ 1117 if (IS_OPTION ("-nowinkill")) 1118 { 1119 /* Is this parameter attached to a screen or is it global? */ 1120 if (-1 == g_iLastScreen) 1121 { 1122 int j; 1123 1124 /* Parameter is for all screens */ 1125 for (j = 0; j < MAXSCREENS; j++) 1126 { 1127 g_ScreenInfo[j].fUseWinKillKey = FALSE; 1128 } 1129 } 1130 else 1131 { 1132 /* Parameter is for a single screen */ 1133 g_ScreenInfo[g_iLastScreen].fUseWinKillKey = FALSE; 1134 } 1135 1136 /* Indicate that we have processed this argument */ 1137 return 1; 1138 } 1139 1140 /* 1141 * Look for the '-winkill' argument 1142 */ 1143 if (IS_OPTION ("-winkill")) 1144 { 1145 /* Is this parameter attached to a screen or is it global? */ 1146 if (-1 == g_iLastScreen) 1147 { 1148 int j; 1149 1150 /* Parameter is for all screens */ 1151 for (j = 0; j < MAXSCREENS; j++) 1152 { 1153 g_ScreenInfo[j].fUseWinKillKey = TRUE; 1154 } 1155 } 1156 else 1157 { 1158 /* Parameter is for a single screen */ 1159 g_ScreenInfo[g_iLastScreen].fUseWinKillKey = TRUE; 1160 } 1161 1162 /* Indicate that we have processed this argument */ 1163 return 1; 1164 } 1165 1166 /* 1167 * Look for the '-nounixkill' argument 1168 */ 1169 if (IS_OPTION ("-nounixkill")) 1170 { 1171 /* Is this parameter attached to a screen or is it global? */ 1172 if (-1 == g_iLastScreen) 1173 { 1174 int j; 1175 1176 /* Parameter is for all screens */ 1177 for (j = 0; j < MAXSCREENS; j++) 1178 { 1179 g_ScreenInfo[j].fUseUnixKillKey = FALSE; 1180 } 1181 } 1182 else 1183 { 1184 /* Parameter is for a single screen */ 1185 g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = FALSE; 1186 } 1187 1188 /* Indicate that we have processed this argument */ 1189 return 1; 1190 } 1191 1192 /* 1193 * Look for the '-unixkill' argument 1194 */ 1195 if (IS_OPTION ("-unixkill")) 1196 { 1197 /* Is this parameter attached to a screen or is it global? */ 1198 if (-1 == g_iLastScreen) 1199 { 1200 int j; 1201 1202 /* Parameter is for all screens */ 1203 for (j = 0; j < MAXSCREENS; j++) 1204 { 1205 g_ScreenInfo[j].fUseUnixKillKey = TRUE; 1206 } 1207 } 1208 else 1209 { 1210 /* Parameter is for a single screen */ 1211 g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE; 1212 } 1213 1214 /* Indicate that we have processed this argument */ 1215 return 1; 1216 } 1217 1218 /* 1219 * Look for the '-notrayicon' argument 1220 */ 1221 if (IS_OPTION ("-notrayicon")) 1222 { 1223 /* Is this parameter attached to a screen or is it global? */ 1224 if (-1 == g_iLastScreen) 1225 { 1226 int j; 1227 1228 /* Parameter is for all screens */ 1229 for (j = 0; j < MAXSCREENS; j++) 1230 { 1231 g_ScreenInfo[j].fNoTrayIcon = TRUE; 1232 } 1233 } 1234 else 1235 { 1236 /* Parameter is for a single screen */ 1237 g_ScreenInfo[g_iLastScreen].fNoTrayIcon = TRUE; 1238 } 1239 1240 /* Indicate that we have processed this argument */ 1241 return 1; 1242 } 1243 1244 /* 1245 * Look for the '-trayicon' argument 1246 */ 1247 if (IS_OPTION ("-trayicon")) 1248 { 1249 /* Is this parameter attached to a screen or is it global? */ 1250 if (-1 == g_iLastScreen) 1251 { 1252 int j; 1253 1254 /* Parameter is for all screens */ 1255 for (j = 0; j < MAXSCREENS; j++) 1256 { 1257 g_ScreenInfo[j].fNoTrayIcon = FALSE; 1258 } 1259 } 1260 else 1261 { 1262 /* Parameter is for a single screen */ 1263 g_ScreenInfo[g_iLastScreen].fNoTrayIcon = FALSE; 1264 } 1265 1266 /* Indicate that we have processed this argument */ 1267 return 1; 1268 } 1269 1270 /* 1271 * Look for the '-fp' argument 1272 */ 1273 if (IS_OPTION ("-fp")) 1274 { 1275 CHECK_ARGS (1); 1276 g_cmdline.fontPath = argv[++i]; 1277 return 0; /* Let DIX parse this again */ 1278 } 1279 1280 /* 1281 * Look for the '-co' argument 1282 */ 1283 if (IS_OPTION ("-co")) 1284 { 1285 CHECK_ARGS (1); 1286 g_cmdline.rgbPath = argv[++i]; 1287 return 0; /* Let DIX parse this again */ 1288 } 1289 1290 /* 1291 * Look for the '-query' argument 1292 */ 1293 if (IS_OPTION ("-query")) 1294 { 1295 CHECK_ARGS (1); 1296 g_fXdmcpEnabled = TRUE; 1297 g_pszQueryHost = argv[++i]; 1298 return 0; /* Let DIX parse this again */ 1299 } 1300 1301 /* 1302 * Look for the '-indirect' or '-broadcast' arguments 1303 */ 1304 if (IS_OPTION ("-indirect") 1305 || IS_OPTION ("-broadcast")) 1306 { 1307 g_fXdmcpEnabled = TRUE; 1308 return 0; /* Let DIX parse this again */ 1309 } 1310 1311 /* 1312 * Look for the '-config' argument 1313 */ 1314 if (IS_OPTION ("-config") 1315 || IS_OPTION ("-xf86config")) 1316 { 1317 CHECK_ARGS (1); 1318#ifdef XWIN_XF86CONFIG 1319 g_cmdline.configFile = argv[++i]; 1320#else 1321 winMessageBoxF ("The %s option is not supported in this " 1322 "release.\n" 1323 "Ignoring this option and continuing.\n", 1324 MB_ICONINFORMATION, 1325 argv[i]); 1326#endif 1327 return 2; 1328 } 1329 1330 /* 1331 * Look for the '-keyboard' argument 1332 */ 1333 if (IS_OPTION ("-keyboard")) 1334 { 1335#ifdef XWIN_XF86CONFIG 1336 CHECK_ARGS (1); 1337 g_cmdline.keyboard = argv[++i]; 1338#else 1339 winMessageBoxF ("The -keyboard option is not supported in this " 1340 "release.\n" 1341 "Ignoring this option and continuing.\n", 1342 MB_ICONINFORMATION); 1343#endif 1344 return 2; 1345 } 1346 1347 /* 1348 * Look for the '-logfile' argument 1349 */ 1350 if (IS_OPTION ("-logfile")) 1351 { 1352 CHECK_ARGS (1); 1353 g_pszLogFile = argv[++i]; 1354#ifdef RELOCATE_PROJECTROOT 1355 g_fLogFileChanged = TRUE; 1356#endif 1357 return 2; 1358 } 1359 1360 /* 1361 * Look for the '-logverbose' argument 1362 */ 1363 if (IS_OPTION ("-logverbose")) 1364 { 1365 CHECK_ARGS (1); 1366 g_iLogVerbose = atoi(argv[++i]); 1367 return 2; 1368 } 1369 1370#ifdef XWIN_CLIPBOARD 1371 /* 1372 * Look for the '-nounicodeclipboard' argument 1373 */ 1374 if (IS_OPTION ("-nounicodeclipboard")) 1375 { 1376 g_fUnicodeClipboard = FALSE; 1377 /* Indicate that we have processed the argument */ 1378 return 1; 1379 } 1380#endif 1381 1382#ifdef XKB 1383 /* 1384 * Look for the '-kb' argument 1385 */ 1386 if (IS_OPTION ("-kb")) 1387 { 1388 g_cmdline.noXkbExtension = TRUE; 1389 return 0; /* Let DIX parse this again */ 1390 } 1391 1392 if (IS_OPTION ("-xkbrules")) 1393 { 1394 CHECK_ARGS (1); 1395 g_cmdline.xkbRules = argv[++i]; 1396 return 2; 1397 } 1398 if (IS_OPTION ("-xkbmodel")) 1399 { 1400 CHECK_ARGS (1); 1401 g_cmdline.xkbModel = argv[++i]; 1402 return 2; 1403 } 1404 if (IS_OPTION ("-xkblayout")) 1405 { 1406 CHECK_ARGS (1); 1407 g_cmdline.xkbLayout = argv[++i]; 1408 return 2; 1409 } 1410 if (IS_OPTION ("-xkbvariant")) 1411 { 1412 CHECK_ARGS (1); 1413 g_cmdline.xkbVariant = argv[++i]; 1414 return 2; 1415 } 1416 if (IS_OPTION ("-xkboptions")) 1417 { 1418 CHECK_ARGS (1); 1419 g_cmdline.xkbOptions = argv[++i]; 1420 return 2; 1421 } 1422#endif 1423 1424 if (IS_OPTION ("-keyhook")) 1425 { 1426 g_fKeyboardHookLL = TRUE; 1427 return 1; 1428 } 1429 1430 if (IS_OPTION ("-nokeyhook")) 1431 { 1432 g_fKeyboardHookLL = FALSE; 1433 return 1; 1434 } 1435 1436 if (IS_OPTION ("-swcursor")) 1437 { 1438 g_fSoftwareCursor = TRUE; 1439 return 1; 1440 } 1441 1442 if (IS_OPTION ("-silent-dup-error")) 1443 { 1444 g_fSilentDupError = TRUE; 1445 return 1; 1446 } 1447 return 0; 1448} 1449 1450 1451/* 1452 * winLogCommandLine - Write entire command line to the log file 1453 */ 1454 1455void 1456winLogCommandLine (int argc, char *argv[]) 1457{ 1458 int i; 1459 int iSize = 0; 1460 int iCurrLen = 0; 1461 1462#define CHARS_PER_LINE 60 1463 1464 /* Bail if command line has already been logged */ 1465 if (g_pszCommandLine) 1466 return; 1467 1468 /* Count how much memory is needed for concatenated command line */ 1469 for (i = 0, iCurrLen = 0; i < argc; ++i) 1470 if (argv[i]) 1471 { 1472 /* Add a character for lines that overflow */ 1473 if ((strlen (argv[i]) < CHARS_PER_LINE 1474 && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE) 1475 || strlen (argv[i]) > CHARS_PER_LINE) 1476 { 1477 iCurrLen = 0; 1478 ++iSize; 1479 } 1480 1481 /* Add space for item and trailing space */ 1482 iSize += strlen (argv[i]) + 1; 1483 1484 /* Update current line length */ 1485 iCurrLen += strlen (argv[i]); 1486 } 1487 1488 /* Allocate memory for concatenated command line */ 1489 g_pszCommandLine = malloc (iSize + 1); 1490 if (!g_pszCommandLine) 1491 FatalError ("winLogCommandLine - Could not allocate memory for " 1492 "command line string. Exiting.\n"); 1493 1494 /* Set first character to concatenated command line to null */ 1495 g_pszCommandLine[0] = '\0'; 1496 1497 /* Loop through all args */ 1498 for (i = 0, iCurrLen = 0; i < argc; ++i) 1499 { 1500 /* Add a character for lines that overflow */ 1501 if ((strlen (argv[i]) < CHARS_PER_LINE 1502 && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE) 1503 || strlen (argv[i]) > CHARS_PER_LINE) 1504 { 1505 iCurrLen = 0; 1506 1507 /* Add line break if it fits */ 1508 strncat (g_pszCommandLine, "\n", iSize - strlen (g_pszCommandLine)); 1509 } 1510 1511 strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine)); 1512 strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine)); 1513 1514 /* Save new line length */ 1515 iCurrLen += strlen (argv[i]); 1516 } 1517 1518 ErrorF ("XWin was started with the following command line:\n\n" 1519 "%s\n\n", g_pszCommandLine); 1520} 1521 1522 1523/* 1524 * winLogVersionInfo - Log Cygwin/X version information 1525 */ 1526 1527void 1528winLogVersionInfo (void) 1529{ 1530 static Bool s_fBeenHere = FALSE; 1531 1532 if (s_fBeenHere) 1533 return; 1534 s_fBeenHere = TRUE; 1535 1536 ErrorF ("Welcome to the XWin X Server\n"); 1537 ErrorF ("Vendor: %s\n", VENDOR_STRING); 1538 ErrorF ("Release: %s\n\n", VERSION_STRING); 1539 ErrorF ("Contact: %s\n\n", VENDOR_CONTACT); 1540} 1541 1542/* 1543 * getMonitorInfo - callback function used to return information from the enumeration of monitors attached 1544 */ 1545 1546wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data) 1547{ 1548 struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data; 1549 // only get data for monitor number specified in <data> 1550 data->monitorNum++; 1551 if (data->monitorNum == data->requestedMonitor) 1552 { 1553 data->bMonitorSpecifiedExists = TRUE; 1554 data->monitorOffsetX = rect->left; 1555 data->monitorOffsetY = rect->top; 1556 data->monitorHeight = rect->bottom - rect->top; 1557 data->monitorWidth = rect->right - rect->left; 1558 return FALSE; 1559 } 1560 return TRUE; 1561} 1562