winprocarg.c revision 1b5d61b8
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" 4305b261ecSmrg 4435c4bbdfSmrg#include "winclipboard/winclipboard.h" 4505b261ecSmrg 4605b261ecSmrg/* 4705b261ecSmrg * Function prototypes 4805b261ecSmrg */ 4905b261ecSmrg 5005b261ecSmrgvoid 5135c4bbdfSmrg winLogCommandLine(int argc, char *argv[]); 5205b261ecSmrg 5305b261ecSmrgvoid 5435c4bbdfSmrg winLogVersionInfo(void); 5505b261ecSmrg 5605b261ecSmrg/* 5705b261ecSmrg * Process arguments on the command line 5805b261ecSmrg */ 5905b261ecSmrg 606747b715Smrgstatic int iLastScreen = -1; 616747b715Smrgstatic winScreenInfo defaultScreenInfo; 626747b715Smrg 636747b715Smrgstatic void 646747b715SmrgwinInitializeScreenDefaults(void) 6505b261ecSmrg{ 6635c4bbdfSmrg DWORD dwWidth, dwHeight; 6735c4bbdfSmrg static Bool fInitializedScreenDefaults = FALSE; 6835c4bbdfSmrg 6935c4bbdfSmrg /* Bail out early if default screen has already been initialized */ 7035c4bbdfSmrg if (fInitializedScreenDefaults) 7135c4bbdfSmrg return; 7235c4bbdfSmrg 7335c4bbdfSmrg /* Zero the memory used for storing the screen info */ 7435c4bbdfSmrg memset(&defaultScreenInfo, 0, sizeof(winScreenInfo)); 7535c4bbdfSmrg 7635c4bbdfSmrg /* Get default width and height */ 7735c4bbdfSmrg /* 7835c4bbdfSmrg * NOTE: These defaults will cause the window to cover only 7935c4bbdfSmrg * the primary monitor in the case that we have multiple monitors. 8035c4bbdfSmrg */ 8135c4bbdfSmrg dwWidth = GetSystemMetrics(SM_CXSCREEN); 8235c4bbdfSmrg dwHeight = GetSystemMetrics(SM_CYSCREEN); 8335c4bbdfSmrg 8435c4bbdfSmrg winErrorFVerb(2, 8535c4bbdfSmrg "winInitializeScreenDefaults - primary monitor w %d h %d\n", 8635c4bbdfSmrg (int) dwWidth, (int) dwHeight); 8735c4bbdfSmrg 8835c4bbdfSmrg /* Set a default DPI, if no '-dpi' option was used */ 8935c4bbdfSmrg if (monitorResolution == 0) { 9035c4bbdfSmrg HDC hdc = GetDC(NULL); 9135c4bbdfSmrg 9235c4bbdfSmrg if (hdc) { 9335c4bbdfSmrg int dpiX = GetDeviceCaps(hdc, LOGPIXELSX); 9435c4bbdfSmrg int dpiY = GetDeviceCaps(hdc, LOGPIXELSY); 9535c4bbdfSmrg 9635c4bbdfSmrg winErrorFVerb(2, 9735c4bbdfSmrg "winInitializeScreenDefaults - native DPI x %d y %d\n", 9835c4bbdfSmrg dpiX, dpiY); 9935c4bbdfSmrg 10035c4bbdfSmrg monitorResolution = dpiY; 10135c4bbdfSmrg ReleaseDC(NULL, hdc); 10235c4bbdfSmrg } 10335c4bbdfSmrg else { 10435c4bbdfSmrg winErrorFVerb(1, 10535c4bbdfSmrg "winInitializeScreenDefaults - Failed to retrieve native DPI, falling back to default of %d DPI\n", 10635c4bbdfSmrg WIN_DEFAULT_DPI); 10735c4bbdfSmrg monitorResolution = WIN_DEFAULT_DPI; 10835c4bbdfSmrg } 10935c4bbdfSmrg } 11035c4bbdfSmrg 11135c4bbdfSmrg defaultScreenInfo.iMonitor = 1; 11235c4bbdfSmrg defaultScreenInfo.hMonitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY); 11335c4bbdfSmrg defaultScreenInfo.dwWidth = dwWidth; 11435c4bbdfSmrg defaultScreenInfo.dwHeight = dwHeight; 11535c4bbdfSmrg defaultScreenInfo.dwUserWidth = dwWidth; 11635c4bbdfSmrg defaultScreenInfo.dwUserHeight = dwHeight; 11735c4bbdfSmrg defaultScreenInfo.fUserGaveHeightAndWidth = 11835c4bbdfSmrg WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH; 11935c4bbdfSmrg defaultScreenInfo.fUserGavePosition = FALSE; 12035c4bbdfSmrg defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP; 12135c4bbdfSmrg defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES; 12205b261ecSmrg#ifdef XWIN_EMULATEPSEUDO 12335c4bbdfSmrg defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; 12405b261ecSmrg#endif 12535c4bbdfSmrg defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH; 12635c4bbdfSmrg defaultScreenInfo.pfb = NULL; 12735c4bbdfSmrg defaultScreenInfo.fFullScreen = FALSE; 12835c4bbdfSmrg defaultScreenInfo.fDecoration = TRUE; 12905b261ecSmrg#ifdef XWIN_MULTIWINDOWEXTWM 13035c4bbdfSmrg defaultScreenInfo.fMWExtWM = FALSE; 13105b261ecSmrg#endif 13235c4bbdfSmrg defaultScreenInfo.fRootless = FALSE; 13335c4bbdfSmrg defaultScreenInfo.fMultiWindow = FALSE; 13435c4bbdfSmrg defaultScreenInfo.fMultiMonitorOverride = FALSE; 13535c4bbdfSmrg defaultScreenInfo.fMultipleMonitors = FALSE; 13635c4bbdfSmrg defaultScreenInfo.fLessPointer = FALSE; 1371b5d61b8Smrg defaultScreenInfo.iResizeMode = resizeDefault; 13835c4bbdfSmrg defaultScreenInfo.fNoTrayIcon = FALSE; 13935c4bbdfSmrg defaultScreenInfo.iE3BTimeout = WIN_E3B_DEFAULT; 14035c4bbdfSmrg defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL; 14135c4bbdfSmrg defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL; 14235c4bbdfSmrg defaultScreenInfo.fIgnoreInput = FALSE; 14335c4bbdfSmrg defaultScreenInfo.fExplicitScreen = FALSE; 14435c4bbdfSmrg 14535c4bbdfSmrg /* Note that the default screen has been initialized */ 14635c4bbdfSmrg fInitializedScreenDefaults = TRUE; 1476747b715Smrg} 14805b261ecSmrg 1496747b715Smrgstatic void 1506747b715SmrgwinInitializeScreen(int i) 1516747b715Smrg{ 15235c4bbdfSmrg winErrorFVerb(3, "winInitializeScreen - %d\n", i); 15305b261ecSmrg 15435c4bbdfSmrg /* Initialize default screen values, if needed */ 15535c4bbdfSmrg winInitializeScreenDefaults(); 1566747b715Smrg 15735c4bbdfSmrg /* Copy the default screen info */ 15835c4bbdfSmrg g_ScreenInfo[i] = defaultScreenInfo; 1596747b715Smrg 16035c4bbdfSmrg /* Set the screen number */ 16135c4bbdfSmrg g_ScreenInfo[i].dwScreen = i; 1626747b715Smrg} 1636747b715Smrg 1646747b715Smrgvoid 1656747b715SmrgwinInitializeScreens(int maxscreens) 1666747b715Smrg{ 16735c4bbdfSmrg int i; 1686747b715Smrg 16935c4bbdfSmrg winErrorFVerb(3, "winInitializeScreens - %i\n", maxscreens); 17035c4bbdfSmrg 17135c4bbdfSmrg if (maxscreens > g_iNumScreens) { 17235c4bbdfSmrg /* Reallocate the memory for DDX-specific screen info */ 17335c4bbdfSmrg g_ScreenInfo = 17435c4bbdfSmrg realloc(g_ScreenInfo, maxscreens * sizeof(winScreenInfo)); 1756747b715Smrg 17635c4bbdfSmrg /* Set default values for any new screens */ 17735c4bbdfSmrg for (i = g_iNumScreens; i < maxscreens; i++) 17835c4bbdfSmrg winInitializeScreen(i); 1796747b715Smrg 18035c4bbdfSmrg /* Keep a count of the number of screens */ 18135c4bbdfSmrg g_iNumScreens = maxscreens; 1826747b715Smrg } 18305b261ecSmrg} 18405b261ecSmrg 18505b261ecSmrg/* See Porting Layer Definition - p. 57 */ 18605b261ecSmrg/* 18705b261ecSmrg * INPUT 18805b261ecSmrg * argv: pointer to an array of null-terminated strings, one for 18905b261ecSmrg * each token in the X Server command line; the first token 19005b261ecSmrg * is 'XWin.exe', or similar. 19105b261ecSmrg * argc: a count of the number of tokens stored in argv. 19205b261ecSmrg * i: a zero-based index into argv indicating the current token being 19305b261ecSmrg * processed. 19405b261ecSmrg * 19505b261ecSmrg * OUTPUT 19605b261ecSmrg * return: return the number of tokens processed correctly. 19705b261ecSmrg * 19805b261ecSmrg * NOTE 19905b261ecSmrg * When looking for n tokens, check that i + n is less than argc. Or, 20005b261ecSmrg * you may check if i is greater than or equal to argc, in which case 20105b261ecSmrg * you should display the UseMsg () and return 0. 20205b261ecSmrg */ 20305b261ecSmrg 20405b261ecSmrg/* Check if enough arguments are given for the option */ 20505b261ecSmrg#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; } 20605b261ecSmrg 20735c4bbdfSmrg/* Compare the current option with the string. */ 20805b261ecSmrg#define IS_OPTION(name) (strcmp (argv[i], name) == 0) 20905b261ecSmrg 21005b261ecSmrgint 21135c4bbdfSmrgddxProcessArgument(int argc, char *argv[], int i) 21205b261ecSmrg{ 21335c4bbdfSmrg static Bool s_fBeenHere = FALSE; 21435c4bbdfSmrg winScreenInfo *screenInfoPtr = NULL; 21505b261ecSmrg 21635c4bbdfSmrg /* Initialize once */ 21735c4bbdfSmrg if (!s_fBeenHere) { 21805b261ecSmrg#ifdef DDXOSVERRORF 21935c4bbdfSmrg /* 22035c4bbdfSmrg * This initialises our hook into VErrorF () for catching log messages 22135c4bbdfSmrg * that are generated before OsInit () is called. 22235c4bbdfSmrg */ 22335c4bbdfSmrg OsVendorVErrorFProc = OsVendorVErrorF; 22405b261ecSmrg#endif 22505b261ecSmrg 22635c4bbdfSmrg s_fBeenHere = TRUE; 22705b261ecSmrg 22835c4bbdfSmrg /* Initialize only if option is not -help */ 22935c4bbdfSmrg if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") && 23035c4bbdfSmrg !IS_OPTION("-version") && !IS_OPTION("--version")) { 23105b261ecSmrg 23235c4bbdfSmrg /* Log the version information */ 23335c4bbdfSmrg winLogVersionInfo(); 23405b261ecSmrg 23535c4bbdfSmrg /* Log the command line */ 23635c4bbdfSmrg winLogCommandLine(argc, argv); 23705b261ecSmrg 23835c4bbdfSmrg /* 23935c4bbdfSmrg * Initialize default screen settings. We have to do this before 24035c4bbdfSmrg * OsVendorInit () gets called, otherwise we will overwrite 24135c4bbdfSmrg * settings changed by parameters such as -fullscreen, etc. 24235c4bbdfSmrg */ 2431b5d61b8Smrg winErrorFVerb(3, "ddxProcessArgument - Initializing default " 24435c4bbdfSmrg "screens\n"); 24535c4bbdfSmrg winInitializeScreenDefaults(); 24635c4bbdfSmrg } 24705b261ecSmrg } 24805b261ecSmrg 24905b261ecSmrg#if CYGDEBUG 25035c4bbdfSmrg winDebug("ddxProcessArgument - arg: %s\n", argv[i]); 25105b261ecSmrg#endif 25205b261ecSmrg 25335c4bbdfSmrg /* 25435c4bbdfSmrg * Look for the '-help' and similar options 25535c4bbdfSmrg */ 25635c4bbdfSmrg if (IS_OPTION("-help") || IS_OPTION("-h") || IS_OPTION("--help")) { 25735c4bbdfSmrg /* Reset logfile. We don't need that helpmessage in the logfile */ 25835c4bbdfSmrg g_pszLogFile = NULL; 25935c4bbdfSmrg g_fNoHelpMessageBox = TRUE; 26035c4bbdfSmrg UseMsg(); 26135c4bbdfSmrg exit(0); 26235c4bbdfSmrg return 1; 26305b261ecSmrg } 26405b261ecSmrg 26535c4bbdfSmrg if (IS_OPTION("-version") || IS_OPTION("--version")) { 26635c4bbdfSmrg /* Reset logfile. We don't need that versioninfo in the logfile */ 26735c4bbdfSmrg g_pszLogFile = NULL; 26835c4bbdfSmrg winLogVersionInfo(); 26935c4bbdfSmrg exit(0); 27035c4bbdfSmrg return 1; 27105b261ecSmrg } 27205b261ecSmrg 27335c4bbdfSmrg /* 27435c4bbdfSmrg * Look for the '-screen scr_num [width height]' argument 27535c4bbdfSmrg */ 27635c4bbdfSmrg if (IS_OPTION("-screen")) { 27735c4bbdfSmrg int iArgsProcessed = 1; 27835c4bbdfSmrg int nScreenNum; 27935c4bbdfSmrg int iWidth, iHeight, iX, iY; 28035c4bbdfSmrg int iMonitor; 28105b261ecSmrg 28205b261ecSmrg#if CYGDEBUG 28335c4bbdfSmrg winDebug("ddxProcessArgument - screen - argc: %d i: %d\n", argc, i); 28405b261ecSmrg#endif 28505b261ecSmrg 28635c4bbdfSmrg /* Display the usage message if the argument is malformed */ 28735c4bbdfSmrg if (i + 1 >= argc) { 28835c4bbdfSmrg return 0; 28905b261ecSmrg } 29005b261ecSmrg 29135c4bbdfSmrg /* Grab screen number */ 29235c4bbdfSmrg nScreenNum = atoi(argv[i + 1]); 29305b261ecSmrg 29435c4bbdfSmrg /* Validate the specified screen number */ 29535c4bbdfSmrg if (nScreenNum < 0) { 29635c4bbdfSmrg ErrorF("ddxProcessArgument - screen - Invalid screen number %d\n", 29735c4bbdfSmrg nScreenNum); 29835c4bbdfSmrg UseMsg(); 29935c4bbdfSmrg return 0; 30035c4bbdfSmrg } 3016747b715Smrg 30235c4bbdfSmrg /* 30335c4bbdfSmrg Initialize default values for any new screens 30435c4bbdfSmrg 30535c4bbdfSmrg Note that default values can't change after a -screen option is 30635c4bbdfSmrg seen, so it's safe to do this for each screen as it is introduced 30735c4bbdfSmrg */ 30835c4bbdfSmrg winInitializeScreens(nScreenNum + 1); 30935c4bbdfSmrg 31035c4bbdfSmrg /* look for @m where m is monitor number */ 31135c4bbdfSmrg if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) { 31235c4bbdfSmrg struct GetMonitorInfoData data; 31335c4bbdfSmrg 31435c4bbdfSmrg if (!QueryMonitor(iMonitor, &data)) { 31535c4bbdfSmrg ErrorF 31635c4bbdfSmrg ("ddxProcessArgument - screen - Querying monitors failed\n"); 31735c4bbdfSmrg } 31835c4bbdfSmrg else if (data.bMonitorSpecifiedExists == TRUE) { 31935c4bbdfSmrg winErrorFVerb(2, 32035c4bbdfSmrg "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", 32135c4bbdfSmrg iMonitor); 32235c4bbdfSmrg iArgsProcessed = 3; 32335c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 32435c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 32535c4bbdfSmrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 32635c4bbdfSmrg g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; 32735c4bbdfSmrg g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth; 32835c4bbdfSmrg g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight; 32935c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth; 33035c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight; 33135c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 33235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 33335c4bbdfSmrg } 33435c4bbdfSmrg else { 33535c4bbdfSmrg /* monitor does not exist, error out */ 33635c4bbdfSmrg ErrorF 33735c4bbdfSmrg ("ddxProcessArgument - screen - Invalid monitor number %d\n", 33835c4bbdfSmrg iMonitor); 33935c4bbdfSmrg UseMsg(); 34035c4bbdfSmrg exit(0); 34135c4bbdfSmrg return 0; 34235c4bbdfSmrg } 34335c4bbdfSmrg } 34435c4bbdfSmrg 34535c4bbdfSmrg /* Look for 'WxD' or 'W D' */ 34635c4bbdfSmrg else if (i + 2 < argc 34735c4bbdfSmrg && 2 == sscanf(argv[i + 2], "%dx%d", 34835c4bbdfSmrg (int *) &iWidth, (int *) &iHeight)) { 34935c4bbdfSmrg winErrorFVerb(2, 35035c4bbdfSmrg "ddxProcessArgument - screen - Found ``WxD'' arg\n"); 35135c4bbdfSmrg iArgsProcessed = 3; 35235c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 35335c4bbdfSmrg g_ScreenInfo[nScreenNum].dwWidth = iWidth; 35435c4bbdfSmrg g_ScreenInfo[nScreenNum].dwHeight = iHeight; 35535c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 35635c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 35735c4bbdfSmrg /* Look for WxD+X+Y */ 35835c4bbdfSmrg if (2 == sscanf(argv[i + 2], "%*dx%*d+%d+%d", 35935c4bbdfSmrg (int *) &iX, (int *) &iY)) { 36035c4bbdfSmrg winErrorFVerb(2, 36135c4bbdfSmrg "ddxProcessArgument - screen - Found ``X+Y'' arg\n"); 36235c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 36335c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = iX; 36435c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = iY; 36535c4bbdfSmrg 36635c4bbdfSmrg /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */ 36735c4bbdfSmrg if (1 == sscanf(argv[i + 2], "%*dx%*d+%*d+%*d@%d", 36835c4bbdfSmrg (int *) &iMonitor)) { 36935c4bbdfSmrg struct GetMonitorInfoData data; 37035c4bbdfSmrg 37135c4bbdfSmrg if (!QueryMonitor(iMonitor, &data)) { 37235c4bbdfSmrg ErrorF 37335c4bbdfSmrg ("ddxProcessArgument - screen - Querying monitors failed\n"); 37435c4bbdfSmrg } 37535c4bbdfSmrg else if (data.bMonitorSpecifiedExists == TRUE) { 37635c4bbdfSmrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 37735c4bbdfSmrg g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; 37835c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX += 37935c4bbdfSmrg data.monitorOffsetX; 38035c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY += 38135c4bbdfSmrg data.monitorOffsetY; 38235c4bbdfSmrg } 38335c4bbdfSmrg else { 38435c4bbdfSmrg /* monitor does not exist, error out */ 38535c4bbdfSmrg ErrorF 38635c4bbdfSmrg ("ddxProcessArgument - screen - Invalid monitor number %d\n", 38735c4bbdfSmrg iMonitor); 38835c4bbdfSmrg UseMsg(); 38935c4bbdfSmrg exit(0); 39035c4bbdfSmrg return 0; 39135c4bbdfSmrg } 39235c4bbdfSmrg 39335c4bbdfSmrg } 39435c4bbdfSmrg } 39535c4bbdfSmrg 39635c4bbdfSmrg /* look for WxD@m where m is monitor number */ 39735c4bbdfSmrg else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", (int *) &iMonitor)) { 39835c4bbdfSmrg struct GetMonitorInfoData data; 39935c4bbdfSmrg 40035c4bbdfSmrg if (!QueryMonitor(iMonitor, &data)) { 40135c4bbdfSmrg ErrorF 40235c4bbdfSmrg ("ddxProcessArgument - screen - Querying monitors failed\n"); 40335c4bbdfSmrg } 40435c4bbdfSmrg else if (data.bMonitorSpecifiedExists == TRUE) { 40535c4bbdfSmrg winErrorFVerb(2, 40635c4bbdfSmrg "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", 40735c4bbdfSmrg iMonitor); 40835c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 40935c4bbdfSmrg g_ScreenInfo[nScreenNum].iMonitor = iMonitor; 41035c4bbdfSmrg g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle; 41135c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX; 41235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY; 41335c4bbdfSmrg } 41435c4bbdfSmrg else { 41535c4bbdfSmrg /* monitor does not exist, error out */ 41635c4bbdfSmrg ErrorF 41735c4bbdfSmrg ("ddxProcessArgument - screen - Invalid monitor number %d\n", 41835c4bbdfSmrg iMonitor); 41935c4bbdfSmrg UseMsg(); 42035c4bbdfSmrg exit(0); 42135c4bbdfSmrg return 0; 42235c4bbdfSmrg } 42335c4bbdfSmrg 42435c4bbdfSmrg } 42535c4bbdfSmrg } 42635c4bbdfSmrg else if (i + 3 < argc && 1 == sscanf(argv[i + 2], "%d", (int *) &iWidth) 42735c4bbdfSmrg && 1 == sscanf(argv[i + 3], "%d", (int *) &iHeight)) { 42835c4bbdfSmrg winErrorFVerb(2, 42935c4bbdfSmrg "ddxProcessArgument - screen - Found ``W D'' arg\n"); 43035c4bbdfSmrg iArgsProcessed = 4; 43135c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE; 43235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwWidth = iWidth; 43335c4bbdfSmrg g_ScreenInfo[nScreenNum].dwHeight = iHeight; 43435c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserWidth = iWidth; 43535c4bbdfSmrg g_ScreenInfo[nScreenNum].dwUserHeight = iHeight; 43635c4bbdfSmrg if (i + 5 < argc && 1 == sscanf(argv[i + 4], "%d", (int *) &iX) 43735c4bbdfSmrg && 1 == sscanf(argv[i + 5], "%d", (int *) &iY)) { 43835c4bbdfSmrg winErrorFVerb(2, 43935c4bbdfSmrg "ddxProcessArgument - screen - Found ``X Y'' arg\n"); 44035c4bbdfSmrg iArgsProcessed = 6; 44135c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE; 44235c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialX = iX; 44335c4bbdfSmrg g_ScreenInfo[nScreenNum].dwInitialY = iY; 44435c4bbdfSmrg } 44535c4bbdfSmrg } 44635c4bbdfSmrg else { 44735c4bbdfSmrg winErrorFVerb(2, 44835c4bbdfSmrg "ddxProcessArgument - screen - Did not find size arg. " 44935c4bbdfSmrg "dwWidth: %d dwHeight: %d\n", 45035c4bbdfSmrg (int) g_ScreenInfo[nScreenNum].dwWidth, 45135c4bbdfSmrg (int) g_ScreenInfo[nScreenNum].dwHeight); 45235c4bbdfSmrg iArgsProcessed = 2; 45335c4bbdfSmrg g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE; 45435c4bbdfSmrg } 45535c4bbdfSmrg 45635c4bbdfSmrg /* Flag that this screen was explicity specified by the user */ 45735c4bbdfSmrg g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE; 45835c4bbdfSmrg 45935c4bbdfSmrg /* 46035c4bbdfSmrg * Keep track of the last screen number seen, as parameters seen 46135c4bbdfSmrg * before a screen number apply to all screens, whereas parameters 46235c4bbdfSmrg * seen after a screen number apply to that screen number only. 46335c4bbdfSmrg */ 46435c4bbdfSmrg iLastScreen = nScreenNum; 46535c4bbdfSmrg 46635c4bbdfSmrg return iArgsProcessed; 4676747b715Smrg } 46835c4bbdfSmrg 46935c4bbdfSmrg /* 47035c4bbdfSmrg * Is this parameter attached to a screen or global? 47135c4bbdfSmrg * 47235c4bbdfSmrg * If the parameter is for all screens (appears before 47335c4bbdfSmrg * any -screen option), store it in the default screen 47435c4bbdfSmrg * info 47535c4bbdfSmrg * 47635c4bbdfSmrg * If the parameter is for a single screen (appears 47735c4bbdfSmrg * after a -screen option), store it in the screen info 47835c4bbdfSmrg * for that screen 47935c4bbdfSmrg * 48035c4bbdfSmrg */ 48135c4bbdfSmrg if (iLastScreen == -1) { 48235c4bbdfSmrg screenInfoPtr = &defaultScreenInfo; 48335c4bbdfSmrg } 48435c4bbdfSmrg else { 48535c4bbdfSmrg screenInfoPtr = &(g_ScreenInfo[iLastScreen]); 4866747b715Smrg } 4876747b715Smrg 48835c4bbdfSmrg /* 48935c4bbdfSmrg * Look for the '-engine n' argument 49035c4bbdfSmrg */ 49135c4bbdfSmrg if (IS_OPTION("-engine")) { 49235c4bbdfSmrg DWORD dwEngine = 0; 49335c4bbdfSmrg CARD8 c8OnBits = 0; 49435c4bbdfSmrg 49535c4bbdfSmrg /* Display the usage message if the argument is malformed */ 49635c4bbdfSmrg if (++i >= argc) { 49735c4bbdfSmrg UseMsg(); 49835c4bbdfSmrg return 0; 49935c4bbdfSmrg } 50035c4bbdfSmrg 50135c4bbdfSmrg /* Grab the argument */ 50235c4bbdfSmrg dwEngine = atoi(argv[i]); 50335c4bbdfSmrg 50435c4bbdfSmrg /* Count the one bits in the engine argument */ 50535c4bbdfSmrg c8OnBits = winCountBits(dwEngine); 50635c4bbdfSmrg 50735c4bbdfSmrg /* Argument should only have a single bit on */ 50835c4bbdfSmrg if (c8OnBits != 1) { 50935c4bbdfSmrg UseMsg(); 51035c4bbdfSmrg return 0; 51135c4bbdfSmrg } 51235c4bbdfSmrg 51335c4bbdfSmrg screenInfoPtr->dwEnginePreferred = dwEngine; 51435c4bbdfSmrg 51535c4bbdfSmrg /* Indicate that we have processed the argument */ 51635c4bbdfSmrg return 2; 51705b261ecSmrg } 51805b261ecSmrg 51935c4bbdfSmrg /* 52035c4bbdfSmrg * Look for the '-fullscreen' argument 52135c4bbdfSmrg */ 52235c4bbdfSmrg if (IS_OPTION("-fullscreen")) { 52335c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 5246747b715Smrg screenInfoPtr->fMultipleMonitors = FALSE; 52535c4bbdfSmrg screenInfoPtr->fFullScreen = TRUE; 52605b261ecSmrg 52735c4bbdfSmrg /* Indicate that we have processed this argument */ 52835c4bbdfSmrg return 1; 52905b261ecSmrg } 53005b261ecSmrg 53135c4bbdfSmrg /* 53235c4bbdfSmrg * Look for the '-lesspointer' argument 53335c4bbdfSmrg */ 53435c4bbdfSmrg if (IS_OPTION("-lesspointer")) { 53535c4bbdfSmrg screenInfoPtr->fLessPointer = TRUE; 53605b261ecSmrg 53735c4bbdfSmrg /* Indicate that we have processed this argument */ 53835c4bbdfSmrg return 1; 53905b261ecSmrg } 54005b261ecSmrg 54135c4bbdfSmrg /* 54235c4bbdfSmrg * Look for the '-nodecoration' argument 54335c4bbdfSmrg */ 54435c4bbdfSmrg if (IS_OPTION("-nodecoration")) { 54535c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 54635c4bbdfSmrg screenInfoPtr->fMultipleMonitors = FALSE; 54735c4bbdfSmrg screenInfoPtr->fDecoration = FALSE; 54805b261ecSmrg 54935c4bbdfSmrg /* Indicate that we have processed this argument */ 55035c4bbdfSmrg return 1; 55105b261ecSmrg } 55205b261ecSmrg 55305b261ecSmrg#ifdef XWIN_MULTIWINDOWEXTWM 55435c4bbdfSmrg /* 55535c4bbdfSmrg * Look for the '-mwextwm' argument 55635c4bbdfSmrg */ 55735c4bbdfSmrg if (IS_OPTION("-mwextwm")) { 55835c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 55935c4bbdfSmrg screenInfoPtr->fMultipleMonitors = TRUE; 56035c4bbdfSmrg screenInfoPtr->fMWExtWM = TRUE; 56135c4bbdfSmrg 56235c4bbdfSmrg /* Indicate that we have processed this argument */ 56335c4bbdfSmrg return 1; 56405b261ecSmrg } 56535c4bbdfSmrg /* 56635c4bbdfSmrg * Look for the '-internalwm' argument 56735c4bbdfSmrg */ 56835c4bbdfSmrg if (IS_OPTION("-internalwm")) { 5691b5d61b8Smrg ErrorF("Ignoring obsolete -internalwm option\n"); 5701b5d61b8Smrg /* Ignored, but we still accept the arg for backwards compatibility */ 57135c4bbdfSmrg /* Indicate that we have processed this argument */ 57235c4bbdfSmrg return 1; 57305b261ecSmrg } 57405b261ecSmrg#endif 57505b261ecSmrg 57635c4bbdfSmrg /* 57735c4bbdfSmrg * Look for the '-rootless' argument 57835c4bbdfSmrg */ 57935c4bbdfSmrg if (IS_OPTION("-rootless")) { 58035c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 58135c4bbdfSmrg screenInfoPtr->fMultipleMonitors = FALSE; 58235c4bbdfSmrg screenInfoPtr->fRootless = TRUE; 58305b261ecSmrg 58435c4bbdfSmrg /* Indicate that we have processed this argument */ 58535c4bbdfSmrg return 1; 58605b261ecSmrg } 58705b261ecSmrg 58835c4bbdfSmrg /* 58935c4bbdfSmrg * Look for the '-multiwindow' argument 59035c4bbdfSmrg */ 59135c4bbdfSmrg if (IS_OPTION("-multiwindow")) { 59235c4bbdfSmrg if (!screenInfoPtr->fMultiMonitorOverride) 59335c4bbdfSmrg screenInfoPtr->fMultipleMonitors = TRUE; 59435c4bbdfSmrg screenInfoPtr->fMultiWindow = TRUE; 59505b261ecSmrg 59635c4bbdfSmrg /* Indicate that we have processed this argument */ 59735c4bbdfSmrg return 1; 59805b261ecSmrg } 59905b261ecSmrg 60035c4bbdfSmrg /* 60135c4bbdfSmrg * Look for the '-multiplemonitors' argument 60235c4bbdfSmrg */ 60335c4bbdfSmrg if (IS_OPTION("-multiplemonitors") 60435c4bbdfSmrg || IS_OPTION("-multimonitors")) { 60535c4bbdfSmrg screenInfoPtr->fMultiMonitorOverride = TRUE; 60635c4bbdfSmrg screenInfoPtr->fMultipleMonitors = TRUE; 60705b261ecSmrg 60835c4bbdfSmrg /* Indicate that we have processed this argument */ 60935c4bbdfSmrg return 1; 61005b261ecSmrg } 61105b261ecSmrg 61235c4bbdfSmrg /* 61335c4bbdfSmrg * Look for the '-nomultiplemonitors' argument 61435c4bbdfSmrg */ 61535c4bbdfSmrg if (IS_OPTION("-nomultiplemonitors") 61635c4bbdfSmrg || IS_OPTION("-nomultimonitors")) { 61735c4bbdfSmrg screenInfoPtr->fMultiMonitorOverride = TRUE; 61835c4bbdfSmrg screenInfoPtr->fMultipleMonitors = FALSE; 61905b261ecSmrg 62035c4bbdfSmrg /* Indicate that we have processed this argument */ 62135c4bbdfSmrg return 1; 62205b261ecSmrg } 62305b261ecSmrg 62435c4bbdfSmrg /* 62535c4bbdfSmrg * Look for the '-scrollbars' argument 62635c4bbdfSmrg */ 62735c4bbdfSmrg if (IS_OPTION("-scrollbars")) { 62805b261ecSmrg 62935c4bbdfSmrg screenInfoPtr->iResizeMode = resizeWithScrollbars; 63005b261ecSmrg 63135c4bbdfSmrg /* Indicate that we have processed this argument */ 63235c4bbdfSmrg return 1; 63305b261ecSmrg } 63405b261ecSmrg 63535c4bbdfSmrg /* 63635c4bbdfSmrg * Look for the '-resize' argument 63735c4bbdfSmrg */ 63835c4bbdfSmrg if (IS_OPTION("-resize") || IS_OPTION("-noresize") || 63935c4bbdfSmrg (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0)) { 64035c4bbdfSmrg winResizeMode mode; 64135c4bbdfSmrg 64235c4bbdfSmrg if (IS_OPTION("-resize")) 6439ace9065Smrg mode = resizeWithRandr; 64435c4bbdfSmrg else if (IS_OPTION("-noresize")) 6451b5d61b8Smrg mode = resizeNotAllowed; 64635c4bbdfSmrg else if (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0) { 64735c4bbdfSmrg char *option = argv[i] + strlen("-resize="); 64835c4bbdfSmrg 64935c4bbdfSmrg if (strcmp(option, "randr") == 0) 65035c4bbdfSmrg mode = resizeWithRandr; 65135c4bbdfSmrg else if (strcmp(option, "scrollbars") == 0) 65235c4bbdfSmrg mode = resizeWithScrollbars; 65335c4bbdfSmrg else if (strcmp(option, "none") == 0) 6541b5d61b8Smrg mode = resizeNotAllowed; 65535c4bbdfSmrg else { 65635c4bbdfSmrg ErrorF("ddxProcessArgument - resize - Invalid resize mode %s\n", 65735c4bbdfSmrg option); 65835c4bbdfSmrg return 0; 6599ace9065Smrg } 6609ace9065Smrg } 66135c4bbdfSmrg else { 66235c4bbdfSmrg ErrorF("ddxProcessArgument - resize - Invalid resize option %s\n", 66335c4bbdfSmrg argv[i]); 66435c4bbdfSmrg return 0; 6659ace9065Smrg } 6669ace9065Smrg 66735c4bbdfSmrg screenInfoPtr->iResizeMode = mode; 6689ace9065Smrg 66935c4bbdfSmrg /* Indicate that we have processed this argument */ 67035c4bbdfSmrg return 1; 6719ace9065Smrg } 67205b261ecSmrg 67335c4bbdfSmrg /* 67435c4bbdfSmrg * Look for the '-clipboard' argument 67535c4bbdfSmrg */ 67635c4bbdfSmrg if (IS_OPTION("-clipboard")) { 67735c4bbdfSmrg /* Now the default, we still accept the arg for backwards compatibility */ 67835c4bbdfSmrg g_fClipboard = TRUE; 67935c4bbdfSmrg 68035c4bbdfSmrg /* Indicate that we have processed this argument */ 68135c4bbdfSmrg return 1; 68235c4bbdfSmrg } 68335c4bbdfSmrg 68435c4bbdfSmrg /* 68535c4bbdfSmrg * Look for the '-noclipboard' argument 68635c4bbdfSmrg */ 68735c4bbdfSmrg if (IS_OPTION("-noclipboard")) { 68835c4bbdfSmrg g_fClipboard = FALSE; 68905b261ecSmrg 69035c4bbdfSmrg /* Indicate that we have processed this argument */ 69135c4bbdfSmrg return 1; 6926747b715Smrg } 6936747b715Smrg 69435c4bbdfSmrg /* 69535c4bbdfSmrg * Look for the '-primary' argument 69635c4bbdfSmrg */ 69735c4bbdfSmrg if (IS_OPTION("-primary")) { 69835c4bbdfSmrg fPrimarySelection = TRUE; 6996747b715Smrg 70035c4bbdfSmrg /* Indicate that we have processed this argument */ 70135c4bbdfSmrg return 1; 70205b261ecSmrg } 70305b261ecSmrg 70435c4bbdfSmrg /* 70535c4bbdfSmrg * Look for the '-noprimary' argument 70635c4bbdfSmrg */ 70735c4bbdfSmrg if (IS_OPTION("-noprimary")) { 70835c4bbdfSmrg fPrimarySelection = FALSE; 70905b261ecSmrg 71035c4bbdfSmrg /* Indicate that we have processed this argument */ 71135c4bbdfSmrg return 1; 71235c4bbdfSmrg } 71305b261ecSmrg 71435c4bbdfSmrg /* 71535c4bbdfSmrg * Look for the '-ignoreinput' argument 71635c4bbdfSmrg */ 71735c4bbdfSmrg if (IS_OPTION("-ignoreinput")) { 71835c4bbdfSmrg screenInfoPtr->fIgnoreInput = TRUE; 71935c4bbdfSmrg 72035c4bbdfSmrg /* Indicate that we have processed this argument */ 72135c4bbdfSmrg return 1; 72205b261ecSmrg } 72305b261ecSmrg 72435c4bbdfSmrg /* 72535c4bbdfSmrg * Look for the '-emulate3buttons' argument 72635c4bbdfSmrg */ 72735c4bbdfSmrg if (IS_OPTION("-emulate3buttons")) { 72835c4bbdfSmrg int iArgsProcessed = 1; 72935c4bbdfSmrg int iE3BTimeout = WIN_DEFAULT_E3B_TIME; 73035c4bbdfSmrg 73135c4bbdfSmrg /* Grab the optional timeout value */ 73235c4bbdfSmrg if (i + 1 < argc && 1 == sscanf(argv[i + 1], "%d", &iE3BTimeout)) { 73335c4bbdfSmrg /* Indicate that we have processed the next argument */ 73435c4bbdfSmrg iArgsProcessed++; 73535c4bbdfSmrg } 73635c4bbdfSmrg else { 73735c4bbdfSmrg /* 73835c4bbdfSmrg * sscanf () won't modify iE3BTimeout if it doesn't find 73935c4bbdfSmrg * the specified format; however, I want to be explicit 74035c4bbdfSmrg * about setting the default timeout in such cases to 74135c4bbdfSmrg * prevent some programs (me) from getting confused. 74235c4bbdfSmrg */ 74335c4bbdfSmrg iE3BTimeout = WIN_DEFAULT_E3B_TIME; 74405b261ecSmrg } 74535c4bbdfSmrg 74635c4bbdfSmrg screenInfoPtr->iE3BTimeout = iE3BTimeout; 74735c4bbdfSmrg 74835c4bbdfSmrg /* Indicate that we have processed this argument */ 74935c4bbdfSmrg return iArgsProcessed; 75005b261ecSmrg } 75105b261ecSmrg 75235c4bbdfSmrg /* 75335c4bbdfSmrg * Look for the '-noemulate3buttons' argument 75435c4bbdfSmrg */ 75535c4bbdfSmrg if (IS_OPTION("-noemulate3buttons")) { 75635c4bbdfSmrg screenInfoPtr->iE3BTimeout = WIN_E3B_OFF; 75735c4bbdfSmrg 75835c4bbdfSmrg /* Indicate that we have processed this argument */ 75935c4bbdfSmrg return 1; 76005b261ecSmrg } 76105b261ecSmrg 76235c4bbdfSmrg /* 76335c4bbdfSmrg * Look for the '-depth n' argument 76435c4bbdfSmrg */ 76535c4bbdfSmrg if (IS_OPTION("-depth")) { 76635c4bbdfSmrg DWORD dwBPP = 0; 76735c4bbdfSmrg 76835c4bbdfSmrg /* Display the usage message if the argument is malformed */ 76935c4bbdfSmrg if (++i >= argc) { 77035c4bbdfSmrg UseMsg(); 77135c4bbdfSmrg return 0; 77235c4bbdfSmrg } 77335c4bbdfSmrg 77435c4bbdfSmrg /* Grab the argument */ 77535c4bbdfSmrg dwBPP = atoi(argv[i]); 77635c4bbdfSmrg 77735c4bbdfSmrg screenInfoPtr->dwBPP = dwBPP; 77835c4bbdfSmrg 77935c4bbdfSmrg /* Indicate that we have processed the argument */ 78035c4bbdfSmrg return 2; 78105b261ecSmrg } 78205b261ecSmrg 78335c4bbdfSmrg /* 78435c4bbdfSmrg * Look for the '-refresh n' argument 78535c4bbdfSmrg */ 78635c4bbdfSmrg if (IS_OPTION("-refresh")) { 78735c4bbdfSmrg DWORD dwRefreshRate = 0; 78835c4bbdfSmrg 78935c4bbdfSmrg /* Display the usage message if the argument is malformed */ 79035c4bbdfSmrg if (++i >= argc) { 79135c4bbdfSmrg UseMsg(); 79235c4bbdfSmrg return 0; 79335c4bbdfSmrg } 79435c4bbdfSmrg 79535c4bbdfSmrg /* Grab the argument */ 79635c4bbdfSmrg dwRefreshRate = atoi(argv[i]); 79735c4bbdfSmrg 79835c4bbdfSmrg screenInfoPtr->dwRefreshRate = dwRefreshRate; 79935c4bbdfSmrg 80035c4bbdfSmrg /* Indicate that we have processed the argument */ 80135c4bbdfSmrg return 2; 80205b261ecSmrg } 80305b261ecSmrg 80435c4bbdfSmrg /* 80535c4bbdfSmrg * Look for the '-clipupdates num_boxes' argument 80635c4bbdfSmrg */ 80735c4bbdfSmrg if (IS_OPTION("-clipupdates")) { 80835c4bbdfSmrg DWORD dwNumBoxes = 0; 80935c4bbdfSmrg 81035c4bbdfSmrg /* Display the usage message if the argument is malformed */ 81135c4bbdfSmrg if (++i >= argc) { 81235c4bbdfSmrg UseMsg(); 81335c4bbdfSmrg return 0; 81435c4bbdfSmrg } 81505b261ecSmrg 81635c4bbdfSmrg /* Grab the argument */ 81735c4bbdfSmrg dwNumBoxes = atoi(argv[i]); 81835c4bbdfSmrg 81935c4bbdfSmrg screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes; 82035c4bbdfSmrg 82135c4bbdfSmrg /* Indicate that we have processed the argument */ 82235c4bbdfSmrg return 2; 82335c4bbdfSmrg } 82435c4bbdfSmrg 82535c4bbdfSmrg#ifdef XWIN_EMULATEPSEUDO 82635c4bbdfSmrg /* 82735c4bbdfSmrg * Look for the '-emulatepseudo' argument 82835c4bbdfSmrg */ 82935c4bbdfSmrg if (IS_OPTION("-emulatepseudo")) { 83035c4bbdfSmrg screenInfoPtr->fEmulatePseudo = TRUE; 83135c4bbdfSmrg 83235c4bbdfSmrg /* Indicate that we have processed this argument */ 83335c4bbdfSmrg return 1; 83405b261ecSmrg } 83505b261ecSmrg#endif 83605b261ecSmrg 83735c4bbdfSmrg /* 83835c4bbdfSmrg * Look for the '-nowinkill' argument 83935c4bbdfSmrg */ 84035c4bbdfSmrg if (IS_OPTION("-nowinkill")) { 84135c4bbdfSmrg screenInfoPtr->fUseWinKillKey = FALSE; 84205b261ecSmrg 84335c4bbdfSmrg /* Indicate that we have processed this argument */ 84435c4bbdfSmrg return 1; 84505b261ecSmrg } 84605b261ecSmrg 84735c4bbdfSmrg /* 84835c4bbdfSmrg * Look for the '-winkill' argument 84935c4bbdfSmrg */ 85035c4bbdfSmrg if (IS_OPTION("-winkill")) { 85135c4bbdfSmrg screenInfoPtr->fUseWinKillKey = TRUE; 85205b261ecSmrg 85335c4bbdfSmrg /* Indicate that we have processed this argument */ 85435c4bbdfSmrg return 1; 85505b261ecSmrg } 85605b261ecSmrg 85735c4bbdfSmrg /* 85835c4bbdfSmrg * Look for the '-nounixkill' argument 85935c4bbdfSmrg */ 86035c4bbdfSmrg if (IS_OPTION("-nounixkill")) { 86135c4bbdfSmrg screenInfoPtr->fUseUnixKillKey = FALSE; 86205b261ecSmrg 86335c4bbdfSmrg /* Indicate that we have processed this argument */ 86435c4bbdfSmrg return 1; 86505b261ecSmrg } 86605b261ecSmrg 86735c4bbdfSmrg /* 86835c4bbdfSmrg * Look for the '-unixkill' argument 86935c4bbdfSmrg */ 87035c4bbdfSmrg if (IS_OPTION("-unixkill")) { 87135c4bbdfSmrg screenInfoPtr->fUseUnixKillKey = TRUE; 87205b261ecSmrg 87335c4bbdfSmrg /* Indicate that we have processed this argument */ 87435c4bbdfSmrg return 1; 87505b261ecSmrg } 87605b261ecSmrg 87735c4bbdfSmrg /* 87835c4bbdfSmrg * Look for the '-notrayicon' argument 87935c4bbdfSmrg */ 88035c4bbdfSmrg if (IS_OPTION("-notrayicon")) { 88135c4bbdfSmrg screenInfoPtr->fNoTrayIcon = TRUE; 88205b261ecSmrg 88335c4bbdfSmrg /* Indicate that we have processed this argument */ 88435c4bbdfSmrg return 1; 88505b261ecSmrg } 88605b261ecSmrg 88735c4bbdfSmrg /* 88835c4bbdfSmrg * Look for the '-trayicon' argument 88935c4bbdfSmrg */ 89035c4bbdfSmrg if (IS_OPTION("-trayicon")) { 89135c4bbdfSmrg screenInfoPtr->fNoTrayIcon = FALSE; 89205b261ecSmrg 89335c4bbdfSmrg /* Indicate that we have processed this argument */ 89435c4bbdfSmrg return 1; 89505b261ecSmrg } 89605b261ecSmrg 89735c4bbdfSmrg /* 89835c4bbdfSmrg * Look for the '-fp' argument 89935c4bbdfSmrg */ 90035c4bbdfSmrg if (IS_OPTION("-fp")) { 90135c4bbdfSmrg CHECK_ARGS(1); 90235c4bbdfSmrg g_cmdline.fontPath = argv[++i]; 90335c4bbdfSmrg return 0; /* Let DIX parse this again */ 90405b261ecSmrg } 90505b261ecSmrg 90635c4bbdfSmrg /* 90735c4bbdfSmrg * Look for the '-query' argument 90835c4bbdfSmrg */ 90935c4bbdfSmrg if (IS_OPTION("-query")) { 91035c4bbdfSmrg CHECK_ARGS(1); 91135c4bbdfSmrg g_fXdmcpEnabled = TRUE; 91235c4bbdfSmrg g_pszQueryHost = argv[++i]; 91335c4bbdfSmrg return 0; /* Let DIX parse this again */ 91405b261ecSmrg } 91505b261ecSmrg 91635c4bbdfSmrg /* 91735c4bbdfSmrg * Look for the '-auth' argument 91835c4bbdfSmrg */ 91935c4bbdfSmrg if (IS_OPTION("-auth")) { 92035c4bbdfSmrg g_fAuthEnabled = TRUE; 92135c4bbdfSmrg return 0; /* Let DIX parse this again */ 9226747b715Smrg } 9236747b715Smrg 92435c4bbdfSmrg /* 92535c4bbdfSmrg * Look for the '-indirect' or '-broadcast' arguments 92635c4bbdfSmrg */ 92735c4bbdfSmrg if (IS_OPTION("-indirect") 92835c4bbdfSmrg || IS_OPTION("-broadcast")) { 92935c4bbdfSmrg g_fXdmcpEnabled = TRUE; 93035c4bbdfSmrg return 0; /* Let DIX parse this again */ 93105b261ecSmrg } 93205b261ecSmrg 93335c4bbdfSmrg /* 93435c4bbdfSmrg * Look for the '-config' argument 93535c4bbdfSmrg */ 93635c4bbdfSmrg if (IS_OPTION("-config") 93735c4bbdfSmrg || IS_OPTION("-xf86config")) { 93835c4bbdfSmrg CHECK_ARGS(1); 93905b261ecSmrg#ifdef XWIN_XF86CONFIG 94035c4bbdfSmrg g_cmdline.configFile = argv[++i]; 94105b261ecSmrg#else 94235c4bbdfSmrg winMessageBoxF("The %s option is not supported in this " 94335c4bbdfSmrg "release.\n" 94435c4bbdfSmrg "Ignoring this option and continuing.\n", 94535c4bbdfSmrg MB_ICONINFORMATION, argv[i]); 94605b261ecSmrg#endif 94735c4bbdfSmrg return 2; 94805b261ecSmrg } 94905b261ecSmrg 95035c4bbdfSmrg /* 95135c4bbdfSmrg * Look for the '-configdir' argument 95235c4bbdfSmrg */ 95335c4bbdfSmrg if (IS_OPTION("-configdir")) { 95435c4bbdfSmrg CHECK_ARGS(1); 9556747b715Smrg#ifdef XWIN_XF86CONFIG 95635c4bbdfSmrg g_cmdline.configDir = argv[++i]; 9576747b715Smrg#else 95835c4bbdfSmrg winMessageBoxF("The %s option is not supported in this " 95935c4bbdfSmrg "release.\n" 96035c4bbdfSmrg "Ignoring this option and continuing.\n", 96135c4bbdfSmrg MB_ICONINFORMATION, argv[i]); 9626747b715Smrg#endif 96335c4bbdfSmrg return 2; 9646747b715Smrg } 9656747b715Smrg 96635c4bbdfSmrg /* 96735c4bbdfSmrg * Look for the '-keyboard' argument 96835c4bbdfSmrg */ 96935c4bbdfSmrg if (IS_OPTION("-keyboard")) { 97005b261ecSmrg#ifdef XWIN_XF86CONFIG 97135c4bbdfSmrg CHECK_ARGS(1); 97235c4bbdfSmrg g_cmdline.keyboard = argv[++i]; 97305b261ecSmrg#else 97435c4bbdfSmrg winMessageBoxF("The -keyboard option is not supported in this " 97535c4bbdfSmrg "release.\n" 97635c4bbdfSmrg "Ignoring this option and continuing.\n", 97735c4bbdfSmrg MB_ICONINFORMATION); 97805b261ecSmrg#endif 97935c4bbdfSmrg return 2; 98005b261ecSmrg } 98105b261ecSmrg 98235c4bbdfSmrg /* 98335c4bbdfSmrg * Look for the '-logfile' argument 98435c4bbdfSmrg */ 98535c4bbdfSmrg if (IS_OPTION("-logfile")) { 98635c4bbdfSmrg CHECK_ARGS(1); 98735c4bbdfSmrg g_pszLogFile = argv[++i]; 98805b261ecSmrg#ifdef RELOCATE_PROJECTROOT 98935c4bbdfSmrg g_fLogFileChanged = TRUE; 99005b261ecSmrg#endif 99135c4bbdfSmrg return 2; 99205b261ecSmrg } 99305b261ecSmrg 99435c4bbdfSmrg /* 99535c4bbdfSmrg * Look for the '-logverbose' argument 99635c4bbdfSmrg */ 99735c4bbdfSmrg if (IS_OPTION("-logverbose")) { 99835c4bbdfSmrg CHECK_ARGS(1); 99935c4bbdfSmrg g_iLogVerbose = atoi(argv[++i]); 100035c4bbdfSmrg return 2; 100105b261ecSmrg } 100205b261ecSmrg 100335c4bbdfSmrg /* 100435c4bbdfSmrg * Look for the '-nounicodeclipboard' argument 100535c4bbdfSmrg */ 100635c4bbdfSmrg if (IS_OPTION("-nounicodeclipboard")) { 100735c4bbdfSmrg g_fUnicodeClipboard = FALSE; 100835c4bbdfSmrg /* Indicate that we have processed the argument */ 100935c4bbdfSmrg return 1; 101005b261ecSmrg } 101105b261ecSmrg 101235c4bbdfSmrg if (IS_OPTION("-xkbrules")) { 101335c4bbdfSmrg CHECK_ARGS(1); 101435c4bbdfSmrg g_cmdline.xkbRules = argv[++i]; 101535c4bbdfSmrg return 2; 101605b261ecSmrg } 101735c4bbdfSmrg if (IS_OPTION("-xkbmodel")) { 101835c4bbdfSmrg CHECK_ARGS(1); 101935c4bbdfSmrg g_cmdline.xkbModel = argv[++i]; 102035c4bbdfSmrg return 2; 102105b261ecSmrg } 102235c4bbdfSmrg if (IS_OPTION("-xkblayout")) { 102335c4bbdfSmrg CHECK_ARGS(1); 102435c4bbdfSmrg g_cmdline.xkbLayout = argv[++i]; 102535c4bbdfSmrg return 2; 102605b261ecSmrg } 102735c4bbdfSmrg if (IS_OPTION("-xkbvariant")) { 102835c4bbdfSmrg CHECK_ARGS(1); 102935c4bbdfSmrg g_cmdline.xkbVariant = argv[++i]; 103035c4bbdfSmrg return 2; 103105b261ecSmrg } 103235c4bbdfSmrg if (IS_OPTION("-xkboptions")) { 103335c4bbdfSmrg CHECK_ARGS(1); 103435c4bbdfSmrg g_cmdline.xkbOptions = argv[++i]; 103535c4bbdfSmrg return 2; 103605b261ecSmrg } 103705b261ecSmrg 103835c4bbdfSmrg if (IS_OPTION("-keyhook")) { 103935c4bbdfSmrg g_fKeyboardHookLL = TRUE; 104035c4bbdfSmrg return 1; 104105b261ecSmrg } 104235c4bbdfSmrg 104335c4bbdfSmrg if (IS_OPTION("-nokeyhook")) { 104435c4bbdfSmrg g_fKeyboardHookLL = FALSE; 104535c4bbdfSmrg return 1; 104605b261ecSmrg } 104735c4bbdfSmrg 104835c4bbdfSmrg if (IS_OPTION("-swcursor")) { 104935c4bbdfSmrg g_fSoftwareCursor = TRUE; 105035c4bbdfSmrg return 1; 105105b261ecSmrg } 105235c4bbdfSmrg 105335c4bbdfSmrg if (IS_OPTION("-wgl")) { 105435c4bbdfSmrg g_fNativeGl = TRUE; 105535c4bbdfSmrg return 1; 10566747b715Smrg } 10576747b715Smrg 105835c4bbdfSmrg if (IS_OPTION("-nowgl")) { 105935c4bbdfSmrg g_fNativeGl = FALSE; 106035c4bbdfSmrg return 1; 10616747b715Smrg } 10626747b715Smrg 106335c4bbdfSmrg if (IS_OPTION("-hostintitle")) { 106435c4bbdfSmrg g_fHostInTitle = TRUE; 106535c4bbdfSmrg return 1; 106635c4bbdfSmrg } 106705b261ecSmrg 106835c4bbdfSmrg if (IS_OPTION("-nohostintitle")) { 106935c4bbdfSmrg g_fHostInTitle = FALSE; 107035c4bbdfSmrg return 1; 107135c4bbdfSmrg } 107235c4bbdfSmrg 107335c4bbdfSmrg return 0; 107435c4bbdfSmrg} 107505b261ecSmrg 107605b261ecSmrg/* 107705b261ecSmrg * winLogCommandLine - Write entire command line to the log file 107805b261ecSmrg */ 107905b261ecSmrg 108005b261ecSmrgvoid 108135c4bbdfSmrgwinLogCommandLine(int argc, char *argv[]) 108205b261ecSmrg{ 108335c4bbdfSmrg int i; 108435c4bbdfSmrg int iSize = 0; 108535c4bbdfSmrg int iCurrLen = 0; 108605b261ecSmrg 108705b261ecSmrg#define CHARS_PER_LINE 60 108805b261ecSmrg 108935c4bbdfSmrg /* Bail if command line has already been logged */ 109035c4bbdfSmrg if (g_pszCommandLine) 109135c4bbdfSmrg return; 109235c4bbdfSmrg 109335c4bbdfSmrg /* Count how much memory is needed for concatenated command line */ 109435c4bbdfSmrg for (i = 0, iCurrLen = 0; i < argc; ++i) 109535c4bbdfSmrg if (argv[i]) { 109635c4bbdfSmrg /* Adds two characters for lines that overflow */ 109735c4bbdfSmrg if ((strlen(argv[i]) < CHARS_PER_LINE 109835c4bbdfSmrg && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) 109935c4bbdfSmrg || strlen(argv[i]) > CHARS_PER_LINE) { 110035c4bbdfSmrg iCurrLen = 0; 110135c4bbdfSmrg iSize += 2; 110235c4bbdfSmrg } 110335c4bbdfSmrg 110435c4bbdfSmrg /* Add space for item and trailing space */ 110535c4bbdfSmrg iSize += strlen(argv[i]) + 1; 110635c4bbdfSmrg 110735c4bbdfSmrg /* Update current line length */ 110835c4bbdfSmrg iCurrLen += strlen(argv[i]); 110935c4bbdfSmrg } 111035c4bbdfSmrg 111135c4bbdfSmrg /* Allocate memory for concatenated command line */ 111235c4bbdfSmrg g_pszCommandLine = malloc(iSize + 1); 111335c4bbdfSmrg if (!g_pszCommandLine) 111435c4bbdfSmrg FatalError("winLogCommandLine - Could not allocate memory for " 111535c4bbdfSmrg "command line string. Exiting.\n"); 111635c4bbdfSmrg 111735c4bbdfSmrg /* Set first character to concatenated command line to null */ 111835c4bbdfSmrg g_pszCommandLine[0] = '\0'; 111935c4bbdfSmrg 112035c4bbdfSmrg /* Loop through all args */ 112135c4bbdfSmrg for (i = 0, iCurrLen = 0; i < argc; ++i) { 112235c4bbdfSmrg /* Add a character for lines that overflow */ 112335c4bbdfSmrg if ((strlen(argv[i]) < CHARS_PER_LINE 112435c4bbdfSmrg && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) 112535c4bbdfSmrg || strlen(argv[i]) > CHARS_PER_LINE) { 112635c4bbdfSmrg iCurrLen = 0; 112735c4bbdfSmrg 112835c4bbdfSmrg /* Add line break if it fits */ 112935c4bbdfSmrg strncat(g_pszCommandLine, "\n ", iSize - strlen(g_pszCommandLine)); 113035c4bbdfSmrg } 113135c4bbdfSmrg 113235c4bbdfSmrg strncat(g_pszCommandLine, argv[i], iSize - strlen(g_pszCommandLine)); 113335c4bbdfSmrg strncat(g_pszCommandLine, " ", iSize - strlen(g_pszCommandLine)); 113435c4bbdfSmrg 113535c4bbdfSmrg /* Save new line length */ 113635c4bbdfSmrg iCurrLen += strlen(argv[i]); 113705b261ecSmrg } 113805b261ecSmrg 113935c4bbdfSmrg ErrorF("XWin was started with the following command line:\n\n" 114035c4bbdfSmrg "%s\n\n", g_pszCommandLine); 114105b261ecSmrg} 114205b261ecSmrg 114305b261ecSmrg/* 114435c4bbdfSmrg * winLogVersionInfo - Log version information 114505b261ecSmrg */ 114605b261ecSmrg 114705b261ecSmrgvoid 114835c4bbdfSmrgwinLogVersionInfo(void) 114905b261ecSmrg{ 115035c4bbdfSmrg static Bool s_fBeenHere = FALSE; 115105b261ecSmrg 115235c4bbdfSmrg if (s_fBeenHere) 115335c4bbdfSmrg return; 115435c4bbdfSmrg s_fBeenHere = TRUE; 115505b261ecSmrg 115635c4bbdfSmrg ErrorF("Welcome to the XWin X Server\n"); 115735c4bbdfSmrg ErrorF("Vendor: %s\n", XVENDORNAME); 115835c4bbdfSmrg ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR, 115935c4bbdfSmrg XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP); 116035c4bbdfSmrg#ifdef HAVE_SYS_UTSNAME_H 116135c4bbdfSmrg { 116235c4bbdfSmrg struct utsname name; 116335c4bbdfSmrg 116435c4bbdfSmrg if (uname(&name) >= 0) { 116535c4bbdfSmrg ErrorF("OS: %s %s %s %s %s\n", name.sysname, name.nodename, 116635c4bbdfSmrg name.release, name.version, name.machine); 116735c4bbdfSmrg } 116835c4bbdfSmrg } 116935c4bbdfSmrg#endif 117035c4bbdfSmrg winOS(); 117135c4bbdfSmrg if (strlen(BUILDERSTRING)) 117235c4bbdfSmrg ErrorF("%s\n", BUILDERSTRING); 117335c4bbdfSmrg ErrorF("Contact: %s\n", BUILDERADDR); 117435c4bbdfSmrg ErrorF("\n"); 117505b261ecSmrg} 1176