/*ARGSUSED*/ static void RemoveOption(Widget w, XtPointer user_data, XtPointer call_data) { Arg args[1]; char *str; XtSetArg(args[0], XtNstring, &str); XtGetValues(name, args, 1); xf86removeOption(options, str); UpdateOptionList(); }
/*ARGSUSED*/ XtPointer MouseConfig(XtPointer config) { XF86ConfInputPtr mouse = (XF86ConfInputPtr)config; XF86OptionPtr option; char mouse_name[32]; Arg args[1]; static char *Device = "Device", *Protocol = "Protocol", *Emulate3Buttons = "Emulate3Buttons", *Emulate3Timeout = "Emulate3Timeout"; current_input = mouse; if (mouse != NULL) { emulate = xf86findOption(mouse->inp_option_lst, Emulate3Buttons) != NULL; if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) device = option->opt_val; else device = NULL; if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) protocol = option->opt_val; else protocol = NULL; XtSetArg(args[0], XtNstring, mouse->inp_identifier); XtSetValues(ident_widget, args, 1); } else { XF86ConfInputPtr input = XF86Config->conf_input_lst; int nmouses = 0; while (input != NULL) { if (strcasecmp(input->inp_driver, "mouse") == 0) ++nmouses; input = (XF86ConfInputPtr)(input->list.next); } do { XmuSnprintf(mouse_name, sizeof(mouse_name), "Mouse%d", nmouses); ++nmouses; } while (xf86findInput(mouse_name, XF86Config->conf_input_lst)); XtSetArg(args[0], XtNstring, mouse_name); XtSetValues(ident_widget, args, 1); emulate = True; device = NULL; protocol = NULL; } xf86info.cur_list = MOUSE; XtSetSensitive(back, xf86info.lists[MOUSE].cur_function > 0); XtSetSensitive(next, xf86info.lists[MOUSE].cur_function < xf86info.lists[MOUSE].num_functions - 1); (xf86info.lists[MOUSE].functions[xf86info.lists[MOUSE].cur_function]) (&xf86info); if (ConfigLoop(MouseConfigCheck) == True) { XtSetArg(args[0], XtNstring, &device); XtGetValues(text, args, 1); if (mouse == NULL) { mouse = XtNew(XF86ConfInputRec); mouse->list.next = NULL; mouse->inp_identifier = XtNewString(ident_string); mouse->inp_driver = XtNewString("mouse"); mouse->inp_option_lst = xf86newOption(XtNewString(Device), XtNewString(device)); xf86addNewOption(mouse->inp_option_lst, XtNewString(Protocol), XtNewString(protocol)); if (emulate) { xf86addNewOption(mouse->inp_option_lst, XtNewString(Emulate3Buttons), NULL); xf86addNewOption(mouse->inp_option_lst, XtNewString(Emulate3Timeout), XtNewString("50")); } mouse->inp_comment = NULL; } else { if ((option = xf86findOption(mouse->inp_option_lst, Device)) != NULL) { XtFree(option->opt_val); option->opt_val = XtNewString(device); XtFree(option->opt_comment); } else { if (mouse->inp_option_lst == NULL) mouse->inp_option_lst = xf86newOption(XtNewString(Device), XtNewString(device)); else xf86addNewOption(mouse->inp_option_lst, XtNewString(Device), XtNewString(device)); } if ((option = xf86findOption(mouse->inp_option_lst, Protocol)) != NULL) { XtFree(option->opt_val); option->opt_val = XtNewString(protocol); XtFree(option->opt_comment); } else xf86addNewOption(mouse->inp_option_lst, XtNewString(Protocol), XtNewString(protocol)); if (emulate == False) { xf86removeOption(&(mouse->inp_option_lst), Emulate3Buttons); xf86removeOption(&(mouse->inp_option_lst), Emulate3Timeout); } else if (emulate) { xf86addNewOption(mouse->inp_option_lst, XtNewString(Emulate3Buttons), NULL); xf86addNewOption(mouse->inp_option_lst, XtNewString(Emulate3Timeout), XtNewString("50")); } } if (strcasecmp(mouse->inp_identifier, ident_string)) xf86renameInput(XF86Config, mouse, ident_string); return ((XtPointer)mouse); } return (NULL); }
/* * Implementation */ XtPointer ScreenConfig(XtPointer conf) { XF86ConfDisplayPtr disp; Arg args[2]; int i, oldrotate; screen = (XF86ConfScreenPtr)conf; if (screen == NULL) return (NULL); XtSetArg(args[0], XtNstring, screen->scrn_identifier); XtSetValues(ident_widget, args, 1); if ((default_depth = screen->scrn_defaultdepth) <= 0) default_depth = 8; sel_index = unsel_index = -1; for (i = 0; i < computer.num_screens; i++) if (computer.screens[i]->screen == screen) { SetScreenRotate(computer.screens[i]); rotate = computer.screens[i]->rotate; } oldrotate = rotate; ndefmodes = 0; disp = screen->scrn_display_lst; while (disp != NULL) { if (disp->disp_depth == default_depth) { XF86ModePtr mod = disp->disp_mode_lst; while (mod != NULL) { if (ndefmodes % 16 == 0) defmodes = (char**) XtRealloc((XtPointer)defmodes, (ndefmodes + 16) * sizeof(char*)); defmodes[ndefmodes++] = XtNewString(mod->mode_name); mod = (XF86ModePtr)(mod->list.next); } break; } disp = (XF86ConfDisplayPtr)(disp->list.next); } if (ndefmodes == 0) { defmodes = (char**)XtMalloc(sizeof(char*)); defmodes[0] = XtNewString("640x480"); ndefmodes = 1; } if (listL != NULL) { XawListUnhighlight(listL); XawListUnhighlight(listR); } xf86info.cur_list = SCREEN; XtSetSensitive(back, xf86info.lists[SCREEN].cur_function > 0); XtSetSensitive(next, xf86info.lists[SCREEN].cur_function < xf86info.lists[SCREEN].num_functions - 1); (xf86info.lists[SCREEN].functions[xf86info.lists[SCREEN].cur_function]) (&xf86info); if (ConfigLoop(NULL) == True) { XF86ModePtr prev = NULL, mod; /* user may have changed the default depth, read variables again */ disp = screen->scrn_display_lst; while (disp != NULL) { if (disp->disp_depth == default_depth) break; disp = (XF86ConfDisplayPtr)(disp->list.next); } if (disp == NULL) { disp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec)); screen->scrn_display_lst = (XF86ConfDisplayPtr) xf86addListItem((GenericListPtr)(screen->scrn_display_lst), (GenericListPtr)(disp)); disp->disp_depth = default_depth; } if (strcasecmp(screen->scrn_identifier, ident_string)) xf86renameScreen(XF86Config, screen, ident_string); screen->scrn_defaultdepth = default_depth; XtSetArg(args[0], XtNlist, NULL); XtSetArg(args[1], XtNnumberStrings, 0); XtSetValues(listL, args, 2); XtSetArg(args[0], XtNlist, NULL); XtSetArg(args[1], XtNnumberStrings, 0); XtSetValues(listR, args, 2); mod = disp->disp_mode_lst; /* free all modes */ while (mod != NULL) { prev = mod; mod = (XF86ModePtr)(mod->list.next); XtFree(prev->mode_name); XtFree((XtPointer)prev); } /* readd modes */ for (i = 0; i < ndefmodes; i++) { mod = XtNew(XF86ModeRec); mod->mode_name = XtNewString(defmodes[i]); XtFree(defmodes[i]); if (i == 0) disp->disp_mode_lst = mod; else prev->list.next = mod; prev = mod; } if (i == 0) disp->disp_mode_lst = NULL; else mod->list.next = NULL; XtFree((XtPointer)defmodes); defmodes = NULL; ndefmodes = 0; for (i = 0; i < computer.num_screens; i++) if (computer.screens[i]->screen == screen) computer.screens[i]->rotate = rotate; if (oldrotate != rotate) { static char *Rotate = "Rotate"; if (screen->scrn_option_lst != NULL) xf86removeOption(&screen->scrn_option_lst, Rotate); if (rotate) screen->scrn_option_lst = xf86addNewOption(screen->scrn_option_lst, XtNewString(Rotate), XtNewString(rotate > 0 ? "CW" : "CCW")); UpdateScreenUI(); AdjustScreenUI(); } return ((XtPointer)screen); } XtSetArg(args[0], XtNlist, NULL); XtSetArg(args[1], XtNnumberStrings, 0); XtSetValues(listL, args, 2); XtSetArg(args[0], XtNlist, NULL); XtSetArg(args[1], XtNnumberStrings, 0); XtSetValues(listR, args, 2); for (i = 0; i < ndefmodes; i++) XtFree(defmodes[i]); XtFree((XtPointer)defmodes); defmodes = NULL; ndefmodes = 0; return (NULL); }