void InitOutput(ScreenInfo * screenInfo, int argc, char *argv[]) { int i; /* Log the command line */ winLogCommandLine(argc, argv); #if CYGDEBUG winDebug("InitOutput\n"); #endif /* Validate command-line arguments */ if (serverGeneration == 1 && !winValidateArgs()) { FatalError("InitOutput - Invalid command-line arguments found. " "Exiting.\n"); } /* Check for duplicate invocation on same display number. */ if (serverGeneration == 1 && !winCheckDisplayNumber()) { if (g_fSilentDupError) g_fSilentFatalError = TRUE; FatalError("InitOutput - Duplicate invocation on display " "number: %s. Exiting.\n", display); } #ifdef XWIN_XF86CONFIG /* Try to read the xorg.conf-style configuration file */ if (!winReadConfigfile()) winErrorFVerb(1, "InitOutput - Error reading config file\n"); #else winMsg(X_INFO, "xorg.conf is not supported\n"); winMsg(X_INFO, "See http://x.cygwin.com/docs/faq/cygwin-x-faq.html " "for more information\n"); winConfigFiles(); #endif /* Load preferences from XWinrc file */ LoadPreferences(); /* Setup global screen info parameters */ screenInfo->imageByteOrder = IMAGE_BYTE_ORDER; screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; screenInfo->numPixmapFormats = NUMFORMATS; /* Describe how we want common pixmap formats padded */ for (i = 0; i < NUMFORMATS; i++) { screenInfo->formats[i] = g_PixmapFormats[i]; } /* Load pointers to DirectDraw functions */ winGetDDProcAddresses(); /* Detect supported engines */ winDetectSupportedEngines(); /* Store the instance handle */ g_hInstance = GetModuleHandle(NULL); /* Initialize each screen */ for (i = 0; i < g_iNumScreens; ++i) { /* Initialize the screen */ if (-1 == AddScreen(winScreenInit, argc, argv)) { FatalError("InitOutput - Couldn't add screen %d", i); } } #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) /* Generate a cookie used by internal clients for authorization */ if (g_fXdmcpEnabled || g_fAuthEnabled) winGenerateAuthorization(); /* Perform some one time initialization */ if (1 == serverGeneration) { /* * setlocale applies to all threads in the current process. * Apply locale specified in LANG environment variable. */ setlocale(LC_ALL, ""); } #endif #if CYGDEBUG || YES winDebug("InitOutput - Returning.\n"); #endif }
Bool winReadConfigfile() { Bool retval = TRUE; char *filename, *dirname; MessageType filefrom = X_DEFAULT; MessageType dirfrom = X_DEFAULT; char *xf86ConfigFile = NULL; char *xf86ConfigDir = NULL; if (g_cmdline.configFile) { filefrom = X_CMDLINE; xf86ConfigFile = g_cmdline.configFile; } if (g_cmdline.configDir) { dirfrom = X_CMDLINE; xf86ConfigDir = g_cmdline.configDir; } /* Parse config file into data structure */ xf86initConfigFiles(); dirname = xf86openConfigDirFiles(CONFIGDIRPATH, xf86ConfigDir, PROJECTROOT); filename = xf86openConfigFile(CONFIGPATH, xf86ConfigFile, PROJECTROOT); /* Hack for backward compatibility */ if (!filename && from == X_DEFAULT) filename = xf86openConfigFile(CONFIGPATH, "XF86Config", PROJECTROOT); if (filename) { winDebug ("Using config file: \"%s\"\n", filename); } else { ErrorF ("Unable to locate/open config file"); if (xf86ConfigFile) ErrorF(": \"%s\"", xf86ConfigFile); ErrorF("\n"); } if (dirname) { winDebug("Using config directory: \"%s\"\n", dirname); } else { winDebug("Unable to locate/open config directory"); if (xf86ConfigDir) ErrorF(": \"%s\"", xf86ConfigDir); ErrorF("\n"); } if (!filename && !dirname) { return FALSE; } free(filename); free(dirname); if ((g_xf86configptr = xf86readConfigFile()) == NULL) { ErrorF ("Problem parsing the config file\n"); return FALSE; } xf86closeConfigFile(); LogPrintMarkers(); /* set options from data structure */ if (g_xf86configptr->conf_layout_lst == NULL || g_cmdline.screenname != NULL) { if (g_cmdline.screenname == NULL) { winDebug ("No Layout section. Using the first Screen section.\n"); } if (!configImpliedLayout(&g_winConfigLayout, g_xf86configptr->conf_screen_lst)) { ErrorF ("Unable to determine the screen layout\n"); return FALSE; } } else { /* Check if layout is given in the config file */ if (g_xf86configptr->conf_flags != NULL) { char *dfltlayout = NULL; void *optlist = g_xf86configptr->conf_flags->flg_option_lst; if (optlist && winFindOption(optlist, "defaultserverlayout")) dfltlayout = winSetStrOption(optlist, "defaultserverlayout", NULL); if (!configLayout(&g_winConfigLayout, g_xf86configptr->conf_layout_lst, dfltlayout)) { ErrorF ("Unable to determine the screen layout\n"); return FALSE; } } else { if (!configLayout(&g_winConfigLayout, g_xf86configptr->conf_layout_lst, NULL)) { ErrorF ("Unable to determine the screen layout\n"); return FALSE; } } } /* setup special config files */ winConfigFiles(); return retval; }
void InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[]) { int i; if (serverGeneration == 1) XwinExtensionInit(); /* Log the command line */ winLogCommandLine(argc, argv); #if CYGDEBUG winDebug("InitOutput\n"); #endif /* Validate command-line arguments */ if (serverGeneration == 1 && !winValidateArgs()) { FatalError("InitOutput - Invalid command-line arguments found. " "Exiting.\n"); } /* Check for duplicate invocation on same display number. */ if (serverGeneration == 1 && !winCheckDisplayNumber()) { if (g_fSilentDupError) g_fSilentFatalError = TRUE; FatalError("InitOutput - Duplicate invocation on display " "number: %s. Exiting.\n", display); } #ifdef XWIN_XF86CONFIG /* Try to read the xorg.conf-style configuration file */ if (!winReadConfigfile()) winErrorFVerb(1, "InitOutput - Error reading config file\n"); #else winMsg(X_INFO, "xorg.conf is not supported\n"); winMsg(X_INFO, "See http://x.cygwin.com/docs/faq/cygwin-x-faq.html " "for more information\n"); winConfigFiles(); #endif /* Load preferences from XWinrc file */ LoadPreferences(); /* Setup global screen info parameters */ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; pScreenInfo->numPixmapFormats = NUMFORMATS; /* Describe how we want common pixmap formats padded */ for (i = 0; i < NUMFORMATS; i++) { pScreenInfo->formats[i] = g_PixmapFormats[i]; } /* Load pointers to DirectDraw functions */ winGetDDProcAddresses(); /* Detect supported engines */ winDetectSupportedEngines(); #ifdef XWIN_MULTIWINDOW /* Load libraries for taskbar grouping */ winPropertyStoreInit(); #endif /* Store the instance handle */ g_hInstance = GetModuleHandle(NULL); /* Create the messaging window */ if (serverGeneration == 1) winCreateMsgWindowThread(); /* Initialize each screen */ for (i = 0; i < g_iNumScreens; ++i) { /* Initialize the screen */ if (-1 == AddScreen(winScreenInit, argc, argv)) { FatalError("InitOutput - Couldn't add screen %d", i); } } /* Unless full xinerama has been explicitly enabled, register all native screens with pseudoramiX */ if (!noPanoramiXExtension) noPseudoramiXExtension = TRUE; if ((g_ScreenInfo[0].fMultipleMonitors) && !noPseudoramiXExtension) { int pass; PseudoramiXExtensionInit(); /* Add primary monitor on pass 0, other monitors on pass 1, to ensure the primary monitor is first in XINERAMA list */ for (pass = 0; pass < 2; pass++) { int iMonitor; for (iMonitor = 1; ; iMonitor++) { struct GetMonitorInfoData data; QueryMonitor(iMonitor, &data); if (data.bMonitorSpecifiedExists) { MONITORINFO mi; mi.cbSize = sizeof(MONITORINFO); if (GetMonitorInfo(data.monitorHandle, &mi)) { /* pass == 1 XOR primary monitor flags is set */ if ((!(pass == 1)) != (!(mi.dwFlags & MONITORINFOF_PRIMARY))) { /* Note the screen origin in a normalized coordinate space where (0,0) is at the top left of the native virtual desktop area */ data.monitorOffsetX = data.monitorOffsetX - GetSystemMetrics(SM_XVIRTUALSCREEN); data.monitorOffsetY = data.monitorOffsetY - GetSystemMetrics(SM_YVIRTUALSCREEN); winDebug ("InitOutput - screen %d added at virtual desktop coordinate (%d,%d) (pseudoramiX) \n", iMonitor-1, data.monitorOffsetX, data.monitorOffsetY); PseudoramiXAddScreen(data.monitorOffsetX, data.monitorOffsetY, data.monitorWidth, data.monitorHeight); } } } else break; } } } #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) /* Generate a cookie used by internal clients for authorization */ if (g_fXdmcpEnabled || g_fAuthEnabled) winGenerateAuthorization(); /* Perform some one time initialization */ if (1 == serverGeneration) { /* * setlocale applies to all threads in the current process. * Apply locale specified in LANG environment variable. */ setlocale(LC_ALL, ""); } #endif #if CYGDEBUG || YES winDebug("InitOutput - Returning.\n"); #endif }