static int set_xinerama(int xinerama_enabled, XConfigLayoutPtr layout) { xconfigAddNewOption(&(layout->options), "Xinerama", (xinerama_enabled ? "1" : "0")); return TRUE; } /* set_xinerama() */
XConfigInputPtr xconfigParsePointerSection (void) { char *s, *s1, *s2; int l; int token; PARSE_PROLOGUE (XConfigInputPtr, XConfigInputRec) while ((token = xconfigGetToken (PointerTab)) != ENDSECTION) { switch (token) { case COMMENT: ptr->comment = xconfigAddComment(ptr->comment, val.str); break; case PROTOCOL: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "Protocol"); xconfigAddNewOption(&ptr->options, "Protocol", val.str); break; case PDEVICE: if (xconfigGetSubToken (&(ptr->comment)) != STRING) Error (QUOTE_MSG, "Device"); xconfigAddNewOption(&ptr->options, "Device", val.str); break; case EMULATE3: xconfigAddNewOption(&ptr->options, "Emulate3Buttons", NULL); break; case EM3TIMEOUT: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Emulate3Timeout"); s = xconfigULongToString(val.num); xconfigAddNewOption(&ptr->options, "Emulate3Timeout", s); TEST_FREE(s); break; case CHORDMIDDLE: xconfigAddNewOption(&ptr->options, "ChordMiddle", NULL); break; case PBUTTONS: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Buttons"); s = xconfigULongToString(val.num); xconfigAddNewOption(&ptr->options, "Buttons", s); TEST_FREE(s); break; case BAUDRATE: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "BaudRate"); s = xconfigULongToString(val.num); xconfigAddNewOption(&ptr->options, "BaudRate", s); TEST_FREE(s); break; case SAMPLERATE: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "SampleRate"); s = xconfigULongToString(val.num); xconfigAddNewOption(&ptr->options, "SampleRate", s); TEST_FREE(s); break; case PRESOLUTION: if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (POSITIVE_INT_MSG, "Resolution"); s = xconfigULongToString(val.num); xconfigAddNewOption(&ptr->options, "Resolution", s); TEST_FREE(s); break; case CLEARDTR: xconfigAddNewOption(&ptr->options, "ClearDTR", NULL); break; case CLEARRTS: xconfigAddNewOption(&ptr->options, "ClearRTS", NULL); break; case ZAXISMAPPING: switch (xconfigGetToken(ZMapTab)) { case NUMBER: if (val.num < 0) Error (ZAXISMAPPING_MSG, NULL); s1 = xconfigULongToString(val.num); if (xconfigGetSubToken (&(ptr->comment)) != NUMBER || val.num < 0) Error (ZAXISMAPPING_MSG, NULL); s2 = xconfigULongToString(val.num); l = strlen(s1) + 1 + strlen(s2) + 1; s = malloc(l); sprintf(s, "%s %s", s1, s2); free(s1); free(s2); break; case XAXIS: s = xconfigStrdup("x"); break; case YAXIS: s = xconfigStrdup("y"); break; default: Error (ZAXISMAPPING_MSG, NULL); break; } xconfigAddNewOption(&ptr->options, "ZAxisMapping", s); TEST_FREE(s); break; case ALWAYSCORE: break; case EOF_TOKEN: Error (UNEXPECTED_EOF_MSG, NULL); break; default: Error (INVALID_KEYWORD_MSG, xconfigTokenString ()); break; } } ptr->identifier = xconfigStrdup(CONF_IMPLICIT_POINTER); ptr->driver = xconfigStrdup("mouse"); xconfigAddNewOption(&ptr->options, "CorePointer", NULL); return ptr; }
static int getCoreInputDevice(GenerateOptions *gop, XConfigPtr config, XConfigLayoutPtr layout, const int mouse, const char *coreKeyword, const char *implicitDriverName, const char *defaultDriver0, const char *defaultDriver1, const char *foundMsg0, const char *foundMsg1) { XConfigInputPtr input, core = NULL; XConfigInputrefPtr inputRef; int found, firstTry; const char *found_msg = NULL; /* * First check if the core input device has been specified in the * active ServerLayout. If more than one is specified, remove the * core attribute from the later ones. */ for (inputRef = layout->inputs; inputRef; inputRef = inputRef->next) { XConfigOptionPtr opt1 = NULL, opt2 = NULL; input = inputRef->input; opt1 = xconfigFindOption(input->options, coreKeyword); opt2 = xconfigFindOption(inputRef->options, coreKeyword); if (opt1 || opt2) { if (!core) { core = input; } else { if (opt1) { xconfigRemoveOption(&input->options, opt1); } if (opt2) { xconfigRemoveOption(&inputRef->options, opt2); } xconfigErrorMsg(WarnMsg, "Duplicate %s devices; removing %s " "attribute from \"%s\"\n", coreKeyword, coreKeyword, input->identifier); } } } /* * XXX XFree86 allows the commandline to override the core input * devices; let's not bother with that, here. */ /* * if we didn't find a core input device above in the * serverLayout, scan through the config's entire input list and * pick the first one with the coreKeyword. */ if (!core) { for (input = config->inputs; input; input = input->next) { if (xconfigFindOption(input->options, coreKeyword)) { core = input; found_msg = foundMsg0; break; } } } /* * if we didn't find a core input device above, then select the * first input with the correct driver */ firstTry = TRUE; tryAgain: if (!core) { input = xconfigFindInput(implicitDriverName, config->inputs); if (!input && defaultDriver0) { input = xconfigFindInputByDriver(defaultDriver0, config->inputs); } if (!input && defaultDriver1) { input = xconfigFindInputByDriver(defaultDriver1, config->inputs); } if (input) { core = input; found_msg = foundMsg1; } } /* * if we didn't find a core input device above, then that means we * don't have any input devices of this type; try to add a new * input device of this type, and then try again to find a core * input device */ if (!core && firstTry) { firstTry = FALSE; xconfigErrorMsg(WarnMsg, "Unable to find %s in X configuration; " "attempting to add new %s section.", coreKeyword, coreKeyword); if (mouse) { xconfigAddMouse(gop, config); } else { xconfigAddKeyboard(gop, config); } goto tryAgain; } /* * if we *still* can't find a core input device, print a warning * message and give up; hopefully the X server's builtin config * will do. */ if (!core) { xconfigErrorMsg(WarnMsg, "Unable to determine %s; will rely on X " "server's built-in default configuration.", coreKeyword); /* don't return FALSE here -- we don't want nvidia-xconfig to fail */ return TRUE; } /* * make sure the core input device is in the layout's input list */ found = FALSE; for (inputRef = layout->inputs; inputRef; inputRef = inputRef->next) { if (inputRef->input == core) { found = TRUE; break; } } if (!found) { inputRef = calloc(1, sizeof(XConfigInputrefRec)); inputRef->input = core; inputRef->input_name = strdup(core->identifier); inputRef->next = layout->inputs; layout->inputs = inputRef; } /* * make sure the core input device has the core keyword set */ for (inputRef = layout->inputs; inputRef; inputRef = inputRef->next) { if (inputRef->input == core) { XConfigOptionPtr opt1 = NULL, opt2 = NULL; opt1 = xconfigFindOption(inputRef->input->options, coreKeyword); opt2 = xconfigFindOption(inputRef->options, coreKeyword); if (!opt1 && !opt2) { xconfigAddNewOption(&inputRef->options, coreKeyword, NULL); } break; } } if (found_msg) { xconfigErrorMsg(WarnMsg, "The %s device was not specified explicitly " "in the layout; using the %s.\n", coreKeyword, found_msg); } return TRUE; }