105b261ecSmrg/* 205b261ecSmrg 305b261ecSmrgCopyright 1993, 1998 The Open Group 46747b715SmrgCopyright (C) Colin Harrison 2005-2008 505b261ecSmrg 605b261ecSmrgPermission to use, copy, modify, distribute, and sell this software and its 705b261ecSmrgdocumentation for any purpose is hereby granted without fee, provided that 805b261ecSmrgthe above copyright notice appear in all copies and that both that 905b261ecSmrgcopyright notice and this permission notice appear in supporting 1005b261ecSmrgdocumentation. 1105b261ecSmrg 1205b261ecSmrgThe above copyright notice and this permission notice shall be included 1305b261ecSmrgin all copies or substantial portions of the Software. 1405b261ecSmrg 1505b261ecSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1605b261ecSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1705b261ecSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 1805b261ecSmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 1905b261ecSmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2005b261ecSmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2105b261ecSmrgOTHER DEALINGS IN THE SOFTWARE. 2205b261ecSmrg 2305b261ecSmrgExcept as contained in this notice, the name of The Open Group shall 2405b261ecSmrgnot be used in advertising or otherwise to promote the sale, use or 2505b261ecSmrgother dealings in this Software without prior written authorization 2605b261ecSmrgfrom The Open Group. 2705b261ecSmrg 2805b261ecSmrg*/ 2905b261ecSmrg 3005b261ecSmrg#ifdef HAVE_XWIN_CONFIG_H 3105b261ecSmrg#include <xwin-config.h> 3205b261ecSmrg#endif 339ace9065Smrg 3435c4bbdfSmrg#ifdef HAVE_SYS_UTSNAME_H 3535c4bbdfSmrg#include <sys/utsname.h> 3635c4bbdfSmrg#endif 3735c4bbdfSmrg 386747b715Smrg#include <../xfree86/common/xorgVersion.h> 3905b261ecSmrg#include "win.h" 4005b261ecSmrg#include "winconfig.h" 4105b261ecSmrg#include "winmsg.h" 429ace9065Smrg#include "winmonitors.h" 43ed6184dfSmrg#include "winprefs.h" 4405b261ecSmrg 4535c4bbdfSmrg#include "winclipboard/winclipboard.h" 4605b261ecSmrg 4705b261ecSmrg/* 4805b261ecSmrg * Function prototypes 4905b261ecSmrg */ 5005b261ecSmrg 5105b261ecSmrgvoid 5235c4bbdfSmrg winLogCommandLine(int argc, char *argv[]); 5305b261ecSmrg 5405b261ecSmrgvoid 5535c4bbdfSmrg winLogVersionInfo(void); 5605b261ecSmrg 5705b261ecSmrg/* 5805b261ecSmrg * Process arguments on the command line 5905b261ecSmrg */ 6005b261ecSmrg 616747b715Smrgstatic int iLastScreen = -1; 626747b715Smrgstatic winScreenInfo defaultScreenInfo; 636747b715Smrg 646747b715Smrgstatic void 656747b715SmrgwinInitializeScreenDefaults(void) 6605b261ecSmrg{ 6735c4bbdfSmrg DWORD dwWidth, dwHeight; 6835c4bbdfSmrg static Bool fInitializedScreenDefaults = FALSE; 6935c4bbdfSmrg 7035c4bbdfSmrg /* Bail out early if default screen has already been initialized */ 7135c4bbdfSmrg if (fInitializedScreenDefaults) 7235c4bbdfSmrg return; 7335c4bbdfSmrg 7435c4bbdfSmrg /* Zero the memory used for storing the screen info */ 7535c4bbdfSmrg memset(&defaultScreenInfo, 0, sizeof(winScreenInfo)); 7635c4bbdfSmrg 7735c4bbdfSmrg /* Get default width and height */ 7835c4bbdfSmrg /* 7935c4bbdfSmrg * NOTE: These defaults will cause the window to cover only 8035c4bbdfSmrg * the primary monitor in the case that we have multiple monitors. 8135c4bbdfSmrg */ 8235c4bbdfSmrg dwWidth = GetSystemMetrics(SM_CXSCREEN); 8335c4bbdfSmrg dwHeight = GetSystemMetrics(SM_CYSCREEN); 8435c4bbdfSmrg 8535c4bbdfSmrg winErrorFVerb(2, 8635c4bbdfSmrg "winInitializeScreenDefaults - primary monitor w %d h %d\n", 8735c4bbdfSmrg (int) dwWidth, (int) dwHeight); 8835c4bbdfSmrg 8935c4bbdfSmrg /* Set a default DPI, if no '-dpi' option was used */ 9035c4bbdfSmrg if (monitorResolution == 0) { 9135c4bbdfSmrg HDC hdc = GetDC(NULL); 9235c4bbdfSmrg 9335c4bbdfSmrg if (hdc) { 9435c4bbdfSmrg int dpiX = GetDeviceCaps(hdc, LOGPIXELSX); 9535c4bbdfSmrg int dpiY = GetDeviceCaps(hdc, LOGPIXELSY); 9635c4bbdfSmrg 9735c4bbdfSmrg winErrorFVerb(2, 9835c4bbdfSmrg "winInitializeScreenDefaults - native DPI x %d y %d\n", 9935c4bbdfSmrg dpiX, dpiY); 10035c4bbdfSmrg 10135c4bbdfSmrg monitorResolution = dpiY; 10235c4bbdfSmrg ReleaseDC(NULL, hdc); 10335c4bbdfSmrg } 10435c4bbdfSmrg else { 10535c4bbdfSmrg winErrorFVerb(1, 10635c4bbdfSmrg "winInitializeScreenDefaults - Failed to retrieve native DPI, falling back to default of %d DPI\n", 10735c4bbdfSmrg WIN_DEFAULT_DPI); 10835c4bbdfSmrg monitorResolution = WIN_DEFAULT_DPI; 10935c4bbdfSmrg } 11035c4bbdfSmrg } 11135c4bbdfSmrg 11235c4bbdfSmrg defaultScreenInfo.iMonitor = 1; 11335c4bbdfSmrg defaultScreenInfo.hMonitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY); 11435c4bbdfSmrg defaultScreenInfo.dwWidth = dwWidth; 11535c4bbdfSmrg defaultScreenInfo.dwHeight = dwHeight; 11635c4bbdfSmrg defaultScreenInfo.dwUserWidth = dwWidth; 11735c4bbdfSmrg defaultScreenInfo.dwUserHeight = dwHeight; 11835c4bbdfSmrg defaultScreenInfo.fUserGaveHeightAndWidth = 11935c4bbdfSmrg WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH; 12035c4bbdfSmrg defaultScreenInfo.fUserGavePosition = FALSE; 12135c4bbdfSmrg defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP; 12235c4bbdfSmrg defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES; 12305b261ecSmrg#ifdef XWIN_EMULATEPSEUDO 12435c4bbdfSmrg defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; 12505b261ecSmrg#endif 12635c4bbdfSmrg defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH; 12735c4bbdfSmrg defaultScreenInfo.pfb = NULL; 12835c4bbdfSmrg defaultScreenInfo.fFullScreen = FALSE; 12935c4bbdfSmrg defaultScreenInfo.fDecoration = TRUE; 13035c4bbdfSmrg defaultScreenInfo.fRootless = FALSE; 13135c4bbdfSmrg defaultScreenInfo.fMultiWindow = FALSE; 132ed6184dfSmrg defaultScreenInfo.fCompositeWM = TRUE; 13335c4bbdfSmrg defaultScreenInfo.fMultiMonitorOverride = FALSE; 13435c4bbdfSmrg defaultScreenInfo.fMultipleMonitors = FALSE; 13535c4bbdfSmrg defaultScreenInfo.fLessPointer = FALSE; 1361b5d61b8Smrg defaultScreenInfo.iResizeMode = resizeDefault; 13735c4bbdfSmrg defaultScreenInfo.fNoTrayIcon = FALSE; 13835c4bbdfSmrg defaultScreenInfo.iE3BTimeout = WIN_E3B_DEFAULT; 13935c4bbdfSmrg defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL; 14035c4bbdfSmrg defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL; 14135c4bbdfSmrg defaultScreenInfo.fIgnoreInput = FALSE; 14235c4bbdfSmrg defaultScreenInfo.fExplicitScreen = FALSE; 143ed6184dfSmrg defaultScreenInfo.hIcon = (HICON) 144ed6184dfSmrg LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, 145ed6184dfSmrg GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0); 146ed6184dfSmrg defaultScreenInfo.hIconSm = (HICON) 147ed6184dfSmrg LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, 148ed6184dfSmrg GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 149ed6184dfSmrg LR_DEFAULTSIZE); 15035c4bbdfSmrg 15135c4bbdfSmrg /* Note that the default screen has been initialized */ 15235c4bbdfSmrg fInitializedScreenDefaults = TRUE; 1536747b715Smrg} 15405b261ecSmrg 1556747b715Smrgstatic void 1566747b715SmrgwinInitializeScreen(int i) 1576747b715Smrg{ 15835c4bbdfSmrg winErrorFVerb(3, "winInitializeScreen - %d\n", i); 15905b261ecSmrg 16035c4bbdfSmrg /* Initialize default screen values, if needed */ 16135c4bbdfSmrg winInitializeScreenDefaults(); 1626747b715Smrg 16335c4bbdfSmrg /* Copy the default screen info */ 16435c4bbdfSmrg g_ScreenInfo[i] = defaultScreenInfo; 1656747b715Smrg 16635c4bbdfSmrg /* Set the screen number */ 16735c4bbdfSmrg g_ScreenInfo[i].dwScreen = i; 1686747b715Smrg} 1696747b715Smrg 1706747b715Smrgvoid 1716747b715SmrgwinInitializeScreens(int maxscreens) 1726747b715Smrg{ 17335c4bbdfSmrg int i; 1746747b715Smrg 17535c4bbdfSmrg winErrorFVerb(3, "winInitializeScreens - %i\n", maxscreens); 17635c4bbdfSmrg 17735c4bbdfSmrg if (maxscreens > g_iNumScreens) { 17835c4bbdfSmrg /* Reallocate the memory for DDX-specific screen info */ 17935c4bbdfSmrg g_ScreenInfo = 18035c4bbdfSmrg realloc(g_ScreenInfo, maxscreens * sizeof(winScreenInfo)); 1816747b715Smrg 18235c4bbdfSmrg /* Set default values for any new screens */ 18335c4bbdfSmrg for (i = g_iNumScreens; i < maxscreens; i++) 18435c4bbdfSmrg winInitializeScreen(i); 1856747b715Smrg 18635c4bbdfSmrg /* Keep a count of the number of screens */ 18735c4bbdfSmrg g_iNumScreens = maxscreens; 1886747b715Smrg } 18905b261ecSmrg} 19005b261ecSmrg 19105b261ecSmrg/* See Porting Layer Definition - p. 57 */ 19205b261ecSmrg/* 19305b261ecSmrg * INPUT 19405b261ecSmrg * argv: pointer to an array of null-terminated strings, one for 19505b261ecSmrg * each token in the X Server command line; the first token 19605b261ecSmrg * is 'XWin.exe', or similar. 19705b261ecSmrg * argc: a count of the number of tokens stored in argv. 19805b261ecSmrg * i: a zero-based index into argv indicating the current token being 19905b261ecSmrg * processed. 20005b261ecSmrg * 20105b261ecSmrg * OUTPUT 20205b261ecSmrg * return: return the number of tokens processed correctly. 20305b261ecSmrg * 20405b261ecSmrg * NOTE 20505b261ecSmrg * When looking for n tokens, check that i + n is less than argc. Or, 20605b261ecSmrg * you may check if i is greater than or equal to argc, in which case 20705b261ecSmrg * you should display the UseMsg () and return 0. 20805b261ecSmrg */ 20905b261ecSmrg 21005b261ecSmrg/* Check if enough arguments are given for the option */ 21105b261ecSmrg#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; } 21205b261ecSmrg 21335c4bbdfSmrg/* Compare the current option with the string. */ 21405b261ecSmrg#define IS_OPTION(name) (strcmp (argv[i], name) == 0) 21505b261ecSmrg 21605b261ecSmrgint 21735c4bbdfSmrgddxProcessArgument(int argc, char *argv[], int i) 21805b261ecSmrg{ 21935c4bbdfSmrg static Bool s_fBeenHere = FALSE; 22035c4bbdfSmrg winScreenInfo *screenInfoPtr = NULL; 22105b261ecSmrg 22235c4bbdfSmrg /* Initialize once */ 22335c4bbdfSmrg if (!s_fBeenHere) { 22405b261ecSmrg#ifdef DDXOSVERRORF 22535c4bbdfSmrg /* 22635c4bbdfSmrg * This initialises our hook into VErrorF () for catching log messages 22735c4bbdfSmrg * that are generated before OsInit () is called. 22835c4bbdfSmrg */ 22935c4bbdfSmrg OsVendorVErrorFProc = OsVendorVErrorF; 23005b261ecSmrg#endif 23105b261ecSmrg 23235c4bbdfSmrg s_fBeenHere = TRUE; 23305b261ecSmrg 23435c4bbdfSmrg /* Initialize only if option is not -help */ 23535c4bbdfSmrg if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") && 23635c4bbdfSmrg !IS_OPTION("-version") && !IS_OPTION("--version")) { 23705b261ecSmrg 23835c4bbdfSmrg /* Log the version information */ 23935c4bbdfSmrg winLogVersionInfo(); 24005b261ecSmrg 24135c4bbdfSmrg /* Log the command line */ 24235c4bbdfSmrg winLogCommandLine(argc, argv); 24305b261ecSmrg 24435c4bbdfSmrg /* 24535c4bbdfSmrg * Initialize default screen settings. We have to do this before 24635c4bbdfSmrg * OsVendorInit () gets called, otherwise we will overwrite 24735c4bbdfSmrg * settings changed by parameters such as -fullscreen, etc. 24835c4bbdfSmrg */ 2491b5d61b8Smrg winErrorFVerb(3, "ddxProcessArgument - Initializing default " 25035c4bbdfSmrg "screens\n"); 25135c4bbdfSmrg winInitializeScreenDefaults(); 25235c4bbdfSmrg } 25305b261ecSmrg } 25405b261ecSmrg 25505b261ecSmrg#if CYGDEBUG 25635c4bbdfSmrg winDebug("ddxProcessArgument - arg: %s\n", argv[i]); 25705b261ecSmrg#endif 25805b261ecSmrg 25935c4bbdfSmrg /* 26035c4bbdfSmrg * Look for the '-help' and similar options 26135c4bbdfSmrg */ 26235c4bbdfSmrg if (IS_OPTION("-help") || IS_OPTION("-h") || IS_OPTION("--help")) { 26335c4bbdfSmrg /* Reset logfile. We don't need that helpmessage in the logfile */ 26435c4bbdfSmrg g_pszLogFile = NULL; 26535c4bbdfSmrg g_fNoHelpMessageBox = TRUE; 26635c4bbdfSmrg UseMsg(); 26735c4bbdfSmrg exit(0); 26835c4bbdfSmrg return 1; 26905b261ecSmrg } 27005b261ecSmrg 27135c4bbdfSmrg if (IS_OPTION("-version") || IS_OPTION("--version")) { 27235c4bbdfSmrg /* Reset logfile. We don't need that versioninfo in the logfile */ 27335c4bbdfSmrg g_pszLogFile = NULL; 27435c4bbdfSmrg winLogVersionInfo(); 27535c4bbdfSmrg exit(0); 27635c4bbdfSmrg return 1; 27705b261ecSmrg } 27805b261ecSmrg 27935c4bbdfSmrg /* 28035c4bbdfSmrg * Look for the '-screen scr_num [width height]' argument 28135c4bbdfSmrg */ 28235c4bbdfSmrg if (IS_OPTION("-screen")) { 28335c4bbdfSmrg int iArgsProcessed = 1; 28435c4bbdfSmrg int nScreenNum; 28535c4bbdfSmrg int iWidth, iHeight, iX, iY; 28635c4bbdfSmrg int iMonitor; 28705b261ecSmrg 28805b261ecSmrg#if CYGDEBUG 28935c4bbdfSmrg winDebug("ddxProcessArgument - screen - argc: %d i: %d\n", argc, i); 29005b261ecSmrg#endif 29105b261ecSmrg 29235c4bbdfSmrg /* Display the usage message if the argument is malformed */ 29335c4bbdfSmrg if (i + 1 >= argc) { 29435c4bbdfSmrg return 0; 29505b261ecSmrg } 29605b261ecSmrg 29735c4bbdfSmrg /* Grab screen number */ 29835c4bbdfSmrg nScreenNum = atoi(argv[i + 1]); 29905b261ecSmrg 30035c4bbdfSmrg /* Validate the specified screen number */ 30135c4bbdfSmrg if (nScreenNum < 0) { 30235c4bbdfSmrg ErrorF("ddxProcessArgument - screen - Invalid screen number %d\n", 30335c4bbdfSmrg nScreenNum); 30435c4bbdfSmrg UseMsg(); 30535c4bbdfSmrg return 0; 30635c4bbdfSmrg } 3076747b715Smrg 30835c4bbdfSmrg /* 30935c4bbdfSmrg Initialize default values for any new screens 31035c4bbdfSmrg 31135c4bbdfSmrg Note that default values can't change after a -screen option is 31235c4bbdfSmrg seen, so it's safe to do this for each screen as it is introduced 31335c4bbdfSmrg */ 31435c4bbdfSmrg winInitializeScreens(nScreenNum + 1); 31535c4bbdfSmrg 31635c4bbdfSmrg /* look for @m where m is monitor number */ 31735c4bbdfSmrg if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) { 31835c4bbdfSmrg struct GetMonitorInfoData data; 31935c4bbdfSmrg 320ed6184dfSmrg if (QueryMonitor(iMonitor, &data)) { 32135c4bbdfSmrg winErrorFVerb(2, 32235c4bbdfSmrg "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", 32335c4bbdfSmrg iMonitor); 32435c4bbdfSmrg iArgsProcessed = 3; 32535c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 32635c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 32735c4bbdfSmrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 32835c4bbdfSmrg g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; 32935c4bbdfSmrg g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth; 33035c4bbdfSmrg g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight; 33135c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth; 33235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight; 33335c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 33435c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 33535c4bbdfSmrg } 33635c4bbdfSmrg else { 33735c4bbdfSmrg /* monitor does not exist, error out */ 33835c4bbdfSmrg ErrorF 33935c4bbdfSmrg ("ddxProcessArgument - screen - Invalid monitor number %d\n", 34035c4bbdfSmrg iMonitor); 341ed6184dfSmrg exit(1); 34235c4bbdfSmrg return 0; 34335c4bbdfSmrg } 34435c4bbdfSmrg } 34535c4bbdfSmrg 34635c4bbdfSmrg /* Look for 'WxD' or 'W D' */ 34735c4bbdfSmrg else if (i + 2 < argc 34835c4bbdfSmrg && 2 == sscanf(argv[i + 2], "%dx%d", 34935c4bbdfSmrg (int *) &iWidth, (int *) &iHeight)) { 35035c4bbdfSmrg winErrorFVerb(2, 35135c4bbdfSmrg "ddxProcessArgument - screen - Found ``WxD'' arg\n"); 35235c4bbdfSmrg iArgsProcessed = 3; 35335c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 35435c4bbdfSmrg g_ScreenInfo[nScreenNum].dwWidth = iWidth; 35535c4bbdfSmrg g_ScreenInfo[nScreenNum].dwHeight = iHeight; 35635c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 35735c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 35835c4bbdfSmrg /* Look for WxD+X+Y */ 35935c4bbdfSmrg if (2 == sscanf(argv[i + 2], "%*dx%*d+%d+%d", 36035c4bbdfSmrg (int *) &iX, (int *) &iY)) { 36135c4bbdfSmrg winErrorFVerb(2, 36235c4bbdfSmrg "ddxProcessArgument - screen - Found ``X+Y'' arg\n"); 36335c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 36435c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = iX; 36535c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = iY; 36635c4bbdfSmrg 36735c4bbdfSmrg /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */ 36835c4bbdfSmrg if (1 == sscanf(argv[i + 2], "%*dx%*d+%*d+%*d@%d", 36935c4bbdfSmrg (int *) &iMonitor)) { 37035c4bbdfSmrg struct GetMonitorInfoData data; 37135c4bbdfSmrg 372ed6184dfSmrg if (QueryMonitor(iMonitor, &data)) { 37335c4bbdfSmrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 37435c4bbdfSmrg g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; 37535c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX += 37635c4bbdfSmrg data.monitorOffsetX; 37735c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY += 37835c4bbdfSmrg data.monitorOffsetY; 37935c4bbdfSmrg } 38035c4bbdfSmrg else { 38135c4bbdfSmrg /* monitor does not exist, error out */ 38235c4bbdfSmrg ErrorF 38335c4bbdfSmrg ("ddxProcessArgument - screen - Invalid monitor number %d\n", 38435c4bbdfSmrg iMonitor); 385ed6184dfSmrg exit(1); 38635c4bbdfSmrg return 0; 38735c4bbdfSmrg } 38835c4bbdfSmrg } 38935c4bbdfSmrg } 39035c4bbdfSmrg 39135c4bbdfSmrg /* look for WxD@m where m is monitor number */ 39235c4bbdfSmrg else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", (int *) &iMonitor)) { 39335c4bbdfSmrg struct GetMonitorInfoData data; 39435c4bbdfSmrg 395ed6184dfSmrg if (QueryMonitor(iMonitor, &data)) { 39635c4bbdfSmrg winErrorFVerb(2, 39735c4bbdfSmrg "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", 39835c4bbdfSmrg iMonitor); 39935c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 40035c4bbdfSmrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 40135c4bbdfSmrg g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; 40235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 40335c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 40435c4bbdfSmrg } 40535c4bbdfSmrg else { 40635c4bbdfSmrg /* monitor does not exist, error out */ 40735c4bbdfSmrg ErrorF 40835c4bbdfSmrg ("ddxProcessArgument - screen - Invalid monitor number %d\n", 40935c4bbdfSmrg iMonitor); 410ed6184dfSmrg exit(1); 41135c4bbdfSmrg return 0; 41235c4bbdfSmrg } 41335c4bbdfSmrg } 41435c4bbdfSmrg } 41535c4bbdfSmrg else if (i + 3 < argc && 1 == sscanf(argv[i + 2], "%d", (int *) &iWidth) 41635c4bbdfSmrg && 1 == sscanf(argv[i + 3], "%d", (int *) &iHeight)) { 41735c4bbdfSmrg winErrorFVerb(2, 41835c4bbdfSmrg "ddxProcessArgument - screen - Found ``W D'' arg\n"); 41935c4bbdfSmrg iArgsProcessed = 4; 42035c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 42135c4bbdfSmrg g_ScreenInfo[nScreenNum].dwWidth = iWidth; 42235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwHeight = iHeight; 42335c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 42435c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 42535c4bbdfSmrg if (i + 5 < argc && 1 == sscanf(argv[i + 4], "%d", (int *) &iX) 42635c4bbdfSmrg && 1 == sscanf(argv[i + 5], "%d", (int *) &iY)) { 42735c4bbdfSmrg winErrorFVerb(2, 42835c4bbdfSmrg "ddxProcessArgument - screen - Found ``X Y'' arg\n"); 42935c4bbdfSmrg iArgsProcessed = 6; 43035c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 43135c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = iX; 43235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = iY; 43335c4bbdfSmrg } 43435c4bbdfSmrg } 43535c4bbdfSmrg else { 43635c4bbdfSmrg winErrorFVerb(2, 43735c4bbdfSmrg "ddxProcessArgument - screen - Did not find size arg. " 43835c4bbdfSmrg "dwWidth: %d dwHeight: %d\n", 43935c4bbdfSmrg (int) g_ScreenInfo[nScreenNum].dwWidth, 44035c4bbdfSmrg (int) g_ScreenInfo[nScreenNum].dwHeight); 44135c4bbdfSmrg iArgsProcessed = 2; 44235c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 44335c4bbdfSmrg } 44435c4bbdfSmrg 445ed6184dfSmrg /* Flag that this screen was explicitly specified by the user */ 44635c4bbdfSmrg g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE; 44735c4bbdfSmrg 44835c4bbdfSmrg /* 44935c4bbdfSmrg * Keep track of the last screen number seen, as parameters seen 45035c4bbdfSmrg * before a screen number apply to all screens, whereas parameters 45135c4bbdfSmrg * seen after a screen number apply to that screen number only. 45235c4bbdfSmrg */ 45335c4bbdfSmrg iLastScreen = nScreenNum; 45435c4bbdfSmrg 45535c4bbdfSmrg return iArgsProcessed; 4566747b715Smrg } 45735c4bbdfSmrg 45835c4bbdfSmrg /* 45935c4bbdfSmrg * Is this parameter attached to a screen or global? 46035c4bbdfSmrg * 46135c4bbdfSmrg * If the parameter is for all screens (appears before 46235c4bbdfSmrg * any -screen option), store it in the default screen 46335c4bbdfSmrg * info 46435c4bbdfSmrg * 46535c4bbdfSmrg * If the parameter is for a single screen (appears 46635c4bbdfSmrg * after a -screen option), store it in the screen info 46735c4bbdfSmrg * for that screen 46835c4bbdfSmrg * 46935c4bbdfSmrg */ 47035c4bbdfSmrg if (iLastScreen == -1) { 47135c4bbdfSmrg screenInfoPtr = &defaultScreenInfo; 47235c4bbdfSmrg } 47335c4bbdfSmrg else { 47435c4bbdfSmrg screenInfoPtr = &(g_ScreenInfo[iLastScreen]); 4756747b715Smrg } 4766747b715Smrg 47735c4bbdfSmrg /* 47835c4bbdfSmrg * Look for the '-engine n' argument 47935c4bbdfSmrg */ 48035c4bbdfSmrg if (IS_OPTION("-engine")) { 48135c4bbdfSmrg DWORD dwEngine = 0; 48235c4bbdfSmrg CARD8 c8OnBits = 0; 48335c4bbdfSmrg 48435c4bbdfSmrg /* Display the usage message if the argument is malformed */ 48535c4bbdfSmrg if (++i >= argc) { 48635c4bbdfSmrg UseMsg(); 48735c4bbdfSmrg return 0; 48835c4bbdfSmrg } 48935c4bbdfSmrg 49035c4bbdfSmrg /* Grab the argument */ 49135c4bbdfSmrg dwEngine = atoi(argv[i]); 49235c4bbdfSmrg 49335c4bbdfSmrg /* Count the one bits in the engine argument */ 49435c4bbdfSmrg c8OnBits = winCountBits(dwEngine); 49535c4bbdfSmrg 49635c4bbdfSmrg /* Argument should only have a single bit on */ 49735c4bbdfSmrg if (c8OnBits != 1) { 49835c4bbdfSmrg UseMsg(); 49935c4bbdfSmrg return 0; 50035c4bbdfSmrg } 50135c4bbdfSmrg 50235c4bbdfSmrg screenInfoPtr->dwEnginePreferred = dwEngine; 50335c4bbdfSmrg 50435c4bbdfSmrg /* Indicate that we have processed the argument */ 50535c4bbdfSmrg return 2; 50605b261ecSmrg } 50705b261ecSmrg 50835c4bbdfSmrg /* 50935c4bbdfSmrg * Look for the '-fullscreen' argument 51035c4bbdfSmrg */ 51135c4bbdfSmrg if (IS_OPTION("-fullscreen")) { 51235c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 5136747b715Smrg screenInfoPtr->fMultipleMonitors = FALSE; 51435c4bbdfSmrg screenInfoPtr->fFullScreen = TRUE; 51505b261ecSmrg 51635c4bbdfSmrg /* Indicate that we have processed this argument */ 51735c4bbdfSmrg return 1; 51805b261ecSmrg } 51905b261ecSmrg 52035c4bbdfSmrg /* 52135c4bbdfSmrg * Look for the '-lesspointer' argument 52235c4bbdfSmrg */ 52335c4bbdfSmrg if (IS_OPTION("-lesspointer")) { 52435c4bbdfSmrg screenInfoPtr->fLessPointer = TRUE; 52505b261ecSmrg 52635c4bbdfSmrg /* Indicate that we have processed this argument */ 52735c4bbdfSmrg return 1; 52805b261ecSmrg } 52905b261ecSmrg 53035c4bbdfSmrg /* 53135c4bbdfSmrg * Look for the '-nodecoration' argument 53235c4bbdfSmrg */ 53335c4bbdfSmrg if (IS_OPTION("-nodecoration")) { 53435c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 53535c4bbdfSmrg screenInfoPtr->fMultipleMonitors = FALSE; 53635c4bbdfSmrg screenInfoPtr->fDecoration = FALSE; 53705b261ecSmrg 53835c4bbdfSmrg /* Indicate that we have processed this argument */ 53935c4bbdfSmrg return 1; 54005b261ecSmrg } 54105b261ecSmrg 54235c4bbdfSmrg /* 543ed6184dfSmrg * Look for the '-rootless' argument 54435c4bbdfSmrg */ 545ed6184dfSmrg if (IS_OPTION("-rootless")) { 54635c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 547ed6184dfSmrg screenInfoPtr->fMultipleMonitors = FALSE; 548ed6184dfSmrg screenInfoPtr->fRootless = TRUE; 54935c4bbdfSmrg 55035c4bbdfSmrg /* Indicate that we have processed this argument */ 55135c4bbdfSmrg return 1; 55205b261ecSmrg } 553ed6184dfSmrg 55435c4bbdfSmrg /* 555ed6184dfSmrg * Look for the '-multiwindow' argument 55635c4bbdfSmrg */ 557ed6184dfSmrg if (IS_OPTION("-multiwindow")) { 558ed6184dfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 559ed6184dfSmrg screenInfoPtr->fMultipleMonitors = TRUE; 560ed6184dfSmrg screenInfoPtr->fMultiWindow = TRUE; 561ed6184dfSmrg 56235c4bbdfSmrg /* Indicate that we have processed this argument */ 56335c4bbdfSmrg return 1; 56405b261ecSmrg } 56505b261ecSmrg 56635c4bbdfSmrg /* 567ed6184dfSmrg * Look for the '-compositewm' argument 56835c4bbdfSmrg */ 569ed6184dfSmrg if (IS_OPTION("-compositewm")) { 570ed6184dfSmrg screenInfoPtr->fCompositeWM = TRUE; 571ed6184dfSmrg 572ed6184dfSmrg /* Indicate that we have processed this argument */ 573ed6184dfSmrg return 1; 574ed6184dfSmrg } 575ed6184dfSmrg /* 576ed6184dfSmrg * Look for the '-nocompositewm' argument 577ed6184dfSmrg */ 578ed6184dfSmrg if (IS_OPTION("-nocompositewm")) { 579ed6184dfSmrg screenInfoPtr->fCompositeWM = FALSE; 58005b261ecSmrg 58135c4bbdfSmrg /* Indicate that we have processed this argument */ 58235c4bbdfSmrg return 1; 58305b261ecSmrg } 58405b261ecSmrg 58535c4bbdfSmrg /* 586ed6184dfSmrg * Look for the '-compositealpha' argument 58735c4bbdfSmrg */ 588ed6184dfSmrg if (IS_OPTION("-compositealpha")) { 589ed6184dfSmrg g_fCompositeAlpha = TRUE; 590ed6184dfSmrg 591ed6184dfSmrg /* Indicate that we have processed this argument */ 592ed6184dfSmrg return 1; 593ed6184dfSmrg } 594ed6184dfSmrg /* 595ed6184dfSmrg * Look for the '-nocompositealpha' argument 596ed6184dfSmrg */ 597ed6184dfSmrg if (IS_OPTION("-nocompositealpha")) { 598ed6184dfSmrg g_fCompositeAlpha = FALSE; 59905b261ecSmrg 60035c4bbdfSmrg /* Indicate that we have processed this argument */ 60135c4bbdfSmrg return 1; 60205b261ecSmrg } 60305b261ecSmrg 60435c4bbdfSmrg /* 60535c4bbdfSmrg * Look for the '-multiplemonitors' argument 60635c4bbdfSmrg */ 60735c4bbdfSmrg if (IS_OPTION("-multiplemonitors") 60835c4bbdfSmrg || IS_OPTION("-multimonitors")) { 60935c4bbdfSmrg screenInfoPtr->fMultiMonitorOverride = TRUE; 61035c4bbdfSmrg screenInfoPtr->fMultipleMonitors = TRUE; 61105b261ecSmrg 61235c4bbdfSmrg /* Indicate that we have processed this argument */ 61335c4bbdfSmrg return 1; 61405b261ecSmrg } 61505b261ecSmrg 61635c4bbdfSmrg /* 61735c4bbdfSmrg * Look for the '-nomultiplemonitors' argument 61835c4bbdfSmrg */ 61935c4bbdfSmrg if (IS_OPTION("-nomultiplemonitors") 62035c4bbdfSmrg || IS_OPTION("-nomultimonitors")) { 62135c4bbdfSmrg screenInfoPtr->fMultiMonitorOverride = TRUE; 62235c4bbdfSmrg screenInfoPtr->fMultipleMonitors = FALSE; 62305b261ecSmrg 62435c4bbdfSmrg /* Indicate that we have processed this argument */ 62535c4bbdfSmrg return 1; 62605b261ecSmrg } 62705b261ecSmrg 62835c4bbdfSmrg /* 62935c4bbdfSmrg * Look for the '-scrollbars' argument 63035c4bbdfSmrg */ 63135c4bbdfSmrg if (IS_OPTION("-scrollbars")) { 63205b261ecSmrg 63335c4bbdfSmrg screenInfoPtr->iResizeMode = resizeWithScrollbars; 63405b261ecSmrg 63535c4bbdfSmrg /* Indicate that we have processed this argument */ 63635c4bbdfSmrg return 1; 63705b261ecSmrg } 63805b261ecSmrg 63935c4bbdfSmrg /* 64035c4bbdfSmrg * Look for the '-resize' argument 64135c4bbdfSmrg */ 64235c4bbdfSmrg if (IS_OPTION("-resize") || IS_OPTION("-noresize") || 64335c4bbdfSmrg (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0)) { 64435c4bbdfSmrg winResizeMode mode; 64535c4bbdfSmrg 64635c4bbdfSmrg if (IS_OPTION("-resize")) 6479ace9065Smrg mode = resizeWithRandr; 64835c4bbdfSmrg else if (IS_OPTION("-noresize")) 6491b5d61b8Smrg mode = resizeNotAllowed; 65035c4bbdfSmrg else if (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0) { 65135c4bbdfSmrg char *option = argv[i] + strlen("-resize="); 65235c4bbdfSmrg 65335c4bbdfSmrg if (strcmp(option, "randr") == 0) 65435c4bbdfSmrg mode = resizeWithRandr; 65535c4bbdfSmrg else if (strcmp(option, "scrollbars") == 0) 65635c4bbdfSmrg mode = resizeWithScrollbars; 65735c4bbdfSmrg else if (strcmp(option, "none") == 0) 6581b5d61b8Smrg mode = resizeNotAllowed; 65935c4bbdfSmrg else { 66035c4bbdfSmrg ErrorF("ddxProcessArgument - resize - Invalid resize mode %s\n", 66135c4bbdfSmrg option); 66235c4bbdfSmrg return 0; 6639ace9065Smrg } 6649ace9065Smrg } 66535c4bbdfSmrg else { 66635c4bbdfSmrg ErrorF("ddxProcessArgument - resize - Invalid resize option %s\n", 66735c4bbdfSmrg argv[i]); 66835c4bbdfSmrg return 0; 6699ace9065Smrg } 6709ace9065Smrg 67135c4bbdfSmrg screenInfoPtr->iResizeMode = mode; 6729ace9065Smrg 67335c4bbdfSmrg /* Indicate that we have processed this argument */ 67435c4bbdfSmrg return 1; 6759ace9065Smrg } 67605b261ecSmrg 67735c4bbdfSmrg /* 67835c4bbdfSmrg * Look for the '-clipboard' argument 67935c4bbdfSmrg */ 68035c4bbdfSmrg if (IS_OPTION("-clipboard")) { 68135c4bbdfSmrg /* Now the default, we still accept the arg for backwards compatibility */ 68235c4bbdfSmrg g_fClipboard = TRUE; 68335c4bbdfSmrg 68435c4bbdfSmrg /* Indicate that we have processed this argument */ 68535c4bbdfSmrg return 1; 68635c4bbdfSmrg } 68735c4bbdfSmrg 68835c4bbdfSmrg /* 68935c4bbdfSmrg * Look for the '-noclipboard' argument 69035c4bbdfSmrg */ 69135c4bbdfSmrg if (IS_OPTION("-noclipboard")) { 69235c4bbdfSmrg g_fClipboard = FALSE; 69305b261ecSmrg 69435c4bbdfSmrg /* Indicate that we have processed this argument */ 69535c4bbdfSmrg return 1; 6966747b715Smrg } 6976747b715Smrg 69835c4bbdfSmrg /* 69935c4bbdfSmrg * Look for the '-primary' argument 70035c4bbdfSmrg */ 70135c4bbdfSmrg if (IS_OPTION("-primary")) { 70235c4bbdfSmrg fPrimarySelection = TRUE; 7036747b715Smrg 70435c4bbdfSmrg /* Indicate that we have processed this argument */ 70535c4bbdfSmrg return 1; 70605b261ecSmrg } 70705b261ecSmrg 70835c4bbdfSmrg /* 70935c4bbdfSmrg * Look for the '-noprimary' argument 71035c4bbdfSmrg */ 71135c4bbdfSmrg if (IS_OPTION("-noprimary")) { 71235c4bbdfSmrg fPrimarySelection = FALSE; 71305b261ecSmrg 71435c4bbdfSmrg /* Indicate that we have processed this argument */ 71535c4bbdfSmrg return 1; 71635c4bbdfSmrg } 71705b261ecSmrg 71835c4bbdfSmrg /* 71935c4bbdfSmrg * Look for the '-ignoreinput' argument 72035c4bbdfSmrg */ 72135c4bbdfSmrg if (IS_OPTION("-ignoreinput")) { 72235c4bbdfSmrg screenInfoPtr->fIgnoreInput = TRUE; 72335c4bbdfSmrg 72435c4bbdfSmrg /* Indicate that we have processed this argument */ 72535c4bbdfSmrg return 1; 72605b261ecSmrg } 72705b261ecSmrg 72835c4bbdfSmrg /* 72935c4bbdfSmrg * Look for the '-emulate3buttons' argument 73035c4bbdfSmrg */ 73135c4bbdfSmrg if (IS_OPTION("-emulate3buttons")) { 73235c4bbdfSmrg int iArgsProcessed = 1; 73335c4bbdfSmrg int iE3BTimeout = WIN_DEFAULT_E3B_TIME; 73435c4bbdfSmrg 73535c4bbdfSmrg /* Grab the optional timeout value */ 73635c4bbdfSmrg if (i + 1 < argc && 1 == sscanf(argv[i + 1], "%d", &iE3BTimeout)) { 73735c4bbdfSmrg /* Indicate that we have processed the next argument */ 73835c4bbdfSmrg iArgsProcessed++; 73935c4bbdfSmrg } 74035c4bbdfSmrg else { 74135c4bbdfSmrg /* 74235c4bbdfSmrg * sscanf () won't modify iE3BTimeout if it doesn't find 74335c4bbdfSmrg * the specified format; however, I want to be explicit 74435c4bbdfSmrg * about setting the default timeout in such cases to 74535c4bbdfSmrg * prevent some programs (me) from getting confused. 74635c4bbdfSmrg */ 74735c4bbdfSmrg iE3BTimeout = WIN_DEFAULT_E3B_TIME; 74805b261ecSmrg } 74935c4bbdfSmrg 75035c4bbdfSmrg screenInfoPtr->iE3BTimeout = iE3BTimeout; 75135c4bbdfSmrg 75235c4bbdfSmrg /* Indicate that we have processed this argument */ 75335c4bbdfSmrg return iArgsProcessed; 75405b261ecSmrg } 75505b261ecSmrg 75635c4bbdfSmrg /* 75735c4bbdfSmrg * Look for the '-noemulate3buttons' argument 75835c4bbdfSmrg */ 75935c4bbdfSmrg if (IS_OPTION("-noemulate3buttons")) { 76035c4bbdfSmrg screenInfoPtr->iE3BTimeout = WIN_E3B_OFF; 76135c4bbdfSmrg 76235c4bbdfSmrg /* Indicate that we have processed this argument */ 76335c4bbdfSmrg return 1; 76405b261ecSmrg } 76505b261ecSmrg 76635c4bbdfSmrg /* 76735c4bbdfSmrg * Look for the '-depth n' argument 76835c4bbdfSmrg */ 76935c4bbdfSmrg if (IS_OPTION("-depth")) { 77035c4bbdfSmrg DWORD dwBPP = 0; 77135c4bbdfSmrg 77235c4bbdfSmrg /* Display the usage message if the argument is malformed */ 77335c4bbdfSmrg if (++i >= argc) { 77435c4bbdfSmrg UseMsg(); 77535c4bbdfSmrg return 0; 77635c4bbdfSmrg } 77735c4bbdfSmrg 77835c4bbdfSmrg /* Grab the argument */ 77935c4bbdfSmrg dwBPP = atoi(argv[i]); 78035c4bbdfSmrg 78135c4bbdfSmrg screenInfoPtr->dwBPP = dwBPP; 78235c4bbdfSmrg 78335c4bbdfSmrg /* Indicate that we have processed the argument */ 78435c4bbdfSmrg return 2; 78505b261ecSmrg } 78605b261ecSmrg 78735c4bbdfSmrg /* 78835c4bbdfSmrg * Look for the '-refresh n' argument 78935c4bbdfSmrg */ 79035c4bbdfSmrg if (IS_OPTION("-refresh")) { 79135c4bbdfSmrg DWORD dwRefreshRate = 0; 79235c4bbdfSmrg 79335c4bbdfSmrg /* Display the usage message if the argument is malformed */ 79435c4bbdfSmrg if (++i >= argc) { 79535c4bbdfSmrg UseMsg(); 79635c4bbdfSmrg return 0; 79735c4bbdfSmrg } 79835c4bbdfSmrg 79935c4bbdfSmrg /* Grab the argument */ 80035c4bbdfSmrg dwRefreshRate = atoi(argv[i]); 80135c4bbdfSmrg 80235c4bbdfSmrg screenInfoPtr->dwRefreshRate = dwRefreshRate; 80335c4bbdfSmrg 80435c4bbdfSmrg /* Indicate that we have processed the argument */ 80535c4bbdfSmrg return 2; 80605b261ecSmrg } 80705b261ecSmrg 80835c4bbdfSmrg /* 80935c4bbdfSmrg * Look for the '-clipupdates num_boxes' argument 81035c4bbdfSmrg */ 81135c4bbdfSmrg if (IS_OPTION("-clipupdates")) { 81235c4bbdfSmrg DWORD dwNumBoxes = 0; 81335c4bbdfSmrg 81435c4bbdfSmrg /* Display the usage message if the argument is malformed */ 81535c4bbdfSmrg if (++i >= argc) { 81635c4bbdfSmrg UseMsg(); 81735c4bbdfSmrg return 0; 81835c4bbdfSmrg } 81905b261ecSmrg 82035c4bbdfSmrg /* Grab the argument */ 82135c4bbdfSmrg dwNumBoxes = atoi(argv[i]); 82235c4bbdfSmrg 82335c4bbdfSmrg screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes; 82435c4bbdfSmrg 82535c4bbdfSmrg /* Indicate that we have processed the argument */ 82635c4bbdfSmrg return 2; 82735c4bbdfSmrg } 82835c4bbdfSmrg 82935c4bbdfSmrg#ifdef XWIN_EMULATEPSEUDO 83035c4bbdfSmrg /* 83135c4bbdfSmrg * Look for the '-emulatepseudo' argument 83235c4bbdfSmrg */ 83335c4bbdfSmrg if (IS_OPTION("-emulatepseudo")) { 83435c4bbdfSmrg screenInfoPtr->fEmulatePseudo = TRUE; 83535c4bbdfSmrg 83635c4bbdfSmrg /* Indicate that we have processed this argument */ 83735c4bbdfSmrg return 1; 83805b261ecSmrg } 83905b261ecSmrg#endif 84005b261ecSmrg 84135c4bbdfSmrg /* 84235c4bbdfSmrg * Look for the '-nowinkill' argument 84335c4bbdfSmrg */ 84435c4bbdfSmrg if (IS_OPTION("-nowinkill")) { 84535c4bbdfSmrg screenInfoPtr->fUseWinKillKey = FALSE; 84605b261ecSmrg 84735c4bbdfSmrg /* Indicate that we have processed this argument */ 84835c4bbdfSmrg return 1; 84905b261ecSmrg } 85005b261ecSmrg 85135c4bbdfSmrg /* 85235c4bbdfSmrg * Look for the '-winkill' argument 85335c4bbdfSmrg */ 85435c4bbdfSmrg if (IS_OPTION("-winkill")) { 85535c4bbdfSmrg screenInfoPtr->fUseWinKillKey = TRUE; 85605b261ecSmrg 85735c4bbdfSmrg /* Indicate that we have processed this argument */ 85835c4bbdfSmrg return 1; 85905b261ecSmrg } 86005b261ecSmrg 86135c4bbdfSmrg /* 86235c4bbdfSmrg * Look for the '-nounixkill' argument 86335c4bbdfSmrg */ 86435c4bbdfSmrg if (IS_OPTION("-nounixkill")) { 86535c4bbdfSmrg screenInfoPtr->fUseUnixKillKey = FALSE; 86605b261ecSmrg 86735c4bbdfSmrg /* Indicate that we have processed this argument */ 86835c4bbdfSmrg return 1; 86905b261ecSmrg } 87005b261ecSmrg 87135c4bbdfSmrg /* 87235c4bbdfSmrg * Look for the '-unixkill' argument 87335c4bbdfSmrg */ 87435c4bbdfSmrg if (IS_OPTION("-unixkill")) { 87535c4bbdfSmrg screenInfoPtr->fUseUnixKillKey = TRUE; 87605b261ecSmrg 87735c4bbdfSmrg /* Indicate that we have processed this argument */ 87835c4bbdfSmrg return 1; 87905b261ecSmrg } 88005b261ecSmrg 88135c4bbdfSmrg /* 88235c4bbdfSmrg * Look for the '-notrayicon' argument 88335c4bbdfSmrg */ 88435c4bbdfSmrg if (IS_OPTION("-notrayicon")) { 88535c4bbdfSmrg screenInfoPtr->fNoTrayIcon = TRUE; 88605b261ecSmrg 88735c4bbdfSmrg /* Indicate that we have processed this argument */ 88835c4bbdfSmrg return 1; 88905b261ecSmrg } 89005b261ecSmrg 89135c4bbdfSmrg /* 89235c4bbdfSmrg * Look for the '-trayicon' argument 89335c4bbdfSmrg */ 89435c4bbdfSmrg if (IS_OPTION("-trayicon")) { 89535c4bbdfSmrg screenInfoPtr->fNoTrayIcon = FALSE; 89605b261ecSmrg 89735c4bbdfSmrg /* Indicate that we have processed this argument */ 89835c4bbdfSmrg return 1; 89905b261ecSmrg } 90005b261ecSmrg 90135c4bbdfSmrg /* 90235c4bbdfSmrg * Look for the '-fp' argument 90335c4bbdfSmrg */ 90435c4bbdfSmrg if (IS_OPTION("-fp")) { 90535c4bbdfSmrg CHECK_ARGS(1); 90635c4bbdfSmrg g_cmdline.fontPath = argv[++i]; 90735c4bbdfSmrg return 0; /* Let DIX parse this again */ 90805b261ecSmrg } 90905b261ecSmrg 91035c4bbdfSmrg /* 91135c4bbdfSmrg * Look for the '-query' argument 91235c4bbdfSmrg */ 91335c4bbdfSmrg if (IS_OPTION("-query")) { 91435c4bbdfSmrg CHECK_ARGS(1); 91535c4bbdfSmrg g_fXdmcpEnabled = TRUE; 91635c4bbdfSmrg g_pszQueryHost = argv[++i]; 91735c4bbdfSmrg return 0; /* Let DIX parse this again */ 91805b261ecSmrg } 91905b261ecSmrg 92035c4bbdfSmrg /* 92135c4bbdfSmrg * Look for the '-auth' argument 92235c4bbdfSmrg */ 92335c4bbdfSmrg if (IS_OPTION("-auth")) { 92435c4bbdfSmrg g_fAuthEnabled = TRUE; 92535c4bbdfSmrg return 0; /* Let DIX parse this again */ 9266747b715Smrg } 9276747b715Smrg 92835c4bbdfSmrg /* 92935c4bbdfSmrg * Look for the '-indirect' or '-broadcast' arguments 93035c4bbdfSmrg */ 93135c4bbdfSmrg if (IS_OPTION("-indirect") 93235c4bbdfSmrg || IS_OPTION("-broadcast")) { 93335c4bbdfSmrg g_fXdmcpEnabled = TRUE; 93435c4bbdfSmrg return 0; /* Let DIX parse this again */ 93505b261ecSmrg } 93605b261ecSmrg 93735c4bbdfSmrg /* 93835c4bbdfSmrg * Look for the '-config' argument 93935c4bbdfSmrg */ 94035c4bbdfSmrg if (IS_OPTION("-config") 94135c4bbdfSmrg || IS_OPTION("-xf86config")) { 94235c4bbdfSmrg CHECK_ARGS(1); 94305b261ecSmrg#ifdef XWIN_XF86CONFIG 94435c4bbdfSmrg g_cmdline.configFile = argv[++i]; 94505b261ecSmrg#else 94635c4bbdfSmrg winMessageBoxF("The %s option is not supported in this " 94735c4bbdfSmrg "release.\n" 94835c4bbdfSmrg "Ignoring this option and continuing.\n", 94935c4bbdfSmrg MB_ICONINFORMATION, argv[i]); 95005b261ecSmrg#endif 95135c4bbdfSmrg return 2; 95205b261ecSmrg } 95305b261ecSmrg 95435c4bbdfSmrg /* 95535c4bbdfSmrg * Look for the '-configdir' argument 95635c4bbdfSmrg */ 95735c4bbdfSmrg if (IS_OPTION("-configdir")) { 95835c4bbdfSmrg CHECK_ARGS(1); 9596747b715Smrg#ifdef XWIN_XF86CONFIG 96035c4bbdfSmrg g_cmdline.configDir = argv[++i]; 9616747b715Smrg#else 96235c4bbdfSmrg winMessageBoxF("The %s option is not supported in this " 96335c4bbdfSmrg "release.\n" 96435c4bbdfSmrg "Ignoring this option and continuing.\n", 96535c4bbdfSmrg MB_ICONINFORMATION, argv[i]); 9666747b715Smrg#endif 96735c4bbdfSmrg return 2; 9686747b715Smrg } 9696747b715Smrg 97035c4bbdfSmrg /* 97135c4bbdfSmrg * Look for the '-keyboard' argument 97235c4bbdfSmrg */ 97335c4bbdfSmrg if (IS_OPTION("-keyboard")) { 97405b261ecSmrg#ifdef XWIN_XF86CONFIG 97535c4bbdfSmrg CHECK_ARGS(1); 97635c4bbdfSmrg g_cmdline.keyboard = argv[++i]; 97705b261ecSmrg#else 97835c4bbdfSmrg winMessageBoxF("The -keyboard option is not supported in this " 97935c4bbdfSmrg "release.\n" 98035c4bbdfSmrg "Ignoring this option and continuing.\n", 98135c4bbdfSmrg MB_ICONINFORMATION); 98205b261ecSmrg#endif 98335c4bbdfSmrg return 2; 98405b261ecSmrg } 98505b261ecSmrg 98635c4bbdfSmrg /* 98735c4bbdfSmrg * Look for the '-logfile' argument 98835c4bbdfSmrg */ 98935c4bbdfSmrg if (IS_OPTION("-logfile")) { 99035c4bbdfSmrg CHECK_ARGS(1); 99135c4bbdfSmrg g_pszLogFile = argv[++i]; 99205b261ecSmrg#ifdef RELOCATE_PROJECTROOT 99335c4bbdfSmrg g_fLogFileChanged = TRUE; 99405b261ecSmrg#endif 99535c4bbdfSmrg return 2; 99605b261ecSmrg } 99705b261ecSmrg 99835c4bbdfSmrg /* 99935c4bbdfSmrg * Look for the '-logverbose' argument 100035c4bbdfSmrg */ 100135c4bbdfSmrg if (IS_OPTION("-logverbose")) { 100235c4bbdfSmrg CHECK_ARGS(1); 100335c4bbdfSmrg g_iLogVerbose = atoi(argv[++i]); 100435c4bbdfSmrg return 2; 100505b261ecSmrg } 100605b261ecSmrg 100735c4bbdfSmrg if (IS_OPTION("-xkbrules")) { 100835c4bbdfSmrg CHECK_ARGS(1); 100935c4bbdfSmrg g_cmdline.xkbRules = argv[++i]; 101035c4bbdfSmrg return 2; 101105b261ecSmrg } 101235c4bbdfSmrg if (IS_OPTION("-xkbmodel")) { 101335c4bbdfSmrg CHECK_ARGS(1); 101435c4bbdfSmrg g_cmdline.xkbModel = argv[++i]; 101535c4bbdfSmrg return 2; 101605b261ecSmrg } 101735c4bbdfSmrg if (IS_OPTION("-xkblayout")) { 101835c4bbdfSmrg CHECK_ARGS(1); 101935c4bbdfSmrg g_cmdline.xkbLayout = argv[++i]; 102035c4bbdfSmrg return 2; 102105b261ecSmrg } 102235c4bbdfSmrg if (IS_OPTION("-xkbvariant")) { 102335c4bbdfSmrg CHECK_ARGS(1); 102435c4bbdfSmrg g_cmdline.xkbVariant = argv[++i]; 102535c4bbdfSmrg return 2; 102605b261ecSmrg } 102735c4bbdfSmrg if (IS_OPTION("-xkboptions")) { 102835c4bbdfSmrg CHECK_ARGS(1); 102935c4bbdfSmrg g_cmdline.xkbOptions = argv[++i]; 103035c4bbdfSmrg return 2; 103105b261ecSmrg } 103205b261ecSmrg 103335c4bbdfSmrg if (IS_OPTION("-keyhook")) { 103435c4bbdfSmrg g_fKeyboardHookLL = TRUE; 103535c4bbdfSmrg return 1; 103605b261ecSmrg } 103735c4bbdfSmrg 103835c4bbdfSmrg if (IS_OPTION("-nokeyhook")) { 103935c4bbdfSmrg g_fKeyboardHookLL = FALSE; 104035c4bbdfSmrg return 1; 104105b261ecSmrg } 104235c4bbdfSmrg 104335c4bbdfSmrg if (IS_OPTION("-swcursor")) { 104435c4bbdfSmrg g_fSoftwareCursor = TRUE; 104535c4bbdfSmrg return 1; 104605b261ecSmrg } 104735c4bbdfSmrg 104835c4bbdfSmrg if (IS_OPTION("-wgl")) { 104935c4bbdfSmrg g_fNativeGl = TRUE; 105035c4bbdfSmrg return 1; 10516747b715Smrg } 10526747b715Smrg 105335c4bbdfSmrg if (IS_OPTION("-nowgl")) { 105435c4bbdfSmrg g_fNativeGl = FALSE; 105535c4bbdfSmrg return 1; 10566747b715Smrg } 10576747b715Smrg 105835c4bbdfSmrg if (IS_OPTION("-hostintitle")) { 105935c4bbdfSmrg g_fHostInTitle = TRUE; 106035c4bbdfSmrg return 1; 106135c4bbdfSmrg } 106205b261ecSmrg 106335c4bbdfSmrg if (IS_OPTION("-nohostintitle")) { 106435c4bbdfSmrg g_fHostInTitle = FALSE; 106535c4bbdfSmrg return 1; 106635c4bbdfSmrg } 106735c4bbdfSmrg 1068ed6184dfSmrg if (IS_OPTION("-icon")) { 1069ed6184dfSmrg char *iconspec; 1070ed6184dfSmrg CHECK_ARGS(1); 1071ed6184dfSmrg iconspec = argv[++i]; 1072ed6184dfSmrg screenInfoPtr->hIcon = LoadImageComma(iconspec, NULL, 1073ed6184dfSmrg GetSystemMetrics(SM_CXICON), 1074ed6184dfSmrg GetSystemMetrics(SM_CYICON), 1075ed6184dfSmrg 0); 1076ed6184dfSmrg screenInfoPtr->hIconSm = LoadImageComma(iconspec, NULL, 1077ed6184dfSmrg GetSystemMetrics(SM_CXSMICON), 1078ed6184dfSmrg GetSystemMetrics(SM_CYSMICON), 1079ed6184dfSmrg LR_DEFAULTSIZE); 1080ed6184dfSmrg if ((screenInfoPtr->hIcon == NULL) || 1081ed6184dfSmrg (screenInfoPtr->hIconSm == NULL)) { 1082ed6184dfSmrg ErrorF("ddxProcessArgument - icon - Invalid icon specification %s\n", 1083ed6184dfSmrg iconspec); 1084ed6184dfSmrg exit(1); 1085ed6184dfSmrg } 1086ed6184dfSmrg 1087ed6184dfSmrg /* Indicate that we have processed the argument */ 1088ed6184dfSmrg return 2; 1089ed6184dfSmrg } 1090ed6184dfSmrg 109135c4bbdfSmrg return 0; 109235c4bbdfSmrg} 109305b261ecSmrg 109405b261ecSmrg/* 109505b261ecSmrg * winLogCommandLine - Write entire command line to the log file 109605b261ecSmrg */ 109705b261ecSmrg 109805b261ecSmrgvoid 109935c4bbdfSmrgwinLogCommandLine(int argc, char *argv[]) 110005b261ecSmrg{ 110135c4bbdfSmrg int i; 110235c4bbdfSmrg int iSize = 0; 110335c4bbdfSmrg int iCurrLen = 0; 110405b261ecSmrg 110505b261ecSmrg#define CHARS_PER_LINE 60 110605b261ecSmrg 110735c4bbdfSmrg /* Bail if command line has already been logged */ 110835c4bbdfSmrg if (g_pszCommandLine) 110935c4bbdfSmrg return; 111035c4bbdfSmrg 111135c4bbdfSmrg /* Count how much memory is needed for concatenated command line */ 111235c4bbdfSmrg for (i = 0, iCurrLen = 0; i < argc; ++i) 111335c4bbdfSmrg if (argv[i]) { 111435c4bbdfSmrg /* Adds two characters for lines that overflow */ 111535c4bbdfSmrg if ((strlen(argv[i]) < CHARS_PER_LINE 111635c4bbdfSmrg && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) 111735c4bbdfSmrg || strlen(argv[i]) > CHARS_PER_LINE) { 111835c4bbdfSmrg iCurrLen = 0; 111935c4bbdfSmrg iSize += 2; 112035c4bbdfSmrg } 112135c4bbdfSmrg 112235c4bbdfSmrg /* Add space for item and trailing space */ 112335c4bbdfSmrg iSize += strlen(argv[i]) + 1; 112435c4bbdfSmrg 112535c4bbdfSmrg /* Update current line length */ 112635c4bbdfSmrg iCurrLen += strlen(argv[i]); 112735c4bbdfSmrg } 112835c4bbdfSmrg 112935c4bbdfSmrg /* Allocate memory for concatenated command line */ 113035c4bbdfSmrg g_pszCommandLine = malloc(iSize + 1); 113135c4bbdfSmrg if (!g_pszCommandLine) 113235c4bbdfSmrg FatalError("winLogCommandLine - Could not allocate memory for " 113335c4bbdfSmrg "command line string. Exiting.\n"); 113435c4bbdfSmrg 113535c4bbdfSmrg /* Set first character to concatenated command line to null */ 113635c4bbdfSmrg g_pszCommandLine[0] = '\0'; 113735c4bbdfSmrg 113835c4bbdfSmrg /* Loop through all args */ 113935c4bbdfSmrg for (i = 0, iCurrLen = 0; i < argc; ++i) { 114035c4bbdfSmrg /* Add a character for lines that overflow */ 114135c4bbdfSmrg if ((strlen(argv[i]) < CHARS_PER_LINE 114235c4bbdfSmrg && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) 114335c4bbdfSmrg || strlen(argv[i]) > CHARS_PER_LINE) { 114435c4bbdfSmrg iCurrLen = 0; 114535c4bbdfSmrg 114635c4bbdfSmrg /* Add line break if it fits */ 114735c4bbdfSmrg strncat(g_pszCommandLine, "\n ", iSize - strlen(g_pszCommandLine)); 114835c4bbdfSmrg } 114935c4bbdfSmrg 115035c4bbdfSmrg strncat(g_pszCommandLine, argv[i], iSize - strlen(g_pszCommandLine)); 115135c4bbdfSmrg strncat(g_pszCommandLine, " ", iSize - strlen(g_pszCommandLine)); 115235c4bbdfSmrg 115335c4bbdfSmrg /* Save new line length */ 115435c4bbdfSmrg iCurrLen += strlen(argv[i]); 115505b261ecSmrg } 115605b261ecSmrg 115735c4bbdfSmrg ErrorF("XWin was started with the following command line:\n\n" 115835c4bbdfSmrg "%s\n\n", g_pszCommandLine); 115905b261ecSmrg} 116005b261ecSmrg 116105b261ecSmrg/* 116235c4bbdfSmrg * winLogVersionInfo - Log version information 116305b261ecSmrg */ 116405b261ecSmrg 116505b261ecSmrgvoid 116635c4bbdfSmrgwinLogVersionInfo(void) 116705b261ecSmrg{ 116835c4bbdfSmrg static Bool s_fBeenHere = FALSE; 116905b261ecSmrg 117035c4bbdfSmrg if (s_fBeenHere) 117135c4bbdfSmrg return; 117235c4bbdfSmrg s_fBeenHere = TRUE; 117305b261ecSmrg 117435c4bbdfSmrg ErrorF("Welcome to the XWin X Server\n"); 117535c4bbdfSmrg ErrorF("Vendor: %s\n", XVENDORNAME); 117635c4bbdfSmrg ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR, 117735c4bbdfSmrg XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP); 117835c4bbdfSmrg#ifdef HAVE_SYS_UTSNAME_H 117935c4bbdfSmrg { 118035c4bbdfSmrg struct utsname name; 118135c4bbdfSmrg 118235c4bbdfSmrg if (uname(&name) >= 0) { 118335c4bbdfSmrg ErrorF("OS: %s %s %s %s %s\n", name.sysname, name.nodename, 118435c4bbdfSmrg name.release, name.version, name.machine); 118535c4bbdfSmrg } 118635c4bbdfSmrg } 118735c4bbdfSmrg#endif 118835c4bbdfSmrg winOS(); 118935c4bbdfSmrg if (strlen(BUILDERSTRING)) 119035c4bbdfSmrg ErrorF("%s\n", BUILDERSTRING); 119135c4bbdfSmrg ErrorF("Contact: %s\n", BUILDERADDR); 119235c4bbdfSmrg ErrorF("\n"); 119305b261ecSmrg} 1194