1706f2543Smrg/* 2706f2543Smrg 3706f2543SmrgCopyright 1993, 1998 The Open Group 4706f2543SmrgCopyright (C) Colin Harrison 2005-2008 5706f2543Smrg 6706f2543SmrgPermission to use, copy, modify, distribute, and sell this software and its 7706f2543Smrgdocumentation for any purpose is hereby granted without fee, provided that 8706f2543Smrgthe above copyright notice appear in all copies and that both that 9706f2543Smrgcopyright notice and this permission notice appear in supporting 10706f2543Smrgdocumentation. 11706f2543Smrg 12706f2543SmrgThe above copyright notice and this permission notice shall be included 13706f2543Smrgin all copies or substantial portions of the Software. 14706f2543Smrg 15706f2543SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16706f2543SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17706f2543SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18706f2543SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 19706f2543SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20706f2543SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21706f2543SmrgOTHER DEALINGS IN THE SOFTWARE. 22706f2543Smrg 23706f2543SmrgExcept as contained in this notice, the name of The Open Group shall 24706f2543Smrgnot be used in advertising or otherwise to promote the sale, use or 25706f2543Smrgother dealings in this Software without prior written authorization 26706f2543Smrgfrom The Open Group. 27706f2543Smrg 28706f2543Smrg*/ 29706f2543Smrg 30706f2543Smrg#ifdef HAVE_XWIN_CONFIG_H 31706f2543Smrg#include <xwin-config.h> 32706f2543Smrg#endif 33706f2543Smrg 34706f2543Smrg#include <../xfree86/common/xorgVersion.h> 35706f2543Smrg#include "win.h" 36706f2543Smrg#include "winconfig.h" 37706f2543Smrg#include "winmsg.h" 38706f2543Smrg#include "winmonitors.h" 39706f2543Smrg 40706f2543Smrg/* 41706f2543Smrg * References to external symbols 42706f2543Smrg */ 43706f2543Smrg 44706f2543Smrg#ifdef XWIN_CLIPBOARD 45706f2543Smrgextern Bool g_fUnicodeClipboard; 46706f2543Smrgextern Bool g_fClipboard; 47706f2543Smrg#endif 48706f2543Smrg 49706f2543Smrg/* 50706f2543Smrg * Function prototypes 51706f2543Smrg */ 52706f2543Smrg 53706f2543Smrgvoid 54706f2543SmrgwinLogCommandLine (int argc, char *argv[]); 55706f2543Smrg 56706f2543Smrgvoid 57706f2543SmrgwinLogVersionInfo (void); 58706f2543Smrg 59706f2543Smrg#ifdef DDXOSVERRORF 60706f2543Smrgvoid OsVendorVErrorF (const char *pszFormat, va_list va_args); 61706f2543Smrg#endif 62706f2543Smrg 63706f2543Smrg/* 64706f2543Smrg * Process arguments on the command line 65706f2543Smrg */ 66706f2543Smrg 67706f2543Smrgstatic int iLastScreen = -1; 68706f2543Smrgstatic winScreenInfo defaultScreenInfo; 69706f2543Smrg 70706f2543Smrgstatic void 71706f2543SmrgwinInitializeScreenDefaults(void) 72706f2543Smrg{ 73706f2543Smrg DWORD dwWidth, dwHeight; 74706f2543Smrg static Bool fInitializedScreenDefaults = FALSE; 75706f2543Smrg 76706f2543Smrg /* Bail out early if default screen has already been initialized */ 77706f2543Smrg if (fInitializedScreenDefaults) 78706f2543Smrg return; 79706f2543Smrg 80706f2543Smrg /* Zero the memory used for storing the screen info */ 81706f2543Smrg memset(&defaultScreenInfo, 0, sizeof(winScreenInfo)); 82706f2543Smrg 83706f2543Smrg /* Get default width and height */ 84706f2543Smrg /* 85706f2543Smrg * NOTE: These defaults will cause the window to cover only 86706f2543Smrg * the primary monitor in the case that we have multiple monitors. 87706f2543Smrg */ 88706f2543Smrg dwWidth = GetSystemMetrics (SM_CXSCREEN); 89706f2543Smrg dwHeight = GetSystemMetrics (SM_CYSCREEN); 90706f2543Smrg 91706f2543Smrg winErrorFVerb (2, "winInitializeScreenDefaults - w %d h %d\n", 92706f2543Smrg (int) dwWidth, (int) dwHeight); 93706f2543Smrg 94706f2543Smrg /* Set a default DPI, if no parameter was passed */ 95706f2543Smrg if (monitorResolution == 0) 96706f2543Smrg monitorResolution = WIN_DEFAULT_DPI; 97706f2543Smrg 98706f2543Smrg defaultScreenInfo.iMonitor = 1; 99706f2543Smrg defaultScreenInfo.dwWidth = dwWidth; 100706f2543Smrg defaultScreenInfo.dwHeight = dwHeight; 101706f2543Smrg defaultScreenInfo.dwUserWidth = dwWidth; 102706f2543Smrg defaultScreenInfo.dwUserHeight = dwHeight; 103706f2543Smrg defaultScreenInfo.fUserGaveHeightAndWidth = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH; 104706f2543Smrg defaultScreenInfo.fUserGavePosition = FALSE; 105706f2543Smrg defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP; 106706f2543Smrg defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES; 107706f2543Smrg#ifdef XWIN_EMULATEPSEUDO 108706f2543Smrg defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; 109706f2543Smrg#endif 110706f2543Smrg defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH; 111706f2543Smrg defaultScreenInfo.pfb = NULL; 112706f2543Smrg defaultScreenInfo.fFullScreen = FALSE; 113706f2543Smrg defaultScreenInfo.fDecoration = TRUE; 114706f2543Smrg#ifdef XWIN_MULTIWINDOWEXTWM 115706f2543Smrg defaultScreenInfo.fMWExtWM = FALSE; 116706f2543Smrg defaultScreenInfo.fInternalWM = FALSE; 117706f2543Smrg#endif 118706f2543Smrg defaultScreenInfo.fRootless = FALSE; 119706f2543Smrg#ifdef XWIN_MULTIWINDOW 120706f2543Smrg defaultScreenInfo.fMultiWindow = FALSE; 121706f2543Smrg#endif 122706f2543Smrg#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 123706f2543Smrg defaultScreenInfo.fMultiMonitorOverride = FALSE; 124706f2543Smrg#endif 125706f2543Smrg defaultScreenInfo.fMultipleMonitors = FALSE; 126706f2543Smrg defaultScreenInfo.fLessPointer = FALSE; 127706f2543Smrg defaultScreenInfo.iResizeMode = notAllowed; 128706f2543Smrg defaultScreenInfo.fNoTrayIcon = FALSE; 129706f2543Smrg defaultScreenInfo.iE3BTimeout = WIN_E3B_OFF; 130706f2543Smrg defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL; 131706f2543Smrg defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL; 132706f2543Smrg defaultScreenInfo.fIgnoreInput = FALSE; 133706f2543Smrg defaultScreenInfo.fExplicitScreen = FALSE; 134706f2543Smrg 135706f2543Smrg /* Note that the default screen has been initialized */ 136706f2543Smrg fInitializedScreenDefaults = TRUE; 137706f2543Smrg} 138706f2543Smrg 139706f2543Smrgstatic void 140706f2543SmrgwinInitializeScreen(int i) 141706f2543Smrg{ 142706f2543Smrg winErrorFVerb (2, "winInitializeScreen - %d\n",i); 143706f2543Smrg 144706f2543Smrg /* Initialize default screen values, if needed */ 145706f2543Smrg winInitializeScreenDefaults(); 146706f2543Smrg 147706f2543Smrg /* Copy the default screen info */ 148706f2543Smrg g_ScreenInfo[i] = defaultScreenInfo; 149706f2543Smrg 150706f2543Smrg /* Set the screen number */ 151706f2543Smrg g_ScreenInfo[i].dwScreen = i; 152706f2543Smrg} 153706f2543Smrg 154706f2543Smrgvoid 155706f2543SmrgwinInitializeScreens(int maxscreens) 156706f2543Smrg{ 157706f2543Smrg int i; 158706f2543Smrg winErrorFVerb (2, "winInitializeScreens - %i\n", maxscreens); 159706f2543Smrg 160706f2543Smrg if (maxscreens > g_iNumScreens) 161706f2543Smrg { 162706f2543Smrg /* Reallocate the memory for DDX-specific screen info */ 163706f2543Smrg g_ScreenInfo = realloc(g_ScreenInfo, maxscreens * sizeof (winScreenInfo)); 164706f2543Smrg 165706f2543Smrg /* Set default values for any new screens */ 166706f2543Smrg for (i = g_iNumScreens; i < maxscreens ; i++) 167706f2543Smrg winInitializeScreen(i); 168706f2543Smrg 169706f2543Smrg /* Keep a count of the number of screens */ 170706f2543Smrg g_iNumScreens = maxscreens; 171706f2543Smrg } 172706f2543Smrg} 173706f2543Smrg 174706f2543Smrg/* See Porting Layer Definition - p. 57 */ 175706f2543Smrg/* 176706f2543Smrg * INPUT 177706f2543Smrg * argv: pointer to an array of null-terminated strings, one for 178706f2543Smrg * each token in the X Server command line; the first token 179706f2543Smrg * is 'XWin.exe', or similar. 180706f2543Smrg * argc: a count of the number of tokens stored in argv. 181706f2543Smrg * i: a zero-based index into argv indicating the current token being 182706f2543Smrg * processed. 183706f2543Smrg * 184706f2543Smrg * OUTPUT 185706f2543Smrg * return: return the number of tokens processed correctly. 186706f2543Smrg * 187706f2543Smrg * NOTE 188706f2543Smrg * When looking for n tokens, check that i + n is less than argc. Or, 189706f2543Smrg * you may check if i is greater than or equal to argc, in which case 190706f2543Smrg * you should display the UseMsg () and return 0. 191706f2543Smrg */ 192706f2543Smrg 193706f2543Smrg/* Check if enough arguments are given for the option */ 194706f2543Smrg#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; } 195706f2543Smrg 196706f2543Smrg/* Compare the current option with the string. */ 197706f2543Smrg#define IS_OPTION(name) (strcmp (argv[i], name) == 0) 198706f2543Smrg 199706f2543Smrgint 200706f2543SmrgddxProcessArgument (int argc, char *argv[], int i) 201706f2543Smrg{ 202706f2543Smrg static Bool s_fBeenHere = FALSE; 203706f2543Smrg winScreenInfo *screenInfoPtr = NULL; 204706f2543Smrg 205706f2543Smrg /* Initialize once */ 206706f2543Smrg if (!s_fBeenHere) 207706f2543Smrg { 208706f2543Smrg#ifdef DDXOSVERRORF 209706f2543Smrg /* 210706f2543Smrg * This initialises our hook into VErrorF () for catching log messages 211706f2543Smrg * that are generated before OsInit () is called. 212706f2543Smrg */ 213706f2543Smrg OsVendorVErrorFProc = OsVendorVErrorF; 214706f2543Smrg#endif 215706f2543Smrg 216706f2543Smrg s_fBeenHere = TRUE; 217706f2543Smrg 218706f2543Smrg /* Initialize only if option is not -help */ 219706f2543Smrg if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") && 220706f2543Smrg !IS_OPTION("-version") && !IS_OPTION("--version")) 221706f2543Smrg { 222706f2543Smrg 223706f2543Smrg /* Log the version information */ 224706f2543Smrg winLogVersionInfo (); 225706f2543Smrg 226706f2543Smrg /* Log the command line */ 227706f2543Smrg winLogCommandLine (argc, argv); 228706f2543Smrg 229706f2543Smrg /* 230706f2543Smrg * Initialize default screen settings. We have to do this before 231706f2543Smrg * OsVendorInit () gets called, otherwise we will overwrite 232706f2543Smrg * settings changed by parameters such as -fullscreen, etc. 233706f2543Smrg */ 234706f2543Smrg winErrorFVerb (2, "ddxProcessArgument - Initializing default " 235706f2543Smrg "screens\n"); 236706f2543Smrg winInitializeScreenDefaults(); 237706f2543Smrg } 238706f2543Smrg } 239706f2543Smrg 240706f2543Smrg#if CYGDEBUG 241706f2543Smrg winDebug ("ddxProcessArgument - arg: %s\n", argv[i]); 242706f2543Smrg#endif 243706f2543Smrg 244706f2543Smrg /* 245706f2543Smrg * Look for the '-help' and similar options 246706f2543Smrg */ 247706f2543Smrg if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help")) 248706f2543Smrg { 249706f2543Smrg /* Reset logfile. We don't need that helpmessage in the logfile */ 250706f2543Smrg g_pszLogFile = NULL; 251706f2543Smrg g_fNoHelpMessageBox = TRUE; 252706f2543Smrg UseMsg(); 253706f2543Smrg exit (0); 254706f2543Smrg return 1; 255706f2543Smrg } 256706f2543Smrg 257706f2543Smrg if (IS_OPTION ("-version") || IS_OPTION("--version")) 258706f2543Smrg { 259706f2543Smrg /* Reset logfile. We don't need that versioninfo in the logfile */ 260706f2543Smrg g_pszLogFile = NULL; 261706f2543Smrg winLogVersionInfo (); 262706f2543Smrg exit (0); 263706f2543Smrg return 1; 264706f2543Smrg } 265706f2543Smrg 266706f2543Smrg /* 267706f2543Smrg * Look for the '-screen scr_num [width height]' argument 268706f2543Smrg */ 269706f2543Smrg if (IS_OPTION ("-screen")) 270706f2543Smrg { 271706f2543Smrg int iArgsProcessed = 1; 272706f2543Smrg int nScreenNum; 273706f2543Smrg int iWidth, iHeight, iX, iY; 274706f2543Smrg int iMonitor; 275706f2543Smrg 276706f2543Smrg#if CYGDEBUG 277706f2543Smrg winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n", 278706f2543Smrg argc, i); 279706f2543Smrg#endif 280706f2543Smrg 281706f2543Smrg /* Display the usage message if the argument is malformed */ 282706f2543Smrg if (i + 1 >= argc) 283706f2543Smrg { 284706f2543Smrg return 0; 285706f2543Smrg } 286706f2543Smrg 287706f2543Smrg /* Grab screen number */ 288706f2543Smrg nScreenNum = atoi (argv[i + 1]); 289706f2543Smrg 290706f2543Smrg /* Validate the specified screen number */ 291706f2543Smrg if (nScreenNum < 0) 292706f2543Smrg { 293706f2543Smrg ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n", 294706f2543Smrg nScreenNum); 295706f2543Smrg UseMsg (); 296706f2543Smrg return 0; 297706f2543Smrg } 298706f2543Smrg 299706f2543Smrg /* 300706f2543Smrg Initialize default values for any new screens 301706f2543Smrg 302706f2543Smrg Note that default values can't change after a -screen option is 303706f2543Smrg seen, so it's safe to do this for each screen as it is introduced 304706f2543Smrg */ 305706f2543Smrg winInitializeScreens(nScreenNum+1); 306706f2543Smrg 307706f2543Smrg /* look for @m where m is monitor number */ 308706f2543Smrg if (i + 2 < argc 309706f2543Smrg && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) 310706f2543Smrg { 311706f2543Smrg struct GetMonitorInfoData data; 312706f2543Smrg if (!QueryMonitor(iMonitor, &data)) 313706f2543Smrg { 314706f2543Smrg ErrorF ("ddxProcessArgument - screen - " 315706f2543Smrg "Querying monitors is not supported on NT4 and Win95\n"); 316706f2543Smrg } else if (data.bMonitorSpecifiedExists == TRUE) 317706f2543Smrg { 318706f2543Smrg winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); 319706f2543Smrg iArgsProcessed = 3; 320706f2543Smrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 321706f2543Smrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 322706f2543Smrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 323706f2543Smrg g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth; 324706f2543Smrg g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight; 325706f2543Smrg g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth; 326706f2543Smrg g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight; 327706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 328706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 329706f2543Smrg } 330706f2543Smrg else 331706f2543Smrg { 332706f2543Smrg /* monitor does not exist, error out */ 333706f2543Smrg ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n", 334706f2543Smrg iMonitor); 335706f2543Smrg UseMsg (); 336706f2543Smrg exit (0); 337706f2543Smrg return 0; 338706f2543Smrg } 339706f2543Smrg } 340706f2543Smrg 341706f2543Smrg /* Look for 'WxD' or 'W D' */ 342706f2543Smrg else if (i + 2 < argc 343706f2543Smrg && 2 == sscanf (argv[i + 2], "%dx%d", 344706f2543Smrg (int *) &iWidth, 345706f2543Smrg (int *) &iHeight)) 346706f2543Smrg { 347706f2543Smrg winErrorFVerb (2, "ddxProcessArgument - screen - Found ``WxD'' arg\n"); 348706f2543Smrg iArgsProcessed = 3; 349706f2543Smrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 350706f2543Smrg g_ScreenInfo[nScreenNum].dwWidth = iWidth; 351706f2543Smrg g_ScreenInfo[nScreenNum].dwHeight = iHeight; 352706f2543Smrg g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 353706f2543Smrg g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 354706f2543Smrg /* Look for WxD+X+Y */ 355706f2543Smrg if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d", 356706f2543Smrg (int *) &iX, 357706f2543Smrg (int *) &iY)) 358706f2543Smrg { 359706f2543Smrg winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X+Y'' arg\n"); 360706f2543Smrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 361706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialX = iX; 362706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialY = iY; 363706f2543Smrg 364706f2543Smrg /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */ 365706f2543Smrg if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d", 366706f2543Smrg (int *) &iMonitor)) 367706f2543Smrg { 368706f2543Smrg struct GetMonitorInfoData data; 369706f2543Smrg if (!QueryMonitor(iMonitor, &data)) 370706f2543Smrg { 371706f2543Smrg ErrorF ("ddxProcessArgument - screen - " 372706f2543Smrg "Querying monitors is not supported on NT4 and Win95\n"); 373706f2543Smrg } else if (data.bMonitorSpecifiedExists == TRUE) 374706f2543Smrg { 375706f2543Smrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 376706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX; 377706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY; 378706f2543Smrg } 379706f2543Smrg else 380706f2543Smrg { 381706f2543Smrg /* monitor does not exist, error out */ 382706f2543Smrg ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n", 383706f2543Smrg iMonitor); 384706f2543Smrg UseMsg (); 385706f2543Smrg exit (0); 386706f2543Smrg return 0; 387706f2543Smrg } 388706f2543Smrg 389706f2543Smrg } 390706f2543Smrg } 391706f2543Smrg 392706f2543Smrg /* look for WxD@m where m is monitor number */ 393706f2543Smrg else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", 394706f2543Smrg (int *) &iMonitor)) 395706f2543Smrg { 396706f2543Smrg struct GetMonitorInfoData data; 397706f2543Smrg if (!QueryMonitor(iMonitor, &data)) 398706f2543Smrg { 399706f2543Smrg ErrorF ("ddxProcessArgument - screen - " 400706f2543Smrg "Querying monitors is not supported on NT4 and Win95\n"); 401706f2543Smrg } else if (data.bMonitorSpecifiedExists == TRUE) 402706f2543Smrg { 403706f2543Smrg winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); 404706f2543Smrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 405706f2543Smrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 406706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 407706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 408706f2543Smrg } 409706f2543Smrg else 410706f2543Smrg { 411706f2543Smrg /* monitor does not exist, error out */ 412706f2543Smrg ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n", 413706f2543Smrg iMonitor); 414706f2543Smrg UseMsg (); 415706f2543Smrg exit (0); 416706f2543Smrg return 0; 417706f2543Smrg } 418706f2543Smrg 419706f2543Smrg } 420706f2543Smrg } 421706f2543Smrg else if (i + 3 < argc 422706f2543Smrg && 1 == sscanf (argv[i + 2], "%d", 423706f2543Smrg (int *) &iWidth) 424706f2543Smrg && 1 == sscanf (argv[i + 3], "%d", 425706f2543Smrg (int *) &iHeight)) 426706f2543Smrg { 427706f2543Smrg winErrorFVerb (2, "ddxProcessArgument - screen - Found ``W D'' arg\n"); 428706f2543Smrg iArgsProcessed = 4; 429706f2543Smrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 430706f2543Smrg g_ScreenInfo[nScreenNum].dwWidth = iWidth; 431706f2543Smrg g_ScreenInfo[nScreenNum].dwHeight = iHeight; 432706f2543Smrg g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 433706f2543Smrg g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 434706f2543Smrg if (i + 5 < argc 435706f2543Smrg && 1 == sscanf (argv[i + 4], "%d", 436706f2543Smrg (int *) &iX) 437706f2543Smrg && 1 == sscanf (argv[i + 5], "%d", 438706f2543Smrg (int *) &iY)) 439706f2543Smrg { 440706f2543Smrg winErrorFVerb (2, "ddxProcessArgument - screen - Found ``X Y'' arg\n"); 441706f2543Smrg iArgsProcessed = 6; 442706f2543Smrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 443706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialX = iX; 444706f2543Smrg g_ScreenInfo[nScreenNum].dwInitialY = iY; 445706f2543Smrg } 446706f2543Smrg } 447706f2543Smrg else 448706f2543Smrg { 449706f2543Smrg winErrorFVerb (2, "ddxProcessArgument - screen - Did not find size arg. " 450706f2543Smrg "dwWidth: %d dwHeight: %d\n", 451706f2543Smrg (int) g_ScreenInfo[nScreenNum].dwWidth, 452706f2543Smrg (int) g_ScreenInfo[nScreenNum].dwHeight); 453706f2543Smrg iArgsProcessed = 2; 454706f2543Smrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 455706f2543Smrg } 456706f2543Smrg 457706f2543Smrg /* Flag that this screen was explicity specified by the user */ 458706f2543Smrg g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE; 459706f2543Smrg 460706f2543Smrg /* 461706f2543Smrg * Keep track of the last screen number seen, as parameters seen 462706f2543Smrg * before a screen number apply to all screens, whereas parameters 463706f2543Smrg * seen after a screen number apply to that screen number only. 464706f2543Smrg */ 465706f2543Smrg iLastScreen = nScreenNum; 466706f2543Smrg 467706f2543Smrg return iArgsProcessed; 468706f2543Smrg } 469706f2543Smrg 470706f2543Smrg 471706f2543Smrg /* 472706f2543Smrg * Is this parameter attached to a screen or global? 473706f2543Smrg * 474706f2543Smrg * If the parameter is for all screens (appears before 475706f2543Smrg * any -screen option), store it in the default screen 476706f2543Smrg * info 477706f2543Smrg * 478706f2543Smrg * If the parameter is for a single screen (appears 479706f2543Smrg * after a -screen option), store it in the screen info 480706f2543Smrg * for that screen 481706f2543Smrg * 482706f2543Smrg */ 483706f2543Smrg if (iLastScreen == -1) 484706f2543Smrg { 485706f2543Smrg screenInfoPtr = &defaultScreenInfo; 486706f2543Smrg } 487706f2543Smrg else 488706f2543Smrg { 489706f2543Smrg screenInfoPtr = &(g_ScreenInfo[iLastScreen]); 490706f2543Smrg } 491706f2543Smrg 492706f2543Smrg /* 493706f2543Smrg * Look for the '-engine n' argument 494706f2543Smrg */ 495706f2543Smrg if (IS_OPTION ("-engine")) 496706f2543Smrg { 497706f2543Smrg DWORD dwEngine = 0; 498706f2543Smrg CARD8 c8OnBits = 0; 499706f2543Smrg 500706f2543Smrg /* Display the usage message if the argument is malformed */ 501706f2543Smrg if (++i >= argc) 502706f2543Smrg { 503706f2543Smrg UseMsg (); 504706f2543Smrg return 0; 505706f2543Smrg } 506706f2543Smrg 507706f2543Smrg /* Grab the argument */ 508706f2543Smrg dwEngine = atoi (argv[i]); 509706f2543Smrg 510706f2543Smrg /* Count the one bits in the engine argument */ 511706f2543Smrg c8OnBits = winCountBits (dwEngine); 512706f2543Smrg 513706f2543Smrg /* Argument should only have a single bit on */ 514706f2543Smrg if (c8OnBits != 1) 515706f2543Smrg { 516706f2543Smrg UseMsg (); 517706f2543Smrg return 0; 518706f2543Smrg } 519706f2543Smrg 520706f2543Smrg screenInfoPtr->dwEnginePreferred = dwEngine; 521706f2543Smrg 522706f2543Smrg /* Indicate that we have processed the argument */ 523706f2543Smrg return 2; 524706f2543Smrg } 525706f2543Smrg 526706f2543Smrg /* 527706f2543Smrg * Look for the '-fullscreen' argument 528706f2543Smrg */ 529706f2543Smrg if (IS_OPTION ("-fullscreen")) 530706f2543Smrg { 531706f2543Smrg#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 532706f2543Smrg if (!screenInfoPtr->fMultiMonitorOverride) 533706f2543Smrg screenInfoPtr->fMultipleMonitors = FALSE; 534706f2543Smrg#endif 535706f2543Smrg screenInfoPtr->fFullScreen = TRUE; 536706f2543Smrg 537706f2543Smrg /* Indicate that we have processed this argument */ 538706f2543Smrg return 1; 539706f2543Smrg } 540706f2543Smrg 541706f2543Smrg /* 542706f2543Smrg * Look for the '-lesspointer' argument 543706f2543Smrg */ 544706f2543Smrg if (IS_OPTION ("-lesspointer")) 545706f2543Smrg { 546706f2543Smrg screenInfoPtr->fLessPointer = TRUE; 547706f2543Smrg 548706f2543Smrg /* Indicate that we have processed this argument */ 549706f2543Smrg return 1; 550706f2543Smrg } 551706f2543Smrg 552706f2543Smrg /* 553706f2543Smrg * Look for the '-nodecoration' argument 554706f2543Smrg */ 555706f2543Smrg if (IS_OPTION ("-nodecoration")) 556706f2543Smrg { 557706f2543Smrg#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 558706f2543Smrg if (!screenInfoPtr->fMultiMonitorOverride) 559706f2543Smrg screenInfoPtr->fMultipleMonitors = FALSE; 560706f2543Smrg#endif 561706f2543Smrg screenInfoPtr->fDecoration = FALSE; 562706f2543Smrg 563706f2543Smrg /* Indicate that we have processed this argument */ 564706f2543Smrg return 1; 565706f2543Smrg } 566706f2543Smrg 567706f2543Smrg#ifdef XWIN_MULTIWINDOWEXTWM 568706f2543Smrg /* 569706f2543Smrg * Look for the '-mwextwm' argument 570706f2543Smrg */ 571706f2543Smrg if (IS_OPTION ("-mwextwm")) 572706f2543Smrg { 573706f2543Smrg if (!screenInfoPtr->fMultiMonitorOverride) 574706f2543Smrg screenInfoPtr->fMultipleMonitors = TRUE; 575706f2543Smrg screenInfoPtr->fMWExtWM = TRUE; 576706f2543Smrg 577706f2543Smrg /* Indicate that we have processed this argument */ 578706f2543Smrg return 1; 579706f2543Smrg } 580706f2543Smrg /* 581706f2543Smrg * Look for the '-internalwm' argument 582706f2543Smrg */ 583706f2543Smrg if (IS_OPTION ("-internalwm")) 584706f2543Smrg { 585706f2543Smrg if (!screenInfoPtr->fMultiMonitorOverride) 586706f2543Smrg screenInfoPtr->fMultipleMonitors = TRUE; 587706f2543Smrg screenInfoPtr->fMWExtWM = TRUE; 588706f2543Smrg screenInfoPtr->fInternalWM = TRUE; 589706f2543Smrg 590706f2543Smrg /* Indicate that we have processed this argument */ 591706f2543Smrg return 1; 592706f2543Smrg } 593706f2543Smrg#endif 594706f2543Smrg 595706f2543Smrg /* 596706f2543Smrg * Look for the '-rootless' argument 597706f2543Smrg */ 598706f2543Smrg if (IS_OPTION ("-rootless")) 599706f2543Smrg { 600706f2543Smrg#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 601706f2543Smrg if (!screenInfoPtr->fMultiMonitorOverride) 602706f2543Smrg screenInfoPtr->fMultipleMonitors = FALSE; 603706f2543Smrg#endif 604706f2543Smrg screenInfoPtr->fRootless = TRUE; 605706f2543Smrg 606706f2543Smrg /* Indicate that we have processed this argument */ 607706f2543Smrg return 1; 608706f2543Smrg } 609706f2543Smrg 610706f2543Smrg#ifdef XWIN_MULTIWINDOW 611706f2543Smrg /* 612706f2543Smrg * Look for the '-multiwindow' argument 613706f2543Smrg */ 614706f2543Smrg if (IS_OPTION ("-multiwindow")) 615706f2543Smrg { 616706f2543Smrg#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 617706f2543Smrg if (!screenInfoPtr->fMultiMonitorOverride) 618706f2543Smrg screenInfoPtr->fMultipleMonitors = TRUE; 619706f2543Smrg#endif 620706f2543Smrg screenInfoPtr->fMultiWindow = TRUE; 621706f2543Smrg 622706f2543Smrg /* Indicate that we have processed this argument */ 623706f2543Smrg return 1; 624706f2543Smrg } 625706f2543Smrg#endif 626706f2543Smrg 627706f2543Smrg /* 628706f2543Smrg * Look for the '-multiplemonitors' argument 629706f2543Smrg */ 630706f2543Smrg if (IS_OPTION ("-multiplemonitors") 631706f2543Smrg || IS_OPTION ("-multimonitors")) 632706f2543Smrg { 633706f2543Smrg#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 634706f2543Smrg screenInfoPtr->fMultiMonitorOverride = TRUE; 635706f2543Smrg#endif 636706f2543Smrg screenInfoPtr->fMultipleMonitors = TRUE; 637706f2543Smrg 638706f2543Smrg /* Indicate that we have processed this argument */ 639706f2543Smrg return 1; 640706f2543Smrg } 641706f2543Smrg 642706f2543Smrg /* 643706f2543Smrg * Look for the '-nomultiplemonitors' argument 644706f2543Smrg */ 645706f2543Smrg if (IS_OPTION ("-nomultiplemonitors") 646706f2543Smrg || IS_OPTION ("-nomultimonitors")) 647706f2543Smrg { 648706f2543Smrg#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) 649706f2543Smrg screenInfoPtr->fMultiMonitorOverride = TRUE; 650706f2543Smrg#endif 651706f2543Smrg screenInfoPtr->fMultipleMonitors = FALSE; 652706f2543Smrg 653706f2543Smrg /* Indicate that we have processed this argument */ 654706f2543Smrg return 1; 655706f2543Smrg } 656706f2543Smrg 657706f2543Smrg 658706f2543Smrg /* 659706f2543Smrg * Look for the '-scrollbars' argument 660706f2543Smrg */ 661706f2543Smrg if (IS_OPTION ("-scrollbars")) 662706f2543Smrg { 663706f2543Smrg 664706f2543Smrg screenInfoPtr->iResizeMode = resizeWithScrollbars; 665706f2543Smrg 666706f2543Smrg /* Indicate that we have processed this argument */ 667706f2543Smrg return 1; 668706f2543Smrg } 669706f2543Smrg 670706f2543Smrg /* 671706f2543Smrg * Look for the '-resize' argument 672706f2543Smrg */ 673706f2543Smrg if (IS_OPTION ("-resize") || IS_OPTION ("-noresize") || 674706f2543Smrg (strncmp(argv[i], "-resize=",strlen("-resize=")) == 0)) 675706f2543Smrg { 676706f2543Smrg winResizeMode mode; 677706f2543Smrg 678706f2543Smrg if (IS_OPTION ("-resize")) 679706f2543Smrg mode = resizeWithRandr; 680706f2543Smrg else if (IS_OPTION ("-noresize")) 681706f2543Smrg mode = notAllowed; 682706f2543Smrg else if (strncmp(argv[i], "-resize=",strlen("-resize=")) == 0) 683706f2543Smrg { 684706f2543Smrg char *option = argv[i] + strlen("-resize="); 685706f2543Smrg if (strcmp(option, "randr") == 0) 686706f2543Smrg mode = resizeWithRandr; 687706f2543Smrg else if (strcmp(option, "scrollbars") == 0) 688706f2543Smrg mode = resizeWithScrollbars; 689706f2543Smrg else if (strcmp(option, "none") == 0) 690706f2543Smrg mode = notAllowed; 691706f2543Smrg else 692706f2543Smrg { 693706f2543Smrg ErrorF ("ddxProcessArgument - resize - Invalid resize mode %s\n", option); 694706f2543Smrg return 0; 695706f2543Smrg } 696706f2543Smrg } 697706f2543Smrg else 698706f2543Smrg { 699706f2543Smrg ErrorF ("ddxProcessArgument - resize - Invalid resize option %s\n", argv[i]); 700706f2543Smrg return 0; 701706f2543Smrg } 702706f2543Smrg 703706f2543Smrg screenInfoPtr->iResizeMode = mode; 704706f2543Smrg 705706f2543Smrg /* Indicate that we have processed this argument */ 706706f2543Smrg return 1; 707706f2543Smrg } 708706f2543Smrg 709706f2543Smrg#ifdef XWIN_CLIPBOARD 710706f2543Smrg /* 711706f2543Smrg * Look for the '-clipboard' argument 712706f2543Smrg */ 713706f2543Smrg if (IS_OPTION ("-clipboard")) 714706f2543Smrg { 715706f2543Smrg /* Now the default, we still accept the arg for backwards compatibility */ 716706f2543Smrg g_fClipboard = TRUE; 717706f2543Smrg 718706f2543Smrg /* Indicate that we have processed this argument */ 719706f2543Smrg return 1; 720706f2543Smrg } 721706f2543Smrg 722706f2543Smrg /* 723706f2543Smrg * Look for the '-noclipboard' argument 724706f2543Smrg */ 725706f2543Smrg if (IS_OPTION ("-noclipboard")) 726706f2543Smrg { 727706f2543Smrg g_fClipboard = FALSE; 728706f2543Smrg 729706f2543Smrg /* Indicate that we have processed this argument */ 730706f2543Smrg return 1; 731706f2543Smrg } 732706f2543Smrg#endif 733706f2543Smrg 734706f2543Smrg 735706f2543Smrg /* 736706f2543Smrg * Look for the '-ignoreinput' argument 737706f2543Smrg */ 738706f2543Smrg if (IS_OPTION ("-ignoreinput")) 739706f2543Smrg { 740706f2543Smrg screenInfoPtr->fIgnoreInput = TRUE; 741706f2543Smrg 742706f2543Smrg /* Indicate that we have processed this argument */ 743706f2543Smrg return 1; 744706f2543Smrg } 745706f2543Smrg 746706f2543Smrg /* 747706f2543Smrg * Look for the '-emulate3buttons' argument 748706f2543Smrg */ 749706f2543Smrg if (IS_OPTION ("-emulate3buttons")) 750706f2543Smrg { 751706f2543Smrg int iArgsProcessed = 1; 752706f2543Smrg int iE3BTimeout = WIN_DEFAULT_E3B_TIME; 753706f2543Smrg 754706f2543Smrg /* Grab the optional timeout value */ 755706f2543Smrg if (i + 1 < argc 756706f2543Smrg && 1 == sscanf (argv[i + 1], "%d", 757706f2543Smrg &iE3BTimeout)) 758706f2543Smrg { 759706f2543Smrg /* Indicate that we have processed the next argument */ 760706f2543Smrg iArgsProcessed++; 761706f2543Smrg } 762706f2543Smrg else 763706f2543Smrg { 764706f2543Smrg /* 765706f2543Smrg * sscanf () won't modify iE3BTimeout if it doesn't find 766706f2543Smrg * the specified format; however, I want to be explicit 767706f2543Smrg * about setting the default timeout in such cases to 768706f2543Smrg * prevent some programs (me) from getting confused. 769706f2543Smrg */ 770706f2543Smrg iE3BTimeout = WIN_DEFAULT_E3B_TIME; 771706f2543Smrg } 772706f2543Smrg 773706f2543Smrg screenInfoPtr->iE3BTimeout = iE3BTimeout; 774706f2543Smrg 775706f2543Smrg /* Indicate that we have processed this argument */ 776706f2543Smrg return iArgsProcessed; 777706f2543Smrg } 778706f2543Smrg 779706f2543Smrg /* 780706f2543Smrg * Look for the '-depth n' argument 781706f2543Smrg */ 782706f2543Smrg if (IS_OPTION ("-depth")) 783706f2543Smrg { 784706f2543Smrg DWORD dwBPP = 0; 785706f2543Smrg 786706f2543Smrg /* Display the usage message if the argument is malformed */ 787706f2543Smrg if (++i >= argc) 788706f2543Smrg { 789706f2543Smrg UseMsg (); 790706f2543Smrg return 0; 791706f2543Smrg } 792706f2543Smrg 793706f2543Smrg /* Grab the argument */ 794706f2543Smrg dwBPP = atoi (argv[i]); 795706f2543Smrg 796706f2543Smrg screenInfoPtr->dwBPP = dwBPP; 797706f2543Smrg 798706f2543Smrg /* Indicate that we have processed the argument */ 799706f2543Smrg return 2; 800706f2543Smrg } 801706f2543Smrg 802706f2543Smrg /* 803706f2543Smrg * Look for the '-refresh n' argument 804706f2543Smrg */ 805706f2543Smrg if (IS_OPTION ("-refresh")) 806706f2543Smrg { 807706f2543Smrg DWORD dwRefreshRate = 0; 808706f2543Smrg 809706f2543Smrg /* Display the usage message if the argument is malformed */ 810706f2543Smrg if (++i >= argc) 811706f2543Smrg { 812706f2543Smrg UseMsg (); 813706f2543Smrg return 0; 814706f2543Smrg } 815706f2543Smrg 816706f2543Smrg /* Grab the argument */ 817706f2543Smrg dwRefreshRate = atoi (argv[i]); 818706f2543Smrg 819706f2543Smrg screenInfoPtr->dwRefreshRate = dwRefreshRate; 820706f2543Smrg 821706f2543Smrg /* Indicate that we have processed the argument */ 822706f2543Smrg return 2; 823706f2543Smrg } 824706f2543Smrg 825706f2543Smrg /* 826706f2543Smrg * Look for the '-clipupdates num_boxes' argument 827706f2543Smrg */ 828706f2543Smrg if (IS_OPTION ("-clipupdates")) 829706f2543Smrg { 830706f2543Smrg DWORD dwNumBoxes = 0; 831706f2543Smrg 832706f2543Smrg /* Display the usage message if the argument is malformed */ 833706f2543Smrg if (++i >= argc) 834706f2543Smrg { 835706f2543Smrg UseMsg (); 836706f2543Smrg return 0; 837706f2543Smrg } 838706f2543Smrg 839706f2543Smrg /* Grab the argument */ 840706f2543Smrg dwNumBoxes = atoi (argv[i]); 841706f2543Smrg 842706f2543Smrg screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes; 843706f2543Smrg 844706f2543Smrg /* Indicate that we have processed the argument */ 845706f2543Smrg return 2; 846706f2543Smrg } 847706f2543Smrg 848706f2543Smrg#ifdef XWIN_EMULATEPSEUDO 849706f2543Smrg /* 850706f2543Smrg * Look for the '-emulatepseudo' argument 851706f2543Smrg */ 852706f2543Smrg if (IS_OPTION ("-emulatepseudo")) 853706f2543Smrg { 854706f2543Smrg screenInfoPtr->fEmulatePseudo = TRUE; 855706f2543Smrg 856706f2543Smrg /* Indicate that we have processed this argument */ 857706f2543Smrg return 1; 858706f2543Smrg } 859706f2543Smrg#endif 860706f2543Smrg 861706f2543Smrg /* 862706f2543Smrg * Look for the '-nowinkill' argument 863706f2543Smrg */ 864706f2543Smrg if (IS_OPTION ("-nowinkill")) 865706f2543Smrg { 866706f2543Smrg screenInfoPtr->fUseWinKillKey = FALSE; 867706f2543Smrg 868706f2543Smrg /* Indicate that we have processed this argument */ 869706f2543Smrg return 1; 870706f2543Smrg } 871706f2543Smrg 872706f2543Smrg /* 873706f2543Smrg * Look for the '-winkill' argument 874706f2543Smrg */ 875706f2543Smrg if (IS_OPTION ("-winkill")) 876706f2543Smrg { 877706f2543Smrg screenInfoPtr->fUseWinKillKey = TRUE; 878706f2543Smrg 879706f2543Smrg /* Indicate that we have processed this argument */ 880706f2543Smrg return 1; 881706f2543Smrg } 882706f2543Smrg 883706f2543Smrg /* 884706f2543Smrg * Look for the '-nounixkill' argument 885706f2543Smrg */ 886706f2543Smrg if (IS_OPTION ("-nounixkill")) 887706f2543Smrg { 888706f2543Smrg screenInfoPtr->fUseUnixKillKey = FALSE; 889706f2543Smrg 890706f2543Smrg /* Indicate that we have processed this argument */ 891706f2543Smrg return 1; 892706f2543Smrg } 893706f2543Smrg 894706f2543Smrg /* 895706f2543Smrg * Look for the '-unixkill' argument 896706f2543Smrg */ 897706f2543Smrg if (IS_OPTION ("-unixkill")) 898706f2543Smrg { 899706f2543Smrg screenInfoPtr->fUseUnixKillKey = TRUE; 900706f2543Smrg 901706f2543Smrg /* Indicate that we have processed this argument */ 902706f2543Smrg return 1; 903706f2543Smrg } 904706f2543Smrg 905706f2543Smrg /* 906706f2543Smrg * Look for the '-notrayicon' argument 907706f2543Smrg */ 908706f2543Smrg if (IS_OPTION ("-notrayicon")) 909706f2543Smrg { 910706f2543Smrg screenInfoPtr->fNoTrayIcon = TRUE; 911706f2543Smrg 912706f2543Smrg /* Indicate that we have processed this argument */ 913706f2543Smrg return 1; 914706f2543Smrg } 915706f2543Smrg 916706f2543Smrg /* 917706f2543Smrg * Look for the '-trayicon' argument 918706f2543Smrg */ 919706f2543Smrg if (IS_OPTION ("-trayicon")) 920706f2543Smrg { 921706f2543Smrg screenInfoPtr->fNoTrayIcon = FALSE; 922706f2543Smrg 923706f2543Smrg /* Indicate that we have processed this argument */ 924706f2543Smrg return 1; 925706f2543Smrg } 926706f2543Smrg 927706f2543Smrg /* 928706f2543Smrg * Look for the '-fp' argument 929706f2543Smrg */ 930706f2543Smrg if (IS_OPTION ("-fp")) 931706f2543Smrg { 932706f2543Smrg CHECK_ARGS (1); 933706f2543Smrg g_cmdline.fontPath = argv[++i]; 934706f2543Smrg return 0; /* Let DIX parse this again */ 935706f2543Smrg } 936706f2543Smrg 937706f2543Smrg /* 938706f2543Smrg * Look for the '-query' argument 939706f2543Smrg */ 940706f2543Smrg if (IS_OPTION ("-query")) 941706f2543Smrg { 942706f2543Smrg CHECK_ARGS (1); 943706f2543Smrg g_fXdmcpEnabled = TRUE; 944706f2543Smrg g_pszQueryHost = argv[++i]; 945706f2543Smrg return 0; /* Let DIX parse this again */ 946706f2543Smrg } 947706f2543Smrg 948706f2543Smrg /* 949706f2543Smrg * Look for the '-auth' argument 950706f2543Smrg */ 951706f2543Smrg if (IS_OPTION ("-auth")) 952706f2543Smrg { 953706f2543Smrg g_fAuthEnabled = TRUE; 954706f2543Smrg return 0; /* Let DIX parse this again */ 955706f2543Smrg } 956706f2543Smrg 957706f2543Smrg /* 958706f2543Smrg * Look for the '-indirect' or '-broadcast' arguments 959706f2543Smrg */ 960706f2543Smrg if (IS_OPTION ("-indirect") 961706f2543Smrg || IS_OPTION ("-broadcast")) 962706f2543Smrg { 963706f2543Smrg g_fXdmcpEnabled = TRUE; 964706f2543Smrg return 0; /* Let DIX parse this again */ 965706f2543Smrg } 966706f2543Smrg 967706f2543Smrg /* 968706f2543Smrg * Look for the '-config' argument 969706f2543Smrg */ 970706f2543Smrg if (IS_OPTION ("-config") 971706f2543Smrg || IS_OPTION ("-xf86config")) 972706f2543Smrg { 973706f2543Smrg CHECK_ARGS (1); 974706f2543Smrg#ifdef XWIN_XF86CONFIG 975706f2543Smrg g_cmdline.configFile = argv[++i]; 976706f2543Smrg#else 977706f2543Smrg winMessageBoxF ("The %s option is not supported in this " 978706f2543Smrg "release.\n" 979706f2543Smrg "Ignoring this option and continuing.\n", 980706f2543Smrg MB_ICONINFORMATION, 981706f2543Smrg argv[i]); 982706f2543Smrg#endif 983706f2543Smrg return 2; 984706f2543Smrg } 985706f2543Smrg 986706f2543Smrg /* 987706f2543Smrg * Look for the '-configdir' argument 988706f2543Smrg */ 989706f2543Smrg if (IS_OPTION ("-configdir")) 990706f2543Smrg { 991706f2543Smrg CHECK_ARGS (1); 992706f2543Smrg#ifdef XWIN_XF86CONFIG 993706f2543Smrg g_cmdline.configDir = argv[++i]; 994706f2543Smrg#else 995706f2543Smrg winMessageBoxF ("The %s option is not supported in this " 996706f2543Smrg "release.\n" 997706f2543Smrg "Ignoring this option and continuing.\n", 998706f2543Smrg MB_ICONINFORMATION, 999706f2543Smrg argv[i]); 1000706f2543Smrg#endif 1001706f2543Smrg return 2; 1002706f2543Smrg } 1003706f2543Smrg 1004706f2543Smrg /* 1005706f2543Smrg * Look for the '-keyboard' argument 1006706f2543Smrg */ 1007706f2543Smrg if (IS_OPTION ("-keyboard")) 1008706f2543Smrg { 1009706f2543Smrg#ifdef XWIN_XF86CONFIG 1010706f2543Smrg CHECK_ARGS (1); 1011706f2543Smrg g_cmdline.keyboard = argv[++i]; 1012706f2543Smrg#else 1013706f2543Smrg winMessageBoxF ("The -keyboard option is not supported in this " 1014706f2543Smrg "release.\n" 1015706f2543Smrg "Ignoring this option and continuing.\n", 1016706f2543Smrg MB_ICONINFORMATION); 1017706f2543Smrg#endif 1018706f2543Smrg return 2; 1019706f2543Smrg } 1020706f2543Smrg 1021706f2543Smrg /* 1022706f2543Smrg * Look for the '-logfile' argument 1023706f2543Smrg */ 1024706f2543Smrg if (IS_OPTION ("-logfile")) 1025706f2543Smrg { 1026706f2543Smrg CHECK_ARGS (1); 1027706f2543Smrg g_pszLogFile = argv[++i]; 1028706f2543Smrg#ifdef RELOCATE_PROJECTROOT 1029706f2543Smrg g_fLogFileChanged = TRUE; 1030706f2543Smrg#endif 1031706f2543Smrg return 2; 1032706f2543Smrg } 1033706f2543Smrg 1034706f2543Smrg /* 1035706f2543Smrg * Look for the '-logverbose' argument 1036706f2543Smrg */ 1037706f2543Smrg if (IS_OPTION ("-logverbose")) 1038706f2543Smrg { 1039706f2543Smrg CHECK_ARGS (1); 1040706f2543Smrg g_iLogVerbose = atoi(argv[++i]); 1041706f2543Smrg return 2; 1042706f2543Smrg } 1043706f2543Smrg 1044706f2543Smrg#ifdef XWIN_CLIPBOARD 1045706f2543Smrg /* 1046706f2543Smrg * Look for the '-nounicodeclipboard' argument 1047706f2543Smrg */ 1048706f2543Smrg if (IS_OPTION ("-nounicodeclipboard")) 1049706f2543Smrg { 1050706f2543Smrg g_fUnicodeClipboard = FALSE; 1051706f2543Smrg /* Indicate that we have processed the argument */ 1052706f2543Smrg return 1; 1053706f2543Smrg } 1054706f2543Smrg#endif 1055706f2543Smrg 1056706f2543Smrg if (IS_OPTION ("-xkbrules")) 1057706f2543Smrg { 1058706f2543Smrg CHECK_ARGS (1); 1059706f2543Smrg g_cmdline.xkbRules = argv[++i]; 1060706f2543Smrg return 2; 1061706f2543Smrg } 1062706f2543Smrg if (IS_OPTION ("-xkbmodel")) 1063706f2543Smrg { 1064706f2543Smrg CHECK_ARGS (1); 1065706f2543Smrg g_cmdline.xkbModel = argv[++i]; 1066706f2543Smrg return 2; 1067706f2543Smrg } 1068706f2543Smrg if (IS_OPTION ("-xkblayout")) 1069706f2543Smrg { 1070706f2543Smrg CHECK_ARGS (1); 1071706f2543Smrg g_cmdline.xkbLayout = argv[++i]; 1072706f2543Smrg return 2; 1073706f2543Smrg } 1074706f2543Smrg if (IS_OPTION ("-xkbvariant")) 1075706f2543Smrg { 1076706f2543Smrg CHECK_ARGS (1); 1077706f2543Smrg g_cmdline.xkbVariant = argv[++i]; 1078706f2543Smrg return 2; 1079706f2543Smrg } 1080706f2543Smrg if (IS_OPTION ("-xkboptions")) 1081706f2543Smrg { 1082706f2543Smrg CHECK_ARGS (1); 1083706f2543Smrg g_cmdline.xkbOptions = argv[++i]; 1084706f2543Smrg return 2; 1085706f2543Smrg } 1086706f2543Smrg 1087706f2543Smrg if (IS_OPTION ("-keyhook")) 1088706f2543Smrg { 1089706f2543Smrg g_fKeyboardHookLL = TRUE; 1090706f2543Smrg return 1; 1091706f2543Smrg } 1092706f2543Smrg 1093706f2543Smrg if (IS_OPTION ("-nokeyhook")) 1094706f2543Smrg { 1095706f2543Smrg g_fKeyboardHookLL = FALSE; 1096706f2543Smrg return 1; 1097706f2543Smrg } 1098706f2543Smrg 1099706f2543Smrg if (IS_OPTION ("-swcursor")) 1100706f2543Smrg { 1101706f2543Smrg g_fSoftwareCursor = TRUE; 1102706f2543Smrg return 1; 1103706f2543Smrg } 1104706f2543Smrg 1105706f2543Smrg if (IS_OPTION ("-silent-dup-error")) 1106706f2543Smrg { 1107706f2543Smrg g_fSilentDupError = TRUE; 1108706f2543Smrg return 1; 1109706f2543Smrg } 1110706f2543Smrg 1111706f2543Smrg if (IS_OPTION("-wgl")) 1112706f2543Smrg { 1113706f2543Smrg g_fNativeGl = TRUE; 1114706f2543Smrg return 1; 1115706f2543Smrg } 1116706f2543Smrg 1117706f2543Smrg if (IS_OPTION("-nowgl")) 1118706f2543Smrg { 1119706f2543Smrg g_fNativeGl = FALSE; 1120706f2543Smrg return 1; 1121706f2543Smrg } 1122706f2543Smrg 1123706f2543Smrg return 0; 1124706f2543Smrg} 1125706f2543Smrg 1126706f2543Smrg 1127706f2543Smrg/* 1128706f2543Smrg * winLogCommandLine - Write entire command line to the log file 1129706f2543Smrg */ 1130706f2543Smrg 1131706f2543Smrgvoid 1132706f2543SmrgwinLogCommandLine (int argc, char *argv[]) 1133706f2543Smrg{ 1134706f2543Smrg int i; 1135706f2543Smrg int iSize = 0; 1136706f2543Smrg int iCurrLen = 0; 1137706f2543Smrg 1138706f2543Smrg#define CHARS_PER_LINE 60 1139706f2543Smrg 1140706f2543Smrg /* Bail if command line has already been logged */ 1141706f2543Smrg if (g_pszCommandLine) 1142706f2543Smrg return; 1143706f2543Smrg 1144706f2543Smrg /* Count how much memory is needed for concatenated command line */ 1145706f2543Smrg for (i = 0, iCurrLen = 0; i < argc; ++i) 1146706f2543Smrg if (argv[i]) 1147706f2543Smrg { 1148706f2543Smrg /* Adds two characters for lines that overflow */ 1149706f2543Smrg if ((strlen (argv[i]) < CHARS_PER_LINE 1150706f2543Smrg && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE) 1151706f2543Smrg || strlen (argv[i]) > CHARS_PER_LINE) 1152706f2543Smrg { 1153706f2543Smrg iCurrLen = 0; 1154706f2543Smrg iSize += 2; 1155706f2543Smrg } 1156706f2543Smrg 1157706f2543Smrg /* Add space for item and trailing space */ 1158706f2543Smrg iSize += strlen (argv[i]) + 1; 1159706f2543Smrg 1160706f2543Smrg /* Update current line length */ 1161706f2543Smrg iCurrLen += strlen (argv[i]); 1162706f2543Smrg } 1163706f2543Smrg 1164706f2543Smrg /* Allocate memory for concatenated command line */ 1165706f2543Smrg g_pszCommandLine = malloc (iSize + 1); 1166706f2543Smrg if (!g_pszCommandLine) 1167706f2543Smrg FatalError ("winLogCommandLine - Could not allocate memory for " 1168706f2543Smrg "command line string. Exiting.\n"); 1169706f2543Smrg 1170706f2543Smrg /* Set first character to concatenated command line to null */ 1171706f2543Smrg g_pszCommandLine[0] = '\0'; 1172706f2543Smrg 1173706f2543Smrg /* Loop through all args */ 1174706f2543Smrg for (i = 0, iCurrLen = 0; i < argc; ++i) 1175706f2543Smrg { 1176706f2543Smrg /* Add a character for lines that overflow */ 1177706f2543Smrg if ((strlen (argv[i]) < CHARS_PER_LINE 1178706f2543Smrg && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE) 1179706f2543Smrg || strlen (argv[i]) > CHARS_PER_LINE) 1180706f2543Smrg { 1181706f2543Smrg iCurrLen = 0; 1182706f2543Smrg 1183706f2543Smrg /* Add line break if it fits */ 1184706f2543Smrg strncat (g_pszCommandLine, "\n ", iSize - strlen (g_pszCommandLine)); 1185706f2543Smrg } 1186706f2543Smrg 1187706f2543Smrg strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine)); 1188706f2543Smrg strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine)); 1189706f2543Smrg 1190706f2543Smrg /* Save new line length */ 1191706f2543Smrg iCurrLen += strlen (argv[i]); 1192706f2543Smrg } 1193706f2543Smrg 1194706f2543Smrg ErrorF ("XWin was started with the following command line:\n\n" 1195706f2543Smrg "%s\n\n", g_pszCommandLine); 1196706f2543Smrg} 1197706f2543Smrg 1198706f2543Smrg 1199706f2543Smrg/* 1200706f2543Smrg * winLogVersionInfo - Log Cygwin/X version information 1201706f2543Smrg */ 1202706f2543Smrg 1203706f2543Smrgvoid 1204706f2543SmrgwinLogVersionInfo (void) 1205706f2543Smrg{ 1206706f2543Smrg static Bool s_fBeenHere = FALSE; 1207706f2543Smrg 1208706f2543Smrg if (s_fBeenHere) 1209706f2543Smrg return; 1210706f2543Smrg s_fBeenHere = TRUE; 1211706f2543Smrg 1212706f2543Smrg ErrorF ("Welcome to the XWin X Server\n"); 1213706f2543Smrg ErrorF ("Vendor: %s\n", XVENDORNAME); 1214706f2543Smrg ErrorF ("Release: %d.%d.%d.%d (%d)\n", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT); 1215706f2543Smrg ErrorF ("%s\n\n", BUILDERSTRING); 1216706f2543Smrg ErrorF ("Contact: %s\n", BUILDERADDR); 1217706f2543Smrg} 1218