static void winCheckMount(void) { FILE *mnt; struct mntent *ent; enum { none = 0, sys_root, user_root, sys_tmp, user_tmp } level = none, curlevel; BOOL binary = TRUE; mnt = setmntent("/etc/mtab", "r"); if (mnt == NULL) { ErrorF("setmntent failed"); return; } while ((ent = getmntent(mnt)) != NULL) { BOOL system = (winCheckMntOpt(ent, "user") != NULL); BOOL root = (strcmp(ent->mnt_dir, "/") == 0); BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0); if (system) { if (root) curlevel = sys_root; else if (tmp) curlevel = sys_tmp; else continue; } else { if (root) curlevel = user_root; else if (tmp) curlevel = user_tmp; else continue; } if (curlevel <= level) continue; level = curlevel; if ((winCheckMntOpt(ent, "binary") == NULL) && (winCheckMntOpt(ent, "binmode") == NULL)) binary = FALSE; else binary = TRUE; } if (endmntent(mnt) != 1) { ErrorF("endmntent failed"); return; } if (!binary) winMsg(X_WARNING, "/tmp mounted in textmode\n"); }
/* Set the keyboard configuration */ Bool winConfigKeyboard(DeviceIntPtr pDevice) { char layoutName[KL_NAMELENGTH]; unsigned char layoutFriendlyName[256]; unsigned int layoutNum = 0; unsigned int deviceIdentifier = 0; int keyboardType; #ifdef XWIN_XF86CONFIG XF86ConfInputPtr kbd = NULL; XF86ConfInputPtr input_list = NULL; MessageType kbdfrom = X_CONFIG; #endif MessageType from = X_DEFAULT; char *s = NULL; /* Setup defaults */ XkbGetRulesDflts(&g_winInfo.xkb); /* * Query the windows autorepeat settings and change the xserver defaults. */ { int kbd_delay; DWORD kbd_speed; if (SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &kbd_delay, 0) && SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &kbd_speed, 0)) { switch (kbd_delay) { case 0: g_winInfo.keyboard.delay = 250; break; case 1: g_winInfo.keyboard.delay = 500; break; case 2: g_winInfo.keyboard.delay = 750; break; default: case 3: g_winInfo.keyboard.delay = 1000; break; } g_winInfo.keyboard.rate = (kbd_speed > 0) ? kbd_speed : 1; winMsg(X_PROBED, "Setting autorepeat to delay=%ld, rate=%ld\n", g_winInfo.keyboard.delay, g_winInfo.keyboard.rate); } } keyboardType = GetKeyboardType(0); if (keyboardType > 0 && GetKeyboardLayoutName(layoutName)) { WinKBLayoutPtr pLayout; Bool bfound = FALSE; int pass; layoutNum = strtoul(layoutName, (char **) NULL, 16); if ((layoutNum & 0xffff) == 0x411) { if (keyboardType == 7) { /* Japanese layouts have problems with key event messages such as the lack of WM_KEYUP for Caps Lock key. Loading US layout fixes this problem. */ if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL) winMsg(X_INFO, "Loading US keyboard layout.\n"); else winMsg(X_ERROR, "LoadKeyboardLayout failed.\n"); } } /* Discover the friendly name of the current layout */ { HKEY regkey = NULL; const char regtempl[] = "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"; char *regpath; DWORD namesize = sizeof(layoutFriendlyName); regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1); strcpy(regpath, regtempl); strcat(regpath, layoutName); if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, ®key)) RegQueryValueEx(regkey, "Layout Text", 0, NULL, layoutFriendlyName, &namesize); /* Close registry key */ if (regkey) RegCloseKey(regkey); free(regpath); } winMsg(X_PROBED, "Windows keyboard layout: \"%s\" (%08x) \"%s\", type %d\n", layoutName, layoutNum, layoutFriendlyName, keyboardType); deviceIdentifier = layoutNum >> 16; for (pass = 0; pass < 2; pass++) { /* If we didn't find an exact match for the input locale identifer, try to find an match on the language identifier part only */ if (pass == 1) layoutNum = (layoutNum & 0xffff); for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) { if (pLayout->winlayout != layoutNum) continue; if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType) continue; bfound = TRUE; winMsg(X_PROBED, "Found matching XKB configuration \"%s\"\n", pLayout->layoutname); winMsg(X_PROBED, "Model = \"%s\" Layout = \"%s\"" " Variant = \"%s\" Options = \"%s\"\n", pLayout->xkbmodel ? pLayout->xkbmodel : "none", pLayout->xkblayout ? pLayout->xkblayout : "none", pLayout->xkbvariant ? pLayout->xkbvariant : "none", pLayout->xkboptions ? pLayout->xkboptions : "none"); g_winInfo.xkb.model = pLayout->xkbmodel; g_winInfo.xkb.layout = pLayout->xkblayout; g_winInfo.xkb.variant = pLayout->xkbvariant; g_winInfo.xkb.options = pLayout->xkboptions; if (deviceIdentifier == 0xa000) { winMsg(X_PROBED, "Windows keyboard layout device identifier indicates Macintosh, setting Model = \"macintosh\""); g_winInfo.xkb.model = "macintosh"; } break; } if (bfound) break; } if (!bfound) { winMsg(X_ERROR, "Keyboardlayout \"%s\" (%s) is unknown, using X server default layout\n", layoutFriendlyName, layoutName); } }
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) { winMsg(from, "Using config file: \"%s\"\n", filename); } else { winMsg(X_ERROR, "Unable to locate/open config file"); if (xf86ConfigFile) ErrorF(": \"%s\"", xf86ConfigFile); ErrorF("\n"); } if (dirname) { winMsg(from, "Using config directory: \"%s\"\n", dirname); } else { winMsg(X_ERROR, "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) { winMsg(X_ERROR, "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) { winMsg(X_WARNING, "No Layout section. Using the first Screen section.\n"); } if (!configImpliedLayout(&g_winConfigLayout, g_xf86configptr->conf_screen_lst)) { winMsg(X_ERROR, "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)) { winMsg(X_ERROR, "Unable to determine the screen layout\n"); return FALSE; } } else { if (!configLayout(&g_winConfigLayout, g_xf86configptr->conf_layout_lst, NULL)) { winMsg(X_ERROR, "Unable to determine the screen layout\n"); return FALSE; } } } /* setup special config files */ winConfigFiles(); return retval; }
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 }
void OsVendorInit(void) { /* Re-initialize global variables on server reset */ winInitializeGlobals(); winFixupPaths(); #ifdef DDXOSVERRORF if (!OsVendorVErrorFProc) OsVendorVErrorFProc = OsVendorVErrorF; #endif if (!g_fLogInited) { /* keep this order. If LogInit fails it calls Abort which then calls * ddxGiveUp where LogInit is called again and creates an infinite * recursion. If we set g_fLogInited to TRUE before the init we * avoid the second call */ g_fLogInited = TRUE; g_pszLogFile = LogInit(g_pszLogFile, NULL); } LogSetParameter(XLOG_FLUSH, 1); LogSetParameter(XLOG_VERBOSITY, g_iLogVerbose); LogSetParameter(XLOG_FILE_VERBOSITY, g_iLogVerbose); /* Log the version information */ if (serverGeneration == 1) winLogVersionInfo(); winCheckMount(); /* Add a default screen if no screens were specified */ if (g_iNumScreens == 0) { winDebug("OsVendorInit - Creating default screen 0\n"); /* * We need to initialize the default screen 0 if no -screen * arguments were processed. * * Add a screen 0 using the defaults set by winInitializeDefaultScreens() * and any additional default screen parameters given */ winInitializeScreens(1); /* We have to flag this as an explicit screen, even though it isn't */ g_ScreenInfo[0].fExplicitScreen = TRUE; } /* Work out what the default emulate3buttons setting should be, and apply it if nothing was explicitly specified */ { int mouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS); int j; for (j = 0; j < g_iNumScreens; j++) { if (g_ScreenInfo[j].iE3BTimeout == WIN_E3B_DEFAULT) { if (mouseButtons < 3) { static Bool reportOnce = TRUE; g_ScreenInfo[j].iE3BTimeout = WIN_DEFAULT_E3B_TIME; if (reportOnce) { reportOnce = FALSE; winMsg(X_PROBED, "Windows reports only %d mouse buttons, defaulting to -emulate3buttons\n", mouseButtons); } } else { g_ScreenInfo[j].iE3BTimeout = WIN_E3B_OFF; } } } } }
static void winFixupPaths(void) { BOOL changed_fontpath = FALSE; MessageType font_from = X_DEFAULT; #ifdef RELOCATE_PROJECTROOT const char *basedir = winGetBaseDir(); size_t basedirlen = strlen(basedir); #endif #ifdef READ_FONTDIRS { /* Open fontpath configuration file */ FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt"); if (fontdirs != NULL) { char buffer[256]; int needs_sep = TRUE; int comment_block = FALSE; /* get default fontpath */ char *fontpath = strdup(defaultFontPath); size_t size = strlen(fontpath); /* read all lines */ while (!feof(fontdirs)) { size_t blen; char *hashchar; char *str; int has_eol = FALSE; /* read one line */ str = fgets(buffer, sizeof(buffer), fontdirs); if (str == NULL) /* stop on error or eof */ break; if (strchr(str, '\n') != NULL) has_eol = TRUE; /* check if block is continued comment */ if (comment_block) { /* ignore all input */ *str = 0; blen = 0; if (has_eol) /* check if line ended in this block */ comment_block = FALSE; } else { /* find comment character. ignore all trailing input */ hashchar = strchr(str, '#'); if (hashchar != NULL) { *hashchar = 0; if (!has_eol) /* mark next block as continued comment */ comment_block = TRUE; } } /* strip whitespaces from beginning */ while (*str == ' ' || *str == '\t') str++; /* get size, strip whitespaces from end */ blen = strlen(str); while (blen > 0 && (str[blen - 1] == ' ' || str[blen - 1] == '\t' || str[blen - 1] == '\n')) { str[--blen] = 0; } /* still something left to add? */ if (blen > 0) { size_t newsize = size + blen; /* reserve one character more for ',' */ if (needs_sep) newsize++; /* allocate memory */ if (fontpath == NULL) fontpath = malloc(newsize + 1); else fontpath = realloc(fontpath, newsize + 1); /* add separator */ if (needs_sep) { fontpath[size] = ','; size++; needs_sep = FALSE; } /* mark next line as new entry */ if (has_eol) needs_sep = TRUE; /* add block */ strncpy(fontpath + size, str, blen); fontpath[newsize] = 0; size = newsize; } } /* cleanup */ fclose(fontdirs); defaultFontPath = strdup(fontpath); free(fontpath); changed_fontpath = TRUE; font_from = X_CONFIG; } } #endif /* READ_FONTDIRS */ #ifdef RELOCATE_PROJECTROOT { const char *libx11dir = PROJECTROOT "/lib/X11"; size_t libx11dir_len = strlen(libx11dir); char *newfp = NULL; size_t newfp_len = 0; const char *endptr, *ptr, *oldptr = defaultFontPath; endptr = oldptr + strlen(oldptr); ptr = strchr(oldptr, ','); if (ptr == NULL) ptr = endptr; while (ptr != NULL) { size_t oldfp_len = (ptr - oldptr); size_t newsize = oldfp_len; char *newpath = malloc(newsize + 1); strncpy(newpath, oldptr, newsize); newpath[newsize] = 0; if (strncmp(libx11dir, newpath, libx11dir_len) == 0) { char *compose; newsize = newsize - libx11dir_len + basedirlen; compose = malloc(newsize + 1); strcpy(compose, basedir); strncat(compose, newpath + libx11dir_len, newsize - basedirlen); compose[newsize] = 0; free(newpath); newpath = compose; } oldfp_len = newfp_len; if (oldfp_len > 0) newfp_len++; /* space for separator */ newfp_len += newsize; if (newfp == NULL) newfp = malloc(newfp_len + 1); else newfp = realloc(newfp, newfp_len + 1); if (oldfp_len > 0) { strcpy(newfp + oldfp_len, ","); oldfp_len++; } strcpy(newfp + oldfp_len, newpath); free(newpath); if (*ptr == 0) { oldptr = ptr; ptr = NULL; } else { oldptr = ptr + 1; ptr = strchr(oldptr, ','); if (ptr == NULL) ptr = endptr; } } defaultFontPath = strdup(newfp); free(newfp); changed_fontpath = TRUE; } #endif /* RELOCATE_PROJECTROOT */ if (changed_fontpath) winMsg(font_from, "FontPath set to \"%s\"\n", defaultFontPath); #ifdef RELOCATE_PROJECTROOT if (getenv("XKEYSYMDB") == NULL) { char buffer[MAX_PATH]; snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB", basedir); buffer[sizeof(buffer) - 1] = 0; putenv(buffer); } if (getenv("XERRORDB") == NULL) { char buffer[MAX_PATH]; snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB", basedir); buffer[sizeof(buffer) - 1] = 0; putenv(buffer); } if (getenv("XLOCALEDIR") == NULL) { char buffer[MAX_PATH]; snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale", basedir); buffer[sizeof(buffer) - 1] = 0; putenv(buffer); } if (getenv("HOME") == NULL) { char buffer[MAX_PATH + 5]; strncpy(buffer, "HOME=", 5); /* query appdata directory */ if (SHGetFolderPathA (NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, buffer + 5) == 0) { putenv(buffer); } else { winMsg(X_ERROR, "Can not determine HOME directory\n"); } } if (!g_fLogFileChanged) { static char buffer[MAX_PATH]; DWORD size = GetTempPath(sizeof(buffer), buffer); if (size && size < sizeof(buffer)) { snprintf(buffer + size, sizeof(buffer) - size, "XWin.%s.log", display); buffer[sizeof(buffer) - 1] = 0; g_pszLogFile = buffer; winMsg(X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile); } } { static char xkbbasedir[MAX_PATH]; snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir); if (sizeof(xkbbasedir) > 0) xkbbasedir[sizeof(xkbbasedir) - 1] = 0; XkbBaseDirectory = xkbbasedir; XkbBinDirectory = basedir; } #endif /* RELOCATE_PROJECTROOT */ }
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 }
int winMouseProc (DeviceIntPtr pDeviceInt, int iState) { int lngMouseButtons, i; int lngWheelEvents = 2; CARD8 *map; DevicePtr pDevice = (DevicePtr) pDeviceInt; switch (iState) { case DEVICE_INIT: /* Get number of mouse buttons */ lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS); /* Mapping of windows events to X events: * LEFT:1 MIDDLE:2 RIGHT:3 * SCROLL_UP:4 SCROLL_DOWN:5 * XBUTTON 1:6 XBUTTON 2:7 ... * * To map scroll wheel correctly we need at least the 3 normal buttons */ if (lngMouseButtons < 3) lngMouseButtons = 3; winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons); /* allocate memory: * number of buttons + 2x mouse wheel event + 1 extra (offset for map) */ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1)); /* initalize button map */ map[0] = 0; for (i=1; i <= lngMouseButtons + lngWheelEvents; i++) map[i] = i; InitPointerDeviceStruct (pDevice, map, lngMouseButtons + lngWheelEvents, GetMotionHistory, winMouseCtrl, GetMotionHistorySize(), 2); free(map); #if defined(XFree86Server) g_winMouseButtonMap = pDeviceInt->button->map; #endif break; case DEVICE_ON: pDevice->on = TRUE; break; case DEVICE_CLOSE: #if defined(XFree86Server) g_winMouseButtonMap = NULL; #endif case DEVICE_OFF: pDevice->on = FALSE; break; } return Success; }