2
* Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17
* CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* Except as contained in this notice, the name of Conectiva Linux shall
23
* not be used in advertising or otherwise to promote the sale, use or other
24
* dealings in this Software without prior written authorization from
27
* Author: Paulo CĆ©sar Pereira de Andrade <pcpa@conectiva.com.br>
29
* $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/expert.c,v 1.14tsi Exp $
33
#include "xf86config.h"
37
#include "monitor-cfg.h"
38
#include <X11/Shell.h>
39
#include <X11/CompositeP.h>
40
#include <X11/Xaw/AsciiText.h>
41
#include <X11/Xaw/Box.h>
42
#include <X11/Xaw/Command.h>
43
#include <X11/Xaw/Form.h>
44
#include <X11/Xaw/Label.h>
45
#include <X11/Xaw/MenuButton.h>
46
#include <X11/Xaw/Paned.h>
47
#include <X11/Xaw/Panner.h>
48
#include <X11/Xaw/Porthole.h>
49
#include <X11/Xaw/SimpleMenu.h>
50
#include <X11/Xaw/SmeBSB.h>
51
#include <X11/Xaw/Toggle.h>
52
#include <X11/Xaw/Tree.h>
58
typedef struct _TreeNode TreeNode;
59
typedef union _TreeData TreeData;
60
typedef void (*NodeDeleteFunc)(TreeNode*);
61
typedef void (*NodeUpdateFunc)(TreeNode*);
73
XF86ConfModesPtr modes;
77
XF86ConfModeLinePtr modeline;
80
Widget text, vendor, board, busid, driver;
81
XF86ConfVideoAdaptorPtr video;
85
XF86ConfVideoPortPtr port;
88
Widget text, vendor, model, width, height, hsync, vrefresh,
89
gammaRed, gammaGreen, gammaBlue;
90
XF86ConfMonitorPtr monitor;
94
XF86ConfModesLinkPtr modeslink;
97
Widget text, vendor, board, chipset, busid, card, driver, ramdac,
98
dacSpeed, videoRam, textClockFreq, biosBase, memBase, ioBase,
99
clockChip, devClock, chipId, chipRev, irq, screen;
100
XF86ConfDevicePtr device;
103
Widget text, defaultDepth, defaultBpp, defaultFbBpp,
105
XF86ConfScreenPtr screen;
109
XF86ConfAdaptorLinkPtr adaptorlink;
112
Widget viewport, c_virtual, depth, bpp, visual, weight, black, white;
113
XF86ConfDisplayPtr display;
121
XF86ConfInputPtr input;
125
XF86ConfLayoutPtr layout;
128
Widget menu, button, scrnum, adjx, adjy;
129
XF86ConfScreenPtr screen;
130
XF86ConfAdjacencyPtr adjacency;
134
XF86ConfInputrefPtr inputref;
138
XF86ConfVendorPtr vendor;
142
XF86ConfVendSubPtr vendsub;
145
Widget name, group, mode;
149
Widget count, size, flags;
150
XF86ConfBuffersPtr buffers;
155
Widget node, toggle, treeParent;
156
TreeNode *parent, *child, *next;
158
NodeDeleteFunc destroy;
159
NodeUpdateFunc update;
165
static Bool ExpertInitialize(void);
166
static TreeNode *NewNode(TreeNode*, Widget, Widget, Widget, TreeData*);
167
static void DeleteNode(TreeNode*);
168
static void DestroyCallback(Widget, XtPointer, XtPointer);
169
static void PannerCallback(Widget, XtPointer, XtPointer);
170
static void PortholeCallback(Widget, XtPointer, XtPointer);
171
static void ToggleCallback(Widget, XtPointer, XtPointer);
172
static void ToggleNode(TreeNode*, Bool);
173
static void ToggleNodeRecursive(TreeNode*);
174
static void OptionsCallback(Widget, XtPointer, XtPointer);
175
static void RelayoutTree(void);
176
static void PopdownCallback(Widget, XtPointer, XtPointer);
177
static void UpdateConfig(TreeNode*);
178
static void DestroyTree(TreeNode*);
180
static void CreateFiles(TreeNode*);
181
static void CreateFilesField(TreeNode*, char*, char*);
182
static void UpdateFiles(TreeNode*);
184
static void CreateFontPath(TreeNode*, char*);
185
static Widget CreateFontPathField(TreeNode*, char*, Bool);
186
static void FontPathChanged(TreeNode*);
187
static void NewFontPathCallback(Widget, XtPointer, XtPointer);
188
static void FontPathCallback(Widget, XtPointer, XtPointer);
190
static void CreateModulePath(TreeNode*, char*);
191
static Widget CreateModulePathField(TreeNode*, char*, Bool);
192
static void ModulePathChanged(TreeNode*);
193
static void NewModulePathCallback(Widget, XtPointer, XtPointer);
195
static void CreateModule(TreeNode*, XF86LoadPtr);
196
static void CreateModuleField(TreeNode*, Bool);
197
static void ModuleDestroy(TreeNode*);
198
static void NewModuleCallback(Widget, XtPointer, XtPointer);
200
static void CreateModes(TreeNode*, XF86ConfModesPtr);
201
static void CreateModesField(TreeNode*, Bool);
202
static void ModesDestroy(TreeNode*);
203
static void NewModesCallback(Widget, XtPointer, XtPointer);
204
static void CreateModesModeLine(TreeNode*, XF86ConfModeLinePtr);
205
static void ModesModeLineDestroy(TreeNode*);
206
static void NewModesModeLineCallback(Widget, XtPointer, XtPointer);
208
static void CreateModeLineField(TreeNode*, Bool, Bool);
209
static XF86ConfModeLinePtr ParseModeLine(char*, char*);
211
static void CreateVideoAdaptor(TreeNode*, XF86ConfVideoAdaptorPtr);
212
static void CreateVideoAdaptorField(TreeNode*, Bool);
213
static void VideoAdaptorDestroy(TreeNode*);
214
static void NewVideoAdaptorCallback(Widget, XtPointer, XtPointer);
215
static void VideoAdaptorUpdate(TreeNode*);
216
static void CreateVideoPort(TreeNode*, XF86ConfVideoPortPtr);
217
static void CreateVideoPortField(TreeNode*, Bool);
218
static void VideoPortDestroy(TreeNode*);
219
static void NewVideoPortCallback(Widget, XtPointer, XtPointer);
221
static void CreateMonitor(TreeNode*, XF86ConfMonitorPtr);
222
static void CreateMonitorField(TreeNode*, Bool);
223
static void MonitorDestroy(TreeNode*);
224
static void NewMonitorCallback(Widget, XtPointer, XtPointer);
225
static void MonitorUpdate(TreeNode*);
226
static void CreateMonitorModeLine(TreeNode*, XF86ConfModeLinePtr);
227
static void MonitorModeLineDestroy(TreeNode*);
228
static void NewMonitorModeLineCallback(Widget, XtPointer, XtPointer);
229
static void CreateMonitorModes(TreeNode*, XF86ConfModesLinkPtr);
230
static void CreateMonitorModesField(TreeNode*, Bool);
231
static void MonitorModesLinkDestroy(TreeNode*);
232
static void NewMonitorModesCallback(Widget, XtPointer, XtPointer);
234
static void CreateDevice(TreeNode*, XF86ConfDevicePtr);
235
static void CreateDeviceField(TreeNode*, Bool);
236
static void NewDeviceCallback(Widget, XtPointer, XtPointer);
237
static void DeviceDestroy(TreeNode*);
238
static void DeviceUpdate(TreeNode*);
240
static void CreateScreen(TreeNode*, XF86ConfScreenPtr);
241
static void CreateScreenField(TreeNode*, Bool);
242
static void NewScreenCallback(Widget, XtPointer, XtPointer);
243
static void ScreenDestroy(TreeNode*);
244
static void ScreenUpdate(TreeNode*);
245
static void CreateScreenAdaptor(TreeNode*, XF86ConfAdaptorLinkPtr);
246
static void CreateScreenAdaptorField(TreeNode*, Bool);
247
static void NewScreenAdaptorCallback(Widget, XtPointer, XtPointer);
248
static void ScreenAdaptorDestroy(TreeNode*);
249
static void CreateScreenDisplay(TreeNode*, XF86ConfDisplayPtr);
250
static void CreateScreenDisplayField(TreeNode*, Bool);
251
static void NewScreenDisplayCallback(Widget, XtPointer, XtPointer);
252
static void ScreenDisplayDestroy(TreeNode*);
253
static void ScreenDisplayUpdate(TreeNode*);
254
static void CreateDisplayMode(TreeNode*, XF86ModePtr);
255
static void CreateDisplayModeField(TreeNode*, Bool);
256
static void NewDisplayModeCallback(Widget, XtPointer, XtPointer);
257
static void DisplayModeDestroy(TreeNode*);
259
static void CreateInput(TreeNode*, XF86ConfInputPtr);
260
static void CreateInputField(TreeNode*, Bool);
261
static void InputDestroy(TreeNode*);
262
static void NewInputCallback(Widget, XtPointer, XtPointer);
263
static void InputUpdate(TreeNode*);
265
static void CreateLayout(TreeNode*, XF86ConfLayoutPtr);
266
static void CreateLayoutField(TreeNode*, Bool);
267
static void LayoutDestroy(TreeNode*);
268
static void NewLayoutCallback(Widget, XtPointer, XtPointer);
269
static void CreateAdjacency(TreeNode*, XF86ConfAdjacencyPtr);
270
static void CreateAdjacencyField(TreeNode*, Bool);
271
static void AdjacencyDestroy(TreeNode*);
272
static void NewAdjacencyCallback(Widget, XtPointer, XtPointer);
273
static void AdjacencyMenuCallback(Widget, XtPointer, XtPointer);
274
static void AdjacencyToggleCallback(Widget, XtPointer, XtPointer);
275
static void CreateInputref(TreeNode*, XF86ConfInputrefPtr);
276
static void CreateInputrefField(TreeNode*, Bool);
277
static void InputrefDestroy(TreeNode*);
278
static void NewInputrefCallback(Widget, XtPointer, XtPointer);
280
static void CreateVendor(TreeNode*, XF86ConfVendorPtr);
281
static void CreateVendorField(TreeNode*, Bool);
282
static void VendorDestroy(TreeNode*);
283
static void NewVendorCallback(Widget, XtPointer, XtPointer);
284
static void CreateVendorSub(TreeNode*, XF86ConfVendSubPtr);
285
static void CreateVendorSubField(TreeNode*, Bool);
286
static void NewVendorSubCallback(Widget, XtPointer, XtPointer);
287
static void VendorSubDestroy(TreeNode*);
288
static void VendorSubUpdate(TreeNode*);
290
static void CreateDRI(TreeNode*, XF86ConfDRIPtr);
291
static void CreateDRIField(TreeNode*);
292
static void DRIUpdate(TreeNode*);
294
static void CreateBuffers(TreeNode*, XF86ConfBuffersPtr);
295
static void CreateBuffersField(TreeNode*, Bool);
296
static void BuffersDestroy(TreeNode*);
297
static void NewBuffersCallback(Widget, XtPointer, XtPointer);
298
static void BuffersUpdate(TreeNode*);
300
extern void RemoveDeviceCallback(Widget, XtPointer, XtPointer);
303
extern void InitializeDevices(void);
304
extern void SelectLayoutCallback(Widget, XtPointer, XtPointer);
305
extern void UpdateMenuDeviceList(int);
306
extern void SetConfigModeCallback(Widget, XtPointer, XtPointer);
307
extern void DefaultLayoutCallback(Widget, XtPointer, XtPointer);
308
extern void RemoveLayoutCallback(Widget, XtPointer, XtPointer);
313
static Widget shell, expert, tree, panner;
314
extern Widget work, optionsShell, config, layoutp, topMenu;
315
extern xf86cfgDevice cpu_device;
316
static TreeNode *mainNode, *monitorTree, *screenTree, *layoutTree;
322
ExpertConfigureStart(void)
326
XtPopup(shell, XtGrabExclusive);
327
if (optionsShell == NULL)
328
CreateOptionsShell();
329
XtVaSetValues(optionsShell, XtNtransientFor, shell, NULL);
333
ExpertConfigureEnd(void)
335
int i, save_config_mode = config_mode;
336
Widget sme, layopt, layoutsme = NULL;
337
XF86ConfLayoutPtr lay;
339
XtVaSetValues(optionsShell, XtNtransientFor, toplevel, NULL);
342
/* Need to do this to avoid all code elsewhere needing to update the
343
* "expert" widget tree
345
UpdateConfig(mainNode);
346
DestroyTree(mainNode);
347
XtDestroyWidget(shell);
350
if (save_config_mode != CONFIG_LAYOUT)
351
SetConfigModeCallback(topMenu, (XtPointer)CONFIG_LAYOUT, NULL);
353
/* Reset everything as the "expert" interface can do almost anything
354
* to the configuration.
356
for (i = 0; i < computer.num_screens; i++) {
357
XtDestroyWidget(computer.screens[i]->widget);
358
XtFree((XtPointer)computer.screens[i]);
360
XtFree((XtPointer)computer.screens);
361
computer.screens = NULL;
362
computer.num_screens = 0;
364
for (i = 0; i < computer.num_devices; i++) {
365
XtDestroyWidget(computer.devices[i]->widget);
366
XtFree((XtPointer)computer.devices[i]);
368
XtFree((XtPointer)computer.devices);
369
computer.devices = NULL;
370
computer.num_devices = 0;
372
for (i = 0; i < computer.num_layouts; i++) {
373
XtFree((XtPointer)computer.layouts[i]->position);
374
XtFree((XtPointer)computer.layouts[i]);
376
XtFree((XtPointer)computer.layouts);
377
computer.layouts = NULL;
378
computer.num_layouts = 0;
380
for (i = 0; i < computer.num_vidmodes; i++)
381
XtFree((XtPointer)computer.vidmodes[i]);
382
XtFree((XtPointer)computer.vidmodes);
383
computer.vidmodes = NULL;
384
computer.num_vidmodes = 0;
386
/* Reinitialize devices/screens */
388
UpdateMenuDeviceList(MOUSE);
389
UpdateMenuDeviceList(KEYBOARD);
390
UpdateMenuDeviceList(CARD);
391
UpdateMenuDeviceList(MONITOR);
393
/* Update layout menu */
394
/* first entry is "New server layout" */
395
for (i = 1; i < ((CompositeWidget)layoutp)->composite.num_children; i++)
396
XtDestroyWidget(((CompositeWidget)layoutp)->composite.children[i]);
397
for (i = 0; i < layoutp->core.num_popups; i++)
398
XtDestroyWidget(layoutp->core.popup_list[i]);
399
lay = XF86Config->conf_layout_lst;
400
while (lay != NULL) {
401
sme = XtVaCreateManagedWidget("sme", smeBSBObjectClass,
403
XtNlabel, lay->lay_identifier,
404
XtNmenuName, lay->lay_identifier,
405
XtNleftBitmap, menuPixmap,
407
XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay);
408
if (layoutsme == NULL)
410
layopt = XtCreatePopupShell(lay->lay_identifier, simpleMenuWidgetClass,
412
sme = XtCreateManagedWidget("default", smeBSBObjectClass,
414
XtAddCallback(sme, XtNcallback, DefaultLayoutCallback, NULL);
415
sme = XtCreateManagedWidget("remove", smeBSBObjectClass,
417
XtAddCallback(sme, XtNcallback, RemoveLayoutCallback, NULL);
418
XtRealizeWidget(layopt);
420
lay = (XF86ConfLayoutPtr)(lay->list.next);
422
computer.layout = NULL;
423
SelectLayoutCallback(layoutsme,
424
XF86Config->conf_layout_lst, NULL);
427
if (XF86Config->conf_flags && XF86Config->conf_flags->flg_option_lst)
429
for (i = 0; i < computer.num_devices; i++)
430
SetTip(computer.devices[i]);
432
/* Reinitialize vidmodes */
433
InitializeVidmodes();
435
if (save_config_mode != CONFIG_LAYOUT)
436
SetConfigModeCallback(topMenu, (XtPointer)(long)save_config_mode, NULL);
441
ExpertCloseAction(Widget w, XEvent *event, String *params, Cardinal *num_params)
443
ExpertConfigureEnd();
448
ExpertCallback(Widget w, XtPointer user_data, XtPointer call_data)
450
ExpertConfigureStart();
455
PopdownCallback(Widget w, XtPointer user_data, XtPointer call_data)
457
ExpertConfigureEnd();
462
CreateFiles(TreeNode *files)
464
XF86ConfFilesPtr file = XF86Config->conf_files;
465
TreeNode *node, *fontpath, *modulepath;
469
value = file->file_logfile ? file->file_logfile : "";
470
node = NewNode(files, NULL, NULL, files->node,
471
(TreeData*)XtCalloc(1, sizeof(TreeData)));
472
CreateFilesField(node, "LogFile", value);
474
files->update = UpdateFiles;
477
value = XF86RGB_path;
479
value = file->file_rgbpath ? file->file_rgbpath : "";
480
node->next = NewNode(files, NULL, NULL, files->node,
481
(TreeData*)XtCalloc(1, sizeof(TreeData)));
483
CreateFilesField(node, "RgbPath", value);
485
w = XtVaCreateManagedWidget("ModulePath", toggleWidgetClass, tree,
486
XtNtreeParent, files->node, NULL);
487
node->next = modulepath = NewNode(files, w, w, files->node, NULL);
489
CreateModulePath(modulepath, NULL);
491
w = XtVaCreateManagedWidget("FontPath", toggleWidgetClass, tree,
492
XtNtreeParent, files->node, NULL);
493
node->next = fontpath = NewNode(files, w, w, files->node, NULL);
495
CreateFontPath(fontpath, NULL);
499
CreateFilesField(TreeNode *node, char *name, char *value)
503
box = XtVaCreateManagedWidget(name, boxWidgetClass, tree,
504
XtNtreeParent, node->node, NULL);
506
(void) XtVaCreateManagedWidget("label", labelWidgetClass, box,
507
XtNlabel, name, NULL);
508
text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
509
XtNeditType, XawtextEdit, XtNstring, value,
511
node->data->files.text = text;
515
UpdateFiles(TreeNode *files)
520
files = files->child;
521
XtVaGetValues(files->data->files.text, XtNstring, &str, NULL);
522
XtFree(XF86Config->conf_files->file_logfile);
524
XF86Config->conf_files->file_logfile = XtNewString(str);
526
XF86Config->conf_files->file_logfile = NULL;
530
XtVaGetValues(files->data->files.text, XtNstring, &str, NULL);
531
XtFree(XF86Config->conf_files->file_rgbpath);
533
XF86Config->conf_files->file_rgbpath = XtNewString(str);
535
XF86Config->conf_files->file_rgbpath = NULL;
539
/* Don't need to set the update tree field, as it is already set
540
* as the destroy field */
542
CreateFontPath(TreeNode *fontpath, char *path)
544
TreeNode *prev = NULL, *node;
548
path = XtNewString(XF86Font_path);
549
if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath) {
550
XtFree(XF86Config->conf_files->file_fontpath);
551
XF86Config->conf_files->file_fontpath = XtNewString(path);
554
else if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath)
555
path = XtNewString(XF86Config->conf_files->file_fontpath);
558
path = XtNewString(path);
559
if ((prev = fontpath->child) != NULL)
567
for (s = strtok(path, ","); s != NULL; s = strtok(NULL, ",")) {
568
node = NewNode(fontpath, NULL, NULL, fontpath->node, NULL);
569
node->destroy = FontPathChanged;
570
(void) CreateFontPathField(node, s, False);
571
if (fontpath->child == NULL)
572
fontpath->child = node;
580
node = NewNode(fontpath, NULL, NULL, fontpath->node, NULL);
581
(void) CreateFontPathField(node, "", True);
582
if (fontpath->child == NULL)
583
fontpath->child = node;
589
CreateFontPathField(TreeNode *fontpath, char *value, Bool addnew)
591
Widget box, command, text;
594
box = XtVaCreateWidget("fontpath", formWidgetClass, tree,
595
XtNtreeParent, fontpath->treeParent, NULL);
596
fontpath->node = box;
598
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
600
XtAddCallback(command, XtNcallback, DestroyCallback,
601
(XtPointer)fontpath);
602
command = XtCreateManagedWidget("up", commandWidgetClass, box, NULL, 0);
603
XtAddCallback(command, XtNcallback, FontPathCallback,
604
(XtPointer)fontpath);
605
command = XtCreateManagedWidget("down", commandWidgetClass, box, NULL, 0);
606
XtAddCallback(command, XtNcallback, FontPathCallback,
607
(XtPointer)fontpath);
608
text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
609
XtNeditType, XawtextEdit,
610
XtNstring, value, NULL);
613
command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0);
614
XtAddCallback(command, XtNcallback, NewFontPathCallback,
615
(XtPointer)fontpath);
616
text = XtVaCreateManagedWidget("valueNew", asciiTextWidgetClass, box,
617
XtNeditType, XawtextEdit,
618
XtNstring, value, NULL);
620
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
621
data->files.text = text;
622
fontpath->data = data;
624
if (fontpath->treeParent && XtIsRealized(fontpath->treeParent))
625
XtRealizeWidget(box);
632
FontPathChanged(TreeNode *node)
634
TreeNode *parent = node->parent;
635
char *fontpath = NULL, *str;
639
/* last node is the "new" */
640
for (node = parent->child; node->next != NULL; node = node->next) {
642
fontpath[pos++] = ',';
643
XtSetArg(args[0], XtNstring, &str);
644
XtGetValues(node->data->files.text, args, 1);
645
len = strlen(str) + 2;
646
fontpath = XtRealloc(fontpath, pos + len);
647
strcpy(fontpath + pos, str);
651
if (XF86Config->conf_files->file_fontpath)
652
XtFree(XF86Config->conf_files->file_fontpath);
653
XF86Config->conf_files->file_fontpath = fontpath;
657
NewFontPathCallback(Widget unused, XtPointer user_data, XtPointer call_data)
659
TreeNode *fontpath, *node = (TreeNode*)user_data;
663
XtSetArg(args[0], XtNstring, &str);
664
XtGetValues(node->data->files.text, args, 1);
668
fontpath = node->parent;
670
CreateFontPath(fontpath, str);
672
FontPathChanged(fontpath->child);
678
FontPathCallback(Widget w, XtPointer user_data, XtPointer call_data)
680
TreeNode *parent, *node, *fontpath = (TreeNode*)user_data;
684
parent = fontpath->parent;
685
node = parent->child;
686
if (!node->next->next)
688
if (strcmp(XtName(w), "up") == 0) {
689
if (node == fontpath)
690
while (node->next->next)
693
while (node && node->next != fontpath)
697
if (fontpath->next->next)
698
node = fontpath->next;
699
/* else is already correct */
702
w1 = node->data->files.text;
703
w2 = fontpath->data->files.text;
705
XtVaGetValues(w1, XtNstring, &t1, NULL);
706
XtVaGetValues(w2, XtNstring, &t2, NULL);
707
t1 = XtNewString(t1);
708
XtVaSetValues(w1, XtNstring, t2, NULL);
709
XtVaSetValues(w2, XtNstring, t1, NULL);
715
/* Don't need to set the update tree field, as it is already set
716
* as the destroy field */
718
CreateModulePath(TreeNode *modulepath, char *path)
720
TreeNode *prev = NULL, *node;
723
if (XF86Module_path) {
724
path = XtNewString(XF86Module_path);
725
if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath) {
726
XtFree(XF86Config->conf_files->file_modulepath);
727
XF86Config->conf_files->file_modulepath = XtNewString(path);
730
else if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath)
731
path = XtNewString(XF86Config->conf_files->file_modulepath);
734
path = XtNewString(path);
735
if ((prev = modulepath->child) != NULL)
743
for (s = strtok(path, ","); s != NULL; s = strtok(NULL, ",")) {
744
node = NewNode(modulepath, NULL, NULL, modulepath->node, NULL);
745
node->destroy = ModulePathChanged;
746
(void) CreateModulePathField(node, s, False);
747
if (modulepath->child == NULL)
748
modulepath->child = node;
756
node = NewNode(modulepath, NULL, NULL, modulepath->node, NULL);
757
(void) CreateModulePathField(node, "", True);
758
if (modulepath->child == NULL)
759
modulepath->child = node;
765
CreateModulePathField(TreeNode *modulepath, char *value, Bool addnew)
767
Widget box, command, text;
770
box = XtVaCreateWidget("modulepath", formWidgetClass, tree,
771
XtNtreeParent, modulepath->treeParent, NULL);
772
modulepath->node = box;
774
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
776
XtAddCallback(command, XtNcallback, DestroyCallback,
777
(XtPointer)modulepath);
778
text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
779
XtNeditType, XawtextEdit,
780
XtNstring, value, NULL);
783
command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0);
784
XtAddCallback(command, XtNcallback, NewModulePathCallback,
785
(XtPointer)modulepath);
786
text = XtVaCreateManagedWidget("valueNew", asciiTextWidgetClass, box,
787
XtNeditType, XawtextEdit,
788
XtNstring, value, NULL);
790
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
791
data->files.text = text;
792
modulepath->data = data;
794
if (modulepath->treeParent && XtIsRealized(modulepath->treeParent))
795
XtRealizeWidget(box);
802
ModulePathChanged(TreeNode *node)
804
TreeNode *parent = node->parent;
805
char *modulepath = NULL, *str;
809
/* last node is the "new" */
810
for (node = parent->child; node->next != NULL; node = node->next) {
812
modulepath[pos++] = ',';
813
XtSetArg(args[0], XtNstring, &str);
814
XtGetValues(node->data->files.text, args, 1);
815
len = strlen(str) + 2;
816
modulepath = XtRealloc(modulepath, pos + len);
817
strcpy(modulepath + pos, str);
821
if (XF86Config->conf_files->file_modulepath)
822
XtFree(XF86Config->conf_files->file_modulepath);
823
XF86Config->conf_files->file_modulepath = modulepath;
827
NewModulePathCallback(Widget unused, XtPointer user_data, XtPointer call_data)
829
TreeNode *modulepath, *node = (TreeNode*)user_data;
833
XtSetArg(args[0], XtNstring, &str);
834
XtGetValues(node->data->files.text, args, 1);
838
modulepath = node->parent;
840
CreateModulePath(modulepath, str);
842
ModulePathChanged(modulepath->child);
848
CreateModule(TreeNode *module, XF86LoadPtr load)
850
TreeNode *prev, *node;
853
if ((prev = module->child) != NULL)
858
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
859
data->module.load = load;
860
node = NewNode(module, NULL, NULL, module->node, data);
861
node->destroy = ModuleDestroy;
862
CreateModuleField(node, False);
863
if (module->child == NULL)
864
module->child = node;
868
load = (XF86LoadPtr)(load->list.next);
871
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
872
node = NewNode(module, NULL, NULL, module->node, data);
873
CreateModuleField(node, True);
874
if (module->child == NULL)
875
module->child = node;
881
CreateModuleField(TreeNode *node, Bool addnew)
883
Widget box, command, label;
885
box = XtVaCreateWidget("module", formWidgetClass, tree,
886
XtNtreeParent, node->treeParent, NULL);
890
XF86OptionPtr *options;
891
XF86LoadPtr load = node->data->module.load;
893
options = &(load->load_opt);
894
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
896
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
897
command = XtCreateManagedWidget("options", commandWidgetClass, box,
899
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
900
label = XtVaCreateManagedWidget("label", labelWidgetClass, box,
901
XtNlabel, load->load_name, NULL);
904
command = XtCreateManagedWidget("new", commandWidgetClass, box,
906
XtAddCallback(command, XtNcallback, NewModuleCallback, (XtPointer)node);
907
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
908
XtNeditType, XawtextEdit,
910
node->data->module.text = label;
912
if (XtIsRealized(node->treeParent))
913
XtRealizeWidget(box);
919
ModuleDestroy(TreeNode *node)
921
if (node->data->module.load)
922
xf86removeModule(XF86Config, node->data->module.load);
927
NewModuleCallback(Widget unused, XtPointer user_data, XtPointer call_data)
929
TreeNode *module, *node = (TreeNode*)user_data;
934
XtSetArg(args[0], XtNstring, &label);
935
XtGetValues(node->data->module.text, args, 1);
939
module = node->parent;
941
load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec));
942
load->load_name = XtNewString(label);
943
XF86Config->conf_modules->mod_load_lst =
944
xf86addModule(XF86Config->conf_modules->mod_load_lst, load);
946
CreateModule(module, load);
952
CreateModes(TreeNode *parent, XF86ConfModesPtr modes)
954
TreeNode *node, *prev;
957
if ((prev = parent->child) != NULL)
962
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
963
data->modes.modes = modes;
964
node = NewNode(parent, NULL, NULL, parent->node, data);
965
node->destroy = ModesDestroy;
966
CreateModesField(node, False);
967
if (parent->child == NULL)
968
parent->child = node;
973
modes = (XF86ConfModesPtr)(modes->list.next);
976
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
977
node = NewNode(parent, NULL, NULL, parent->node, data);
978
CreateModesField(node, True);
979
if (parent->child == NULL)
980
parent->child = node;
986
CreateModesField(TreeNode *node, Bool addnew)
988
Widget box, command, label;
990
box = XtVaCreateWidget("modes", formWidgetClass, tree,
991
XtNtreeParent, node->treeParent, NULL);
995
XF86ConfModesPtr modes = node->data->modes.modes;
997
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
999
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
1000
label = XtVaCreateManagedWidget("mode", toggleWidgetClass, box,
1001
XtNlabel, modes->modes_identifier,
1004
node->toggle = label;
1005
XtAddCallback(label, XtNcallback, ToggleCallback, (XtPointer)node);
1006
CreateModesModeLine(node, node->data->modes.modes->mon_modeline_lst);
1009
command = XtCreateManagedWidget("new", commandWidgetClass, box,
1011
XtAddCallback(command, XtNcallback, NewModesCallback, (XtPointer)node);
1012
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
1013
XtNeditType, XawtextEdit,
1015
node->data->modes.text = label;
1017
if (XtIsRealized(node->treeParent))
1018
XtRealizeWidget(box);
1024
ModesDestroy(TreeNode *node)
1026
if (node->data->modes.modes) {
1028
TreeNode *mon = monitorTree->child;
1030
/* last one is the "new" entry */
1031
while (mon && mon->next) {
1032
/* UseModes is the second entry */
1033
TreeNode *mod = mon->child->next->child;
1034
CompositeWidget composite;
1036
while (mod && mod->next) {
1037
TreeNode *next = mod->next;
1039
if (mod && strcmp(mod->data->modeslink.modeslink->ml_modes_str,
1040
node->data->modes.modes->modes_identifier) == 0)
1041
/* Needs to do string comparison because may be deleting
1042
* a "test" Modes section, with no Modelines.
1047
composite = (CompositeWidget)mod->data->modeslink.menu;
1049
for (i = 0; i < composite->composite.num_children; ++i)
1050
if (strcmp(XtName(composite->composite.children[i]),
1051
node->data->modes.modes->modes_identifier) == 0)
1052
XtDestroyWidget(composite->composite.children[i]);
1057
xf86removeModes(XF86Config, node->data->modes.modes);
1063
NewModesCallback(Widget unused, XtPointer user_data, XtPointer call_data)
1065
TreeNode *parent, *node = (TreeNode*)user_data;
1066
XF86ConfModesPtr modes;
1070
XtSetArg(args[0], XtNstring, &label);
1071
XtGetValues(node->data->modes.text, args, 1);
1075
parent = node->parent;
1077
modes = (XF86ConfModesPtr)XtCalloc(1, sizeof(XF86ConfModesRec));
1078
modes->modes_identifier = XtNewString(label);
1079
XF86Config->conf_modes_lst =
1080
xf86addModes(XF86Config->conf_modes_lst, modes);
1083
TreeNode *mon = monitorTree->child;
1086
/* last one is the "new" entry */
1087
while (mon && mon->next) {
1088
/* UseModes is the second entry */
1089
TreeNode *mod = mon->child->next->child;
1091
while (mod && mod->next)
1094
sme = XtCreateManagedWidget(modes->modes_identifier,
1096
mod->data->modeslink.menu, NULL, 0);
1097
XtAddCallback(sme, XtNcallback, NewMonitorModesCallback,
1104
CreateModes(parent, modes);
1109
CreateModesModeLine(TreeNode *parent, XF86ConfModeLinePtr modeline)
1111
TreeNode *node, *prev;
1114
if ((prev = parent->child) != NULL)
1119
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1120
data->modeline.modeline = modeline;
1121
node = NewNode(parent, NULL, NULL, parent->node, data);
1122
node->destroy = ModesModeLineDestroy;
1123
CreateModeLineField(node, False, False);
1124
if (parent->child == NULL)
1125
parent->child = node;
1129
modeline = (XF86ConfModeLinePtr)(modeline->list.next);
1131
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1132
node = NewNode(parent, NULL, NULL, parent->node, data);
1133
if (parent->child == NULL)
1134
parent->child = node;
1138
CreateModeLineField(node, True, False);
1141
/* This function should allow creating modelines for the
1142
Mode and Monitor section */
1144
CreateModeLineField(TreeNode *node, Bool addnew, Bool monitor)
1146
Widget box, command;
1147
char buf[512], tmp[32];
1149
box = XtVaCreateWidget("modeline", formWidgetClass, tree,
1150
XtNtreeParent, node->treeParent, NULL);
1154
XF86ConfModeLinePtr mod = node->data->modeline.modeline;
1156
command = XtCreateManagedWidget("remove", commandWidgetClass,
1158
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
1159
XtVaCreateManagedWidget("label", labelWidgetClass, box,
1160
XtNlabel, mod->ml_identifier, NULL);
1162
XmuSnprintf(buf, sizeof(buf), "%g %d %d %d %d %d %d %d %d",
1163
mod->ml_clock / 1000., mod->ml_hdisplay, mod->ml_hsyncstart,
1164
mod->ml_hsyncend, mod->ml_htotal, mod->ml_vdisplay,
1165
mod->ml_vsyncstart, mod->ml_vsyncend, mod->ml_vtotal);
1166
if (mod->ml_flags & XF86CONF_INTERLACE)
1167
strcat(buf, " interlace");
1168
if (mod->ml_flags & XF86CONF_PHSYNC)
1169
strcat(buf, " +hsync");
1170
if (mod->ml_flags & XF86CONF_NHSYNC)
1171
strcat(buf, " -hsync");
1172
if (mod->ml_flags & XF86CONF_PVSYNC)
1173
strcat(buf, " +vsync");
1174
if (mod->ml_flags & XF86CONF_NVSYNC)
1175
strcat(buf, " -vsync");
1176
if (mod->ml_flags & XF86CONF_CSYNC)
1177
strcat(buf, " composite");
1178
if (mod->ml_flags & XF86CONF_PCSYNC)
1179
strcat(buf, " +csync");
1180
if (mod->ml_flags & XF86CONF_NCSYNC)
1181
strcat(buf, " -csync");
1182
if (mod->ml_flags & XF86CONF_DBLSCAN)
1183
strcat(buf, " doublescan");
1184
if (mod->ml_flags & XF86CONF_BCAST)
1185
strcat(buf, " bcast");
1186
if (mod->ml_flags & XF86CONF_HSKEW) {
1187
XmuSnprintf(tmp, sizeof(tmp), " hskew %d", mod->ml_hskew);
1190
if (mod->ml_flags & XF86CONF_VSCAN) {
1191
XmuSnprintf(tmp, sizeof(tmp), " vscan %d", mod->ml_vscan);
1194
if (mod->ml_flags & XF86CONF_CUSTOM)
1195
strcat(buf, " custom");
1196
node->data->modeline.value =
1197
XtVaCreateManagedWidget("modeline", asciiTextWidgetClass, box,
1198
XtNeditType, XawtextEdit,
1199
XtNstring, buf, NULL);
1203
command = XtCreateManagedWidget("new", commandWidgetClass,
1205
XtAddCallback(command, XtNcallback, monitor ?
1206
NewMonitorModeLineCallback : NewModesModeLineCallback,
1208
node->data->modeline.text =
1209
XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
1210
XtNeditType, XawtextEdit, NULL);
1211
node->data->modeline.value =
1212
XtVaCreateManagedWidget("modelineNew", asciiTextWidgetClass, box,
1213
XtNeditType, XawtextEdit, NULL);
1215
if (XtIsRealized(node->treeParent))
1216
XtRealizeWidget(box);
1222
ModesModeLineDestroy(TreeNode *node)
1224
if (node->data->modeline.modeline)
1225
xf86removeModesModeLine(node->parent->data->modes.modes,
1226
node->data->modeline.modeline);
1231
NewModesModeLineCallback(Widget unused, XtPointer user_data, XtPointer call_data)
1233
TreeNode *parent, *node = (TreeNode*)user_data;
1234
XF86ConfModeLinePtr modeline;
1236
char *ident, *value;
1238
XtSetArg(args[0], XtNstring, &ident);
1239
XtGetValues(node->data->modeline.text, args, 1);
1240
XtSetArg(args[0], XtNstring, &value);
1241
XtGetValues(node->data->modeline.value, args, 1);
1242
if (*ident == '\0' || *value == '\0')
1245
parent = node->parent;
1247
modeline = ParseModeLine(ident, value);
1248
parent->data->modes.modes->mon_modeline_lst =
1249
xf86addModeLine(parent->data->modes.modes->mon_modeline_lst, modeline);
1251
CreateModesModeLine(parent, modeline);
1255
static XF86ConfModeLinePtr
1256
ParseModeLine(char *identifier, char *modeline)
1258
XF86ConfModeLinePtr ml = (XF86ConfModeLinePtr)
1259
XtCalloc(1, sizeof(XF86ConfModeLineRec));
1260
char *s, *ptr = modeline;
1263
ml->ml_identifier = XtNewString(identifier);
1265
ml->ml_clock = (int)(strtod(ptr, &ptr) * 1000.0 + 0.5);
1266
while (*ptr && isspace(*ptr)) ++ptr;
1268
ml->ml_hdisplay = strtol(ptr, &ptr, 10);
1269
while (*ptr && isspace(*ptr)) ++ptr;
1271
ml->ml_hsyncstart = strtol(ptr, &ptr, 10);
1272
while (*ptr && isspace(*ptr)) ++ptr;
1274
ml->ml_hsyncend = strtol(ptr, &ptr, 10);
1275
while (*ptr && isspace(*ptr)) ++ptr;
1277
ml->ml_htotal = strtol(ptr, &ptr, 10);
1278
while (*ptr && isspace(*ptr)) ++ptr;
1280
ml->ml_vdisplay = strtol(ptr, &ptr, 10);
1281
while (*ptr && isspace(*ptr)) ++ptr;
1283
ml->ml_vsyncstart = strtol(ptr, &ptr, 10);
1284
while (*ptr && isspace(*ptr)) ++ptr;
1286
ml->ml_vsyncend = strtol(ptr, &ptr, 10);
1287
while (*ptr && isspace(*ptr)) ++ptr;
1289
ml->ml_vtotal = strtol(ptr, &ptr, 10);
1290
while (*ptr && isspace(*ptr)) ++ptr;
1300
while (*s && isspace(*s))
1303
while (*s && !isspace(*s))
1307
Bool done = *s == '\0';
1310
if (strcmp(ptr, "interlace") == 0)
1311
ml->ml_flags |= XF86CONF_INTERLACE;
1312
else if (strcmp(ptr, "+hsync") == 0)
1313
ml->ml_flags |= XF86CONF_PHSYNC;
1314
else if (strcmp(ptr, "-hsync") == 0)
1315
ml->ml_flags |= XF86CONF_NHSYNC;
1316
else if (strcmp(ptr, "+vsync") == 0)
1317
ml->ml_flags |= XF86CONF_PVSYNC;
1318
else if (strcmp(ptr, "-vsync") == 0)
1319
ml->ml_flags |= XF86CONF_NVSYNC;
1320
else if (strcmp(ptr, "composite") == 0)
1321
ml->ml_flags |= XF86CONF_CSYNC;
1322
else if (strcmp(ptr, "+csync") == 0)
1323
ml->ml_flags |= XF86CONF_PCSYNC;
1324
else if (strcmp(ptr, "-csync") == 0)
1325
ml->ml_flags |= XF86CONF_NCSYNC;
1326
else if (strcmp(ptr, "doublescan") == 0)
1327
ml->ml_flags |= XF86CONF_DBLSCAN;
1328
else if (strcmp(ptr, "bcast") == 0)
1329
ml->ml_flags |= XF86CONF_BCAST;
1330
else if (strcmp(ptr, "hskew") == 0) {
1332
while (*s && isspace(*s))
1335
while (*s && !isspace(*s))
1338
ml->ml_hskew = strtol(ptr, &s, 10);
1339
ml->ml_flags |= XF86CONF_HSKEW;
1343
else if (strcmp(ptr, "vscan") == 0) {
1345
while (*s && isspace(*s))
1348
while (*s && !isspace(*s))
1351
ml->ml_vscan = strtol(ptr, &s, 10);
1352
ml->ml_flags |= XF86CONF_VSCAN;
1356
else if (strcmp(ptr, "custom") == 0)
1357
ml->ml_flags |= XF86CONF_CUSTOM;
1370
CreateVideoAdaptor(TreeNode *parent, XF86ConfVideoAdaptorPtr video)
1372
TreeNode *node, *prev;
1375
if ((prev = parent->child) != NULL)
1380
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1381
data->video.video = video;
1382
node = NewNode(parent, NULL, NULL, parent->node, data);
1383
node->destroy = VideoAdaptorDestroy;
1384
node->update = VideoAdaptorUpdate;
1385
CreateVideoAdaptorField(node, False);
1386
if (parent->child == NULL)
1387
parent->child = node;
1392
video = (XF86ConfVideoAdaptorPtr)(video->list.next);
1395
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1396
node = NewNode(parent, NULL, NULL, parent->node, data);
1397
CreateVideoAdaptorField(node, True);
1398
if (parent->child == NULL)
1399
parent->child = node;
1405
CreateVideoAdaptorField(TreeNode *node, Bool addnew)
1407
Widget box, command, label;
1409
box = XtVaCreateWidget("video", formWidgetClass, tree,
1410
XtNtreeParent, node->treeParent, NULL);
1416
XF86ConfVideoAdaptorPtr video = node->data->video.video;
1418
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
1420
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
1421
command = XtCreateManagedWidget("options", commandWidgetClass, box,
1423
XtAddCallback(command, XtNcallback, OptionsCallback,
1424
(XtPointer)&(video->va_option_lst));
1425
label = XtVaCreateManagedWidget("adaptor", labelWidgetClass, box,
1426
XtNlabel, video->va_identifier,
1429
XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0);
1430
str = video->va_vendor ? video->va_vendor : "";
1431
node->data->video.vendor =
1432
XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box,
1433
XtNeditType, XawtextEdit,
1437
XtCreateManagedWidget("boardL", labelWidgetClass, box, NULL, 0);
1438
str = video->va_board ? video->va_board : "";
1439
node->data->video.board =
1440
XtVaCreateManagedWidget("board", asciiTextWidgetClass, box,
1441
XtNeditType, XawtextEdit,
1445
XtCreateManagedWidget("busidL", labelWidgetClass, box, NULL, 0);
1446
str = video->va_busid ? video->va_busid : "";
1447
node->data->video.busid =
1448
XtVaCreateManagedWidget("busid", asciiTextWidgetClass, box,
1449
XtNeditType, XawtextEdit,
1453
XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0);
1454
str = video->va_driver ? video->va_driver : "";
1455
node->data->video.driver =
1456
XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box,
1457
XtNeditType, XawtextEdit,
1461
label = XtVaCreateManagedWidget("VideoPort", toggleWidgetClass, tree,
1465
port = NewNode(node, label, label, node->node, NULL);
1467
CreateVideoPort(port, video->va_port_lst);
1470
command = XtCreateManagedWidget("new", commandWidgetClass, box,
1472
XtAddCallback(command, XtNcallback, NewVideoAdaptorCallback,
1474
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
1475
XtNeditType, XawtextEdit,
1477
node->data->video.text = label;
1479
if (XtIsRealized(node->treeParent))
1480
XtRealizeWidget(box);
1486
VideoAdaptorDestroy(TreeNode *node)
1488
if (node->data->video.video) {
1490
TreeNode *scrn = screenTree->child;
1492
/* last one is the "new" entry */
1493
while (scrn && scrn->next) {
1494
/* VideoAdator is the first entry */
1495
TreeNode *ad = scrn->child->child;
1496
CompositeWidget composite;
1498
while (ad && ad->next) {
1499
TreeNode *next = ad->next;
1501
if (ad && strcmp(ad->data->adaptorlink.adaptorlink->al_adaptor_str,
1502
node->data->video.video->va_identifier) == 0)
1506
composite = (CompositeWidget)ad->data->adaptorlink.menu;
1508
for (i = 0; i < composite->composite.num_children; ++i)
1509
if (strcmp(XtName(composite->composite.children[i]),
1510
node->data->video.video->va_identifier) == 0)
1511
XtDestroyWidget(composite->composite.children[i]);
1516
xf86removeVideoAdaptor(XF86Config, node->data->video.video);
1522
NewVideoAdaptorCallback(Widget unused, XtPointer user_data, XtPointer call_data)
1524
TreeNode *parent, *node = (TreeNode*)user_data;
1525
XF86ConfVideoAdaptorPtr video;
1529
XtSetArg(args[0], XtNstring, &label);
1530
XtGetValues(node->data->video.text, args, 1);
1534
parent = node->parent;
1536
video = (XF86ConfVideoAdaptorPtr)
1537
XtCalloc(1, sizeof(XF86ConfVideoAdaptorRec));
1538
video->va_identifier = XtNewString(label);
1539
XF86Config->conf_videoadaptor_lst =
1540
xf86addVideoAdaptor(XF86Config->conf_videoadaptor_lst, video);
1543
TreeNode *scrn = screenTree->child;
1546
/* last one is the "new" entry */
1547
while (scrn && scrn->next) {
1548
/* VideoAdaptor is the first entry */
1549
TreeNode *ad = scrn->child->child;
1551
while (ad && ad->next)
1554
sme = XtCreateManagedWidget(video->va_identifier,
1556
ad->data->adaptorlink.menu, NULL, 0);
1557
XtAddCallback(sme, XtNcallback, NewScreenAdaptorCallback,
1564
CreateVideoAdaptor(parent, video);
1569
VideoAdaptorUpdate(TreeNode *node)
1574
XtVaGetValues(node->data->video.vendor, XtNstring, &str, NULL);
1575
XtFree(node->data->video.video->va_vendor);
1577
node->data->video.video->va_vendor = XtNewString(str);
1579
node->data->video.video->va_vendor = NULL;
1582
XtVaGetValues(node->data->video.board, XtNstring, &str, NULL);
1583
XtFree(node->data->video.video->va_board);
1585
node->data->video.video->va_board = XtNewString(str);
1587
node->data->video.video->va_board = NULL;
1590
XtVaGetValues(node->data->video.busid, XtNstring, &str, NULL);
1591
XtFree(node->data->video.video->va_busid);
1593
node->data->video.video->va_busid = XtNewString(str);
1595
node->data->video.video->va_busid = NULL;
1598
XtVaGetValues(node->data->video.driver, XtNstring, &str, NULL);
1599
XtFree(node->data->video.video->va_driver);
1601
node->data->video.video->va_driver = XtNewString(str);
1603
node->data->video.video->va_driver = NULL;
1607
CreateVideoPort(TreeNode *parent, XF86ConfVideoPortPtr port)
1609
TreeNode *prev, *node;
1612
if ((prev = parent->child) != NULL)
1617
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1618
data->port.port = port;
1619
node = NewNode(parent, NULL, NULL, parent->node, data);
1620
node->destroy = VideoPortDestroy;
1621
CreateVideoPortField(node, False);
1622
if (parent->child == NULL)
1623
parent->child = node;
1627
port = (XF86ConfVideoPortPtr)(port->list.next);
1630
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1631
node = NewNode(parent, NULL, NULL, parent->node, data);
1632
CreateVideoPortField(node, True);
1633
if (parent->child == NULL)
1634
parent->child = node;
1640
CreateVideoPortField(TreeNode *node, Bool addnew)
1642
Widget box, command, label;
1644
box = XtVaCreateWidget("port", formWidgetClass, tree,
1645
XtNtreeParent, node->treeParent, NULL);
1649
XF86OptionPtr *options;
1650
XF86ConfVideoPortPtr port = node->data->port.port;
1652
options = &(port->vp_option_lst);
1653
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
1655
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
1656
command = XtCreateManagedWidget("options", commandWidgetClass, box,
1658
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
1659
label = XtVaCreateManagedWidget("label", labelWidgetClass, box,
1660
XtNlabel, port->vp_identifier, NULL);
1663
command = XtCreateManagedWidget("new", commandWidgetClass, box,
1665
XtAddCallback(command, XtNcallback, NewVideoPortCallback, (XtPointer)node);
1666
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
1667
XtNeditType, XawtextEdit,
1669
node->data->port.text = label;
1671
if (XtIsRealized(node->treeParent))
1672
XtRealizeWidget(box);
1678
VideoPortDestroy(TreeNode *node)
1680
if (node->data->port.port)
1681
xf86removeVideoPort(node->parent->parent->data->video.video,
1682
node->data->port.port);
1687
NewVideoPortCallback(Widget unused, XtPointer user_data, XtPointer call_data)
1689
TreeNode *video, *node = (TreeNode*)user_data;
1690
XF86ConfVideoPortPtr port;
1694
XtSetArg(args[0], XtNstring, &label);
1695
XtGetValues(node->data->port.text, args, 1);
1699
video = node->parent->parent;
1701
port = (XF86ConfVideoPortPtr)XtCalloc(1, sizeof(XF86ConfVideoPortRec));
1702
port->vp_identifier = XtNewString(label);
1703
video->data->video.video->va_port_lst =
1704
xf86addVideoPort(video->data->video.video->va_port_lst, port);
1706
CreateVideoPort(video, port);
1712
CreateMonitor(TreeNode *parent, XF86ConfMonitorPtr mon)
1714
TreeNode *prev, *node;
1717
if ((prev = parent->child) != NULL)
1722
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1723
data->monitor.monitor = mon;
1724
node = NewNode(parent, NULL, NULL, parent->node, data);
1725
node->destroy = MonitorDestroy;
1726
node->update = MonitorUpdate;
1727
CreateMonitorField(node, False);
1728
if (parent->child == NULL)
1729
parent->child = node;
1733
mon = (XF86ConfMonitorPtr)(mon->list.next);
1736
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
1737
node = NewNode(parent, NULL, NULL, parent->node, data);
1738
CreateMonitorField(node, True);
1739
if (parent->child == NULL)
1740
parent->child = node;
1746
CreateMonitorField(TreeNode *node, Bool addnew)
1748
Widget box, command, label;
1750
box = XtVaCreateWidget("monitor", formWidgetClass, tree,
1751
XtNtreeParent, node->treeParent, NULL);
1755
char *str, buf[256];
1756
XF86OptionPtr *options;
1757
XF86ConfMonitorPtr mon = node->data->monitor.monitor;
1759
TreeNode *modeline, *modes, *prev;
1761
options = &(mon->mon_option_lst);
1762
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
1764
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
1765
command = XtCreateManagedWidget("options", commandWidgetClass, box,
1767
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
1768
label = XtVaCreateManagedWidget("label", labelWidgetClass, box,
1769
XtNlabel, mon->mon_identifier, NULL);
1771
XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0);
1772
str = mon->mon_vendor ? mon->mon_vendor : "";
1773
node->data->monitor.vendor =
1774
XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box,
1775
XtNeditType, XawtextEdit,
1779
XtCreateManagedWidget("modelnameL", labelWidgetClass, box, NULL, 0);
1780
str = mon->mon_modelname ? mon->mon_modelname : "";
1781
node->data->monitor.model =
1782
XtVaCreateManagedWidget("modelname", asciiTextWidgetClass, box,
1783
XtNeditType, XawtextEdit,
1787
XtCreateManagedWidget("widthL", labelWidgetClass, box, NULL, 0);
1789
XmuSnprintf(buf, sizeof(buf), "%d", mon->mon_width);
1792
node->data->monitor.width =
1793
XtVaCreateManagedWidget("width", asciiTextWidgetClass, box,
1794
XtNeditType, XawtextEdit,
1798
XtCreateManagedWidget("heightL", labelWidgetClass, box, NULL, 0);
1799
if (mon->mon_height)
1800
XmuSnprintf(buf, sizeof(buf), "%d", mon->mon_height);
1803
node->data->monitor.height =
1804
XtVaCreateManagedWidget("height", asciiTextWidgetClass, box,
1805
XtNeditType, XawtextEdit,
1809
XtCreateManagedWidget("hsyncL", labelWidgetClass, box, NULL, 0);
1810
if (mon->mon_n_hsync > 0)
1811
parser_range_to_string(buf, &(mon->mon_hsync[0]),
1815
node->data->monitor.hsync =
1816
XtVaCreateManagedWidget("hsync", asciiTextWidgetClass, box,
1817
XtNeditType, XawtextEdit,
1821
XtCreateManagedWidget("vrefreshL", labelWidgetClass, box, NULL, 0);
1822
if (mon->mon_n_vrefresh > 0)
1823
parser_range_to_string(buf, &(mon->mon_vrefresh[0]),
1824
mon->mon_n_vrefresh);
1827
node->data->monitor.vrefresh =
1828
XtVaCreateManagedWidget("vrefresh", asciiTextWidgetClass, box,
1829
XtNeditType, XawtextEdit,
1833
XtCreateManagedWidget("gammaRedL", labelWidgetClass, box, NULL, 0);
1834
if (mon->mon_gamma_red)
1835
XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_red);
1838
node->data->monitor.gammaRed =
1839
XtVaCreateManagedWidget("gammaRed", asciiTextWidgetClass, box,
1840
XtNeditType, XawtextEdit,
1844
XtCreateManagedWidget("gammaGreenL", labelWidgetClass, box, NULL, 0);
1845
if (mon->mon_gamma_green)
1846
XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_green);
1849
node->data->monitor.gammaGreen =
1850
XtVaCreateManagedWidget("gammaGreen", asciiTextWidgetClass, box,
1851
XtNeditType, XawtextEdit,
1855
XtCreateManagedWidget("gammaBlueL", labelWidgetClass, box, NULL, 0);
1856
if (mon->mon_gamma_blue)
1857
XmuSnprintf(buf, sizeof(buf), "%g", mon->mon_gamma_blue);
1860
node->data->monitor.gammaBlue =
1861
XtVaCreateManagedWidget("gammaBlue", asciiTextWidgetClass, box,
1862
XtNeditType, XawtextEdit,
1866
if ((prev = node->child) != NULL)
1869
command = XtVaCreateManagedWidget("ModeLine", toggleWidgetClass, tree,
1871
XtNtreeParent, box, NULL);
1872
modeline = NewNode(node, command, command, node->node, NULL);
1873
CreateMonitorModeLine(modeline,
1874
node->data->monitor.monitor->mon_modeline_lst);
1876
prev = node->child = modeline;
1878
prev->next = modeline;
1882
useModes = XtVaCreateManagedWidget("UseModes", toggleWidgetClass, tree,
1884
XtNtreeParent, box, NULL);
1885
prev->next = modes = NewNode(node, useModes, useModes, node->node, NULL);
1886
CreateMonitorModes(modes,
1887
node->data->monitor.monitor->mon_modes_sect_lst);
1890
command = XtCreateManagedWidget("new", commandWidgetClass, box,
1892
XtAddCallback(command, XtNcallback, NewMonitorCallback, (XtPointer)node);
1893
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
1894
XtNeditType, XawtextEdit,
1896
node->data->monitor.text = label;
1898
if (XtIsRealized(node->treeParent))
1899
XtRealizeWidget(box);
1904
MonitorDestroy(TreeNode *node)
1907
TreeNode *sc = screenTree;
1909
for (i = 0; i < computer.num_devices; i++)
1910
if ((XF86ConfMonitorPtr)(computer.devices[i]->config) ==
1911
node->data->monitor.monitor) {
1912
config = computer.devices[i]->widget;
1913
RemoveDeviceCallback(NULL, NULL, NULL);
1919
sc = prev = sc->child;
1921
TreeNode *next = sc->next;
1923
if (sc->data->screen.screen->scrn_monitor ==
1924
node->data->monitor.monitor) {
1925
XtDestroyWidget(sc->node);
1928
DestroyTree(sc->child);
1930
XtFree((XtPointer)sc->data);
1931
XtFree((XtPointer)sc);
1933
if (sc == screenTree->child)
1934
sc = prev = next = screenTree->child = next;
1936
prev->next = sc = next;
1946
NewMonitorCallback(Widget w, XtPointer user_data, XtPointer call_data)
1948
TreeNode *parent, *node = (TreeNode*)user_data;
1949
XF86ConfMonitorPtr mon;
1953
XtSetArg(args[0], XtNstring, &label);
1954
XtGetValues(node->data->monitor.text, args, 1);
1958
parent = node->parent;
1960
mon = (XF86ConfMonitorPtr)XtCalloc(1, sizeof(XF86ConfMonitorRec));
1961
mon->mon_identifier = XtNewString(label);
1962
XF86Config->conf_monitor_lst =
1963
xf86addMonitor(XF86Config->conf_monitor_lst, mon);
1965
CreateMonitor(parent, mon);
1971
MonitorUpdate(TreeNode *node)
1976
XtVaGetValues(node->data->monitor.vendor, XtNstring, &str, NULL);
1977
XtFree(node->data->monitor.monitor->mon_vendor);
1979
node->data->monitor.monitor->mon_vendor = XtNewString(str);
1981
node->data->monitor.monitor->mon_vendor = NULL;
1984
XtVaGetValues(node->data->monitor.model, XtNstring, &str, NULL);
1985
XtFree(node->data->monitor.monitor->mon_modelname);
1987
node->data->monitor.monitor->mon_modelname = XtNewString(str);
1989
node->data->monitor.monitor->mon_modelname = NULL;
1992
XtVaGetValues(node->data->monitor.width, XtNstring, &str, NULL);
1993
node->data->monitor.monitor->mon_width = strtoul(str, NULL, 0);
1996
XtVaGetValues(node->data->monitor.height, XtNstring, &str, NULL);
1997
node->data->monitor.monitor->mon_height = strtoul(str, NULL, 0);
2000
XtVaGetValues(node->data->monitor.hsync, XtNstring, &str, NULL);
2001
node->data->monitor.monitor->mon_n_hsync =
2002
string_to_parser_range(str,
2003
&(node->data->monitor.monitor->mon_hsync[0]),
2007
XtVaGetValues(node->data->monitor.vrefresh, XtNstring, &str, NULL);
2008
node->data->monitor.monitor->mon_n_vrefresh =
2009
string_to_parser_range(str,
2010
&(node->data->monitor.monitor->mon_vrefresh[0]),
2014
XtVaGetValues(node->data->monitor.gammaRed, XtNstring, &str, NULL);
2015
node->data->monitor.monitor->mon_gamma_red = strtod(str, NULL);
2018
XtVaGetValues(node->data->monitor.gammaGreen, XtNstring, &str, NULL);
2019
node->data->monitor.monitor->mon_gamma_green = strtod(str, NULL);
2022
XtVaGetValues(node->data->monitor.gammaBlue, XtNstring, &str, NULL);
2023
node->data->monitor.monitor->mon_gamma_blue = strtod(str, NULL);
2027
CreateMonitorModeLine(TreeNode *parent, XF86ConfModeLinePtr modeline)
2029
TreeNode *node, *prev;
2032
if ((prev = parent->child) != NULL)
2037
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2038
data->modeline.modeline = modeline;
2039
node = NewNode(parent, NULL, NULL, parent->node, data);
2040
node->destroy = MonitorModeLineDestroy;
2041
CreateModeLineField(node, False, True);
2042
if (parent->child == NULL)
2043
parent->child = node;
2047
modeline = (XF86ConfModeLinePtr)(modeline->list.next);
2049
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2050
node = NewNode(parent, NULL, NULL, parent->node, data);
2051
if (parent->child == NULL)
2052
parent->child = node;
2056
CreateModeLineField(node, True, True);
2061
MonitorModeLineDestroy(TreeNode *node)
2063
if (node->data->modeline.modeline)
2064
xf86removeMonitorModeLine(node->parent->parent->data->monitor.monitor,
2065
node->data->modeline.modeline);
2070
NewMonitorModeLineCallback(Widget w, XtPointer user_data, XtPointer call_data)
2072
TreeNode *parent, *node = (TreeNode*)user_data;
2073
XF86ConfModeLinePtr modeline;
2075
char *ident, *value;
2077
XtSetArg(args[0], XtNstring, &ident);
2078
XtGetValues(node->data->modeline.text, args, 1);
2079
XtSetArg(args[0], XtNstring, &value);
2080
XtGetValues(node->data->modeline.value, args, 1);
2081
if (*ident == '\0' || *value == '\0')
2084
parent = node->parent;
2086
modeline = ParseModeLine(ident, value);
2087
parent->parent->data->monitor.monitor->mon_modeline_lst =
2088
xf86addModeLine(parent->parent->data->monitor.monitor->mon_modeline_lst,
2091
CreateMonitorModeLine(parent, modeline);
2096
CreateMonitorModes(TreeNode *parent, XF86ConfModesLinkPtr lnk)
2098
TreeNode *node, *prev;
2101
if ((prev = parent->child) != NULL)
2106
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2107
data->modeslink.modeslink = lnk;
2108
node = NewNode(parent, NULL, NULL, parent->node, data);
2109
node->destroy = MonitorModesLinkDestroy;
2110
CreateMonitorModesField(node, False);
2111
if (parent->child == NULL)
2112
parent->child = node;
2116
lnk = (XF86ConfModesLinkPtr)(lnk->list.next);
2118
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2119
node = NewNode(parent, NULL, NULL, parent->node, data);
2120
if (parent->child == NULL)
2121
parent->child = node;
2125
CreateMonitorModesField(node, True);
2129
CreateMonitorModesField(TreeNode *node, Bool addnew)
2131
Widget box, command;
2133
box = XtVaCreateWidget("modes", formWidgetClass, tree,
2134
XtNtreeParent, node->treeParent, NULL);
2138
XF86ConfModesLinkPtr lnk = node->data->modeslink.modeslink;
2140
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
2142
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
2143
(void) XtVaCreateManagedWidget("mode", labelWidgetClass, box,
2144
XtNlabel, lnk->ml_modes_str, NULL);
2148
XF86ConfModesPtr ptr = XF86Config->conf_modes_lst;
2150
command = XtVaCreateManagedWidget("new", menuButtonWidgetClass, box,
2151
XtNmenuName, "modesMenu", NULL);
2152
node->data->modeslink.menu =
2153
XtVaCreatePopupShell("modesMenu", simpleMenuWidgetClass, box,
2154
XtNleftMargin, 1, XtNrightMargin, 1,
2155
XtNtopMargin, 1, XtNbottomMargin, 1,
2158
sme = XtCreateManagedWidget(ptr->modes_identifier, smeBSBObjectClass,
2159
node->data->modeslink.menu, NULL, 0);
2160
XtAddCallback(sme, XtNcallback, NewMonitorModesCallback,
2162
ptr = (XF86ConfModesPtr)(ptr->list.next);
2165
if (XtIsRealized(node->treeParent))
2166
XtRealizeWidget(box);
2172
MonitorModesLinkDestroy(TreeNode *node)
2174
if (node->data->modeslink.modeslink)
2175
xf86removeMonitorModesLink(node->parent->parent->data->monitor.monitor,
2176
node->data->modeslink.modeslink);
2181
NewMonitorModesCallback(Widget w, XtPointer user_data, XtPointer call_data)
2183
TreeNode *parent, *node = (TreeNode*)user_data;
2184
XF86ConfModesLinkPtr link;
2185
char *ident = XtName(w);
2187
parent = node->parent;
2189
link = (XF86ConfModesLinkPtr)XtCalloc(1, sizeof(XF86ConfModesLinkRec));
2190
link->ml_modes_str = XtNewString(ident);
2191
parent->parent->data->monitor.monitor->mon_modes_sect_lst =
2192
xf86addModesLink(parent->parent->data->monitor.monitor->mon_modes_sect_lst,
2195
CreateMonitorModes(parent, link);
2201
CreateDevice(TreeNode *parent, XF86ConfDevicePtr dev)
2203
TreeNode *prev, *node;
2206
if ((prev = parent->child) != NULL)
2211
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2212
data->device.device = dev;
2213
node = NewNode(parent, NULL, NULL, parent->node, data);
2214
node->destroy = DeviceDestroy;
2215
node->update = DeviceUpdate;
2216
CreateDeviceField(node, False);
2217
if (parent->child == NULL)
2218
parent->child = node;
2222
dev = (XF86ConfDevicePtr)(dev->list.next);
2225
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2226
node = NewNode(parent, NULL, NULL, parent->node, data);
2227
CreateDeviceField(node, True);
2228
if (parent->child == NULL)
2229
parent->child = node;
2235
CreateDeviceField(TreeNode *node, Bool addnew)
2237
Widget box, command, label;
2239
box = XtVaCreateWidget("device", formWidgetClass, tree,
2240
XtNtreeParent, node->treeParent, NULL);
2245
char buf[1024], *str;
2246
XF86OptionPtr *options;
2247
XF86ConfDevicePtr dev = node->data->device.device;
2249
options = &(dev->dev_option_lst);
2250
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
2252
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
2253
command = XtCreateManagedWidget("options", commandWidgetClass, box,
2255
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
2256
label = XtVaCreateManagedWidget("label", labelWidgetClass, box,
2257
XtNlabel, dev->dev_identifier, NULL);
2259
XtCreateManagedWidget("vendorL", labelWidgetClass, box, NULL, 0);
2260
str = dev->dev_vendor ? dev->dev_vendor : "";
2261
node->data->device.vendor =
2262
XtVaCreateManagedWidget("vendor", asciiTextWidgetClass, box,
2263
XtNeditType, XawtextEdit,
2267
XtCreateManagedWidget("boardL", labelWidgetClass, box, NULL, 0);
2268
str = dev->dev_board ? dev->dev_board : "";
2269
node->data->device.board =
2270
XtVaCreateManagedWidget("board", asciiTextWidgetClass, box,
2271
XtNeditType, XawtextEdit,
2275
XtCreateManagedWidget("chipsetL", labelWidgetClass, box, NULL, 0);
2276
str = dev->dev_chipset ? dev->dev_chipset : "";
2277
node->data->device.chipset =
2278
XtVaCreateManagedWidget("chipset", asciiTextWidgetClass, box,
2279
XtNeditType, XawtextEdit,
2283
XtCreateManagedWidget("busidL", labelWidgetClass, box, NULL, 0);
2284
str = dev->dev_busid ? dev->dev_busid : "";
2285
node->data->device.busid =
2286
XtVaCreateManagedWidget("busid", asciiTextWidgetClass, box,
2287
XtNeditType, XawtextEdit,
2291
XtCreateManagedWidget("cardL", labelWidgetClass, box, NULL, 0);
2292
str = dev->dev_card ? dev->dev_card : "";
2293
node->data->device.card =
2294
XtVaCreateManagedWidget("card", asciiTextWidgetClass, box,
2295
XtNeditType, XawtextEdit,
2299
XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0);
2300
str = dev->dev_driver ? dev->dev_driver : "";
2301
node->data->device.driver =
2302
XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box,
2303
XtNeditType, XawtextEdit,
2307
XtCreateManagedWidget("ramdacL", labelWidgetClass, box, NULL, 0);
2308
str = dev->dev_ramdac ? dev->dev_ramdac : "";
2309
node->data->device.ramdac =
2310
XtVaCreateManagedWidget("ramdac", asciiTextWidgetClass, box,
2311
XtNeditType, XawtextEdit,
2315
XtCreateManagedWidget("dacSpeedL", labelWidgetClass, box, NULL, 0);
2316
if (dev->dev_dacSpeeds[0] > 0) {
2317
for (i = len = 0; i < CONF_MAXDACSPEEDS &&
2318
dev->dev_dacSpeeds[i] > 0; i++) {
2319
tmp = XmuSnprintf(buf + len, sizeof(buf) - len, "%g ",
2320
dev->dev_dacSpeeds[i] / 1000.);
2326
node->data->device.dacSpeed =
2327
XtVaCreateManagedWidget("dacSpeed", asciiTextWidgetClass, box,
2328
XtNeditType, XawtextEdit,
2332
XtCreateManagedWidget("videoRamL", labelWidgetClass, box, NULL, 0);
2333
if (dev->dev_videoram)
2334
XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_videoram);
2337
node->data->device.videoRam =
2338
XtVaCreateManagedWidget("videoRam", asciiTextWidgetClass, box,
2339
XtNeditType, XawtextEdit,
2343
XtCreateManagedWidget("textClockFreqL", labelWidgetClass, box, NULL, 0);
2344
if (dev->dev_textclockfreq)
2345
XmuSnprintf(buf, sizeof(buf), "%.1f",
2346
(double)dev->dev_textclockfreq / 1000.0);
2349
node->data->device.textClockFreq =
2350
XtVaCreateManagedWidget("textClockFreq", asciiTextWidgetClass, box,
2351
XtNeditType, XawtextEdit,
2355
XtCreateManagedWidget("biosBaseL", labelWidgetClass, box, NULL, 0);
2356
if (dev->dev_bios_base)
2357
XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_bios_base);
2360
node->data->device.biosBase =
2361
XtVaCreateManagedWidget("biosBase", asciiTextWidgetClass, box,
2362
XtNeditType, XawtextEdit,
2366
XtCreateManagedWidget("memBaseL", labelWidgetClass, box, NULL, 0);
2367
if (dev->dev_mem_base)
2368
XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_mem_base);
2371
node->data->device.memBase =
2372
XtVaCreateManagedWidget("memBase", asciiTextWidgetClass, box,
2373
XtNeditType, XawtextEdit,
2377
XtCreateManagedWidget("ioBaseL", labelWidgetClass, box, NULL, 0);
2378
if (dev->dev_io_base)
2379
XmuSnprintf(buf, sizeof(buf), "0x%lx", dev->dev_io_base);
2382
node->data->device.ioBase =
2383
XtVaCreateManagedWidget("ioBase", asciiTextWidgetClass, box,
2384
XtNeditType, XawtextEdit,
2388
XtCreateManagedWidget("clockChipL", labelWidgetClass, box, NULL, 0);
2389
str = dev->dev_clockchip ? dev->dev_clockchip : "";
2390
node->data->device.clockChip =
2391
XtVaCreateManagedWidget("clockChip", asciiTextWidgetClass, box,
2392
XtNeditType, XawtextEdit,
2397
for (i = len = 0; i < dev->dev_clocks; i++) {
2398
tmp = XmuSnprintf(buf + len, sizeof(buf) - len, "%.1f ",
2399
(double)dev->dev_clock[i] / 1000.0);
2402
XtCreateManagedWidget("devClockL", labelWidgetClass, box, NULL, 0);
2403
node->data->device.devClock =
2404
XtVaCreateManagedWidget("devClock", asciiTextWidgetClass, box,
2405
XtNeditType, XawtextEdit,
2409
XtCreateManagedWidget("chipIdL", labelWidgetClass, box, NULL, 0);
2410
if (dev->dev_chipid != -1)
2411
XmuSnprintf(buf, sizeof(buf), "0x%x", dev->dev_chipid);
2414
node->data->device.chipId =
2415
XtVaCreateManagedWidget("chipId", asciiTextWidgetClass, box,
2416
XtNeditType, XawtextEdit,
2420
XtCreateManagedWidget("chipRevL", labelWidgetClass, box, NULL, 0);
2421
if (dev->dev_chiprev != -1)
2422
XmuSnprintf(buf, sizeof(buf), "0x%x", dev->dev_chiprev);
2425
node->data->device.chipRev =
2426
XtVaCreateManagedWidget("chipRev", asciiTextWidgetClass, box,
2427
XtNeditType, XawtextEdit,
2431
XtCreateManagedWidget("irqL", labelWidgetClass, box, NULL, 0);
2432
if (dev->dev_irq != -1)
2433
XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_irq);
2436
node->data->device.irq =
2437
XtVaCreateManagedWidget("irq", asciiTextWidgetClass, box,
2438
XtNeditType, XawtextEdit,
2442
XtCreateManagedWidget("screenL", labelWidgetClass, box, NULL, 0);
2443
if (dev->dev_screen > 0)
2444
XmuSnprintf(buf, sizeof(buf), "%d", dev->dev_screen);
2447
node->data->device.screen =
2448
XtVaCreateManagedWidget("screen", asciiTextWidgetClass, box,
2449
XtNeditType, XawtextEdit,
2454
command = XtCreateManagedWidget("new", commandWidgetClass, box,
2456
XtAddCallback(command, XtNcallback, NewDeviceCallback, (XtPointer)node);
2457
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
2458
XtNeditType, XawtextEdit,
2460
node->data->device.text = label;
2462
if (XtIsRealized(node->treeParent))
2463
XtRealizeWidget(box);
2468
NewDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
2470
TreeNode *parent, *node = (TreeNode*)user_data;
2471
XF86ConfDevicePtr dev;
2475
XtSetArg(args[0], XtNstring, &label);
2476
XtGetValues(node->data->device.text, args, 1);
2480
parent = node->parent;
2482
dev = (XF86ConfDevicePtr)XtCalloc(1, sizeof(XF86ConfDeviceRec));
2483
dev->dev_identifier = XtNewString(label);
2484
dev->dev_chipid = -1;
2485
dev->dev_chiprev = -1;
2488
XF86Config->conf_device_lst =
2489
xf86addDevice(XF86Config->conf_device_lst, dev);
2491
CreateDevice(parent, dev);
2497
DeviceDestroy(TreeNode *node)
2500
TreeNode *sc = screenTree;
2502
for (i = 0; i < computer.num_devices; i++)
2503
if ((XF86ConfDevicePtr)(computer.devices[i]->config) ==
2504
node->data->device.device) {
2505
config = computer.devices[i]->widget;
2506
RemoveDeviceCallback(NULL, NULL, NULL);
2512
sc = prev = sc->child;
2514
TreeNode *next = sc->next;
2516
if (sc->data->screen.screen->scrn_monitor ==
2517
node->data->monitor.monitor) {
2518
XtDestroyWidget(sc->node);
2521
DestroyTree(sc->child);
2523
XtFree((XtPointer)sc->data);
2524
XtFree((XtPointer)sc);
2526
if (sc == screenTree->child)
2527
sc = prev = next = screenTree->child = next;
2529
prev->next = sc = next;
2539
DeviceUpdate(TreeNode *node)
2545
XtVaGetValues(node->data->device.vendor, XtNstring, &str, NULL);
2546
XtFree(node->data->device.device->dev_vendor);
2548
node->data->device.device->dev_vendor = XtNewString(str);
2550
node->data->device.device->dev_vendor = NULL;
2553
XtVaGetValues(node->data->device.board, XtNstring, &str, NULL);
2554
XtFree(node->data->device.device->dev_board);
2556
node->data->device.device->dev_board = XtNewString(str);
2558
node->data->device.device->dev_board = NULL;
2561
XtVaGetValues(node->data->device.chipset, XtNstring, &str, NULL);
2562
XtFree(node->data->device.device->dev_chipset);
2564
node->data->device.device->dev_chipset = XtNewString(str);
2566
node->data->device.device->dev_chipset = NULL;
2569
XtVaGetValues(node->data->device.busid, XtNstring, &str, NULL);
2570
XtFree(node->data->device.device->dev_busid);
2572
node->data->device.device->dev_busid = XtNewString(str);
2574
node->data->device.device->dev_busid = NULL;
2577
XtVaGetValues(node->data->device.card, XtNstring, &str, NULL);
2578
XtFree(node->data->device.device->dev_card);
2580
node->data->device.device->dev_card = XtNewString(str);
2582
node->data->device.device->dev_card = NULL;
2585
XtVaGetValues(node->data->device.driver, XtNstring, &str, NULL);
2586
XtFree(node->data->device.device->dev_driver);
2588
node->data->device.device->dev_driver = XtNewString(str);
2590
node->data->device.device->dev_driver = NULL;
2593
XtVaGetValues(node->data->device.ramdac, XtNstring, &str, NULL);
2594
XtFree(node->data->device.device->dev_ramdac);
2596
node->data->device.device->dev_ramdac = XtNewString(str);
2598
node->data->device.device->dev_ramdac = NULL;
2602
XtVaGetValues(node->data->device.dacSpeed, XtNstring, &str, NULL);
2603
for (i = 0; i < CONF_MAXDACSPEEDS && str != tmp; i++) {
2604
if ((node->data->device.device->dev_dacSpeeds[i] =
2605
(strtod(str, &tmp) * 1000. + .5)) == 0)
2608
while (isspace(*str))
2613
XtVaGetValues(node->data->device.videoRam, XtNstring, &str, NULL);
2614
node->data->device.device->dev_videoram = strtoul(str, NULL, 0);
2617
XtVaGetValues(node->data->device.textClockFreq, XtNstring, &str, NULL);
2618
node->data->device.device->dev_textclockfreq =
2619
strtod(str, NULL) * 1000. + .5;
2622
XtVaGetValues(node->data->device.biosBase, XtNstring, &str, NULL);
2623
node->data->device.device->dev_bios_base = strtoul(str, NULL, 0);
2626
XtVaGetValues(node->data->device.memBase, XtNstring, &str, NULL);
2627
node->data->device.device->dev_mem_base = strtoul(str, NULL, 0);
2630
XtVaGetValues(node->data->device.ioBase, XtNstring, &str, NULL);
2631
node->data->device.device->dev_io_base = strtoul(str, NULL, 0);
2634
XtVaGetValues(node->data->device.clockChip, XtNstring, &str, NULL);
2635
XtFree(node->data->device.device->dev_clockchip);
2637
node->data->device.device->dev_clockchip = XtNewString(str);
2639
node->data->device.device->dev_clockchip = NULL;
2643
XtVaGetValues(node->data->device.devClock, XtNstring, &str, NULL);
2644
for (i = 0; i < CONF_MAXCLOCKS && str != tmp; i++) {
2645
if ((node->data->device.device->dev_clock[i] =
2646
(strtod(str, &tmp) * 1000. + .5)) == 0)
2649
while (isspace(*str))
2652
node->data->device.device->dev_clocks = i;
2655
XtVaGetValues(node->data->device.chipId, XtNstring, &str, NULL);
2657
node->data->device.device->dev_chipid = strtoul(str, NULL, 0);
2659
node->data->device.device->dev_chipid = -1;
2662
XtVaGetValues(node->data->device.chipRev, XtNstring, &str, NULL);
2664
node->data->device.device->dev_chiprev = strtoul(str, NULL, 0);
2666
node->data->device.device->dev_chiprev = -1;
2669
XtVaGetValues(node->data->device.irq, XtNstring, &str, NULL);
2671
node->data->device.device->dev_irq = strtoul(str, NULL, 0);
2673
node->data->device.device->dev_irq = -1;
2676
XtVaGetValues(node->data->device.screen, XtNstring, &str, NULL);
2678
node->data->device.device->dev_screen = strtoul(str, NULL, 0);
2680
node->data->device.device->dev_screen = -1;
2685
CreateScreen(TreeNode *parent, XF86ConfScreenPtr scrn)
2687
TreeNode *prev, *node;
2690
if ((prev = parent->child) != NULL)
2695
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2696
data->screen.screen = scrn;
2697
node = NewNode(parent, NULL, NULL, parent->node, data);
2698
node->destroy = ScreenDestroy;
2699
node->update = ScreenUpdate;
2700
CreateScreenField(node, False);
2701
if (parent->child == NULL)
2702
parent->child = node;
2706
scrn = (XF86ConfScreenPtr)(scrn->list.next);
2709
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2710
node = NewNode(parent, NULL, NULL, parent->node, data);
2711
CreateScreenField(node, True);
2712
if (parent->child == NULL)
2713
parent->child = node;
2719
CreateScreenField(TreeNode *node, Bool addnew)
2721
Widget box, command, label;
2723
box = XtVaCreateWidget("screen", formWidgetClass, tree,
2724
XtNtreeParent, node->treeParent, NULL);
2728
char buf[256], *str;
2729
XF86OptionPtr *options;
2730
TreeNode *adaptor, *display;
2731
XF86ConfScreenPtr scrn = node->data->screen.screen;
2733
options = &(scrn->scrn_option_lst);
2734
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
2736
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
2737
command = XtCreateManagedWidget("options", commandWidgetClass, box,
2739
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
2740
label = XtVaCreateManagedWidget("label", labelWidgetClass, box,
2741
XtNlabel, scrn->scrn_identifier, NULL);
2743
XtCreateManagedWidget("defaultDepthL", labelWidgetClass, box, NULL, 0);
2744
if (scrn->scrn_defaultdepth)
2745
XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultdepth);
2748
node->data->screen.defaultDepth =
2749
XtVaCreateManagedWidget("defaultDepth", asciiTextWidgetClass, box,
2750
XtNeditType, XawtextEdit,
2754
XtCreateManagedWidget("defaultBppL", labelWidgetClass, box, NULL, 0);
2755
if (scrn->scrn_defaultbpp)
2756
XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultbpp);
2759
node->data->screen.defaultBpp =
2760
XtVaCreateManagedWidget("defaultBpp", asciiTextWidgetClass, box,
2761
XtNeditType, XawtextEdit,
2765
XtCreateManagedWidget("defaultFbBppL", labelWidgetClass, box, NULL, 0);
2766
if (scrn->scrn_defaultfbbpp)
2767
XmuSnprintf(buf, sizeof(buf), "%d", scrn->scrn_defaultfbbpp);
2770
node->data->screen.defaultFbBpp =
2771
XtVaCreateManagedWidget("defaultFbBpp", asciiTextWidgetClass, box,
2772
XtNeditType, XawtextEdit,
2776
XtCreateManagedWidget("monitorL", labelWidgetClass, box, NULL, 0);
2777
str = scrn->scrn_monitor_str ? scrn->scrn_monitor_str : "";
2778
node->data->screen.monitor =
2779
XtVaCreateManagedWidget("monitor", asciiTextWidgetClass, box,
2780
XtNeditType, XawtextEdit,
2784
XtCreateManagedWidget("deviceL", labelWidgetClass, box, NULL, 0);
2785
str = scrn->scrn_device_str ? scrn->scrn_device_str : "";
2786
node->data->screen.device =
2787
XtVaCreateManagedWidget("device", asciiTextWidgetClass, box,
2788
XtNeditType, XawtextEdit,
2792
command = XtVaCreateManagedWidget("videoAdaptor", toggleWidgetClass,
2793
tree, XtNstate, True,
2794
XtNtreeParent, box, NULL);
2795
adaptor = NewNode(node, command, command, node->node, NULL);
2796
CreateScreenAdaptor(adaptor, scrn->scrn_adaptor_lst);
2797
node->child = adaptor;
2799
command = XtVaCreateManagedWidget("Display", toggleWidgetClass,
2800
tree, XtNstate, True,
2801
XtNtreeParent, box, NULL);
2802
display = NewNode(node, command, command, node->node, NULL);
2803
CreateScreenDisplay(display, scrn->scrn_display_lst);
2804
adaptor->next = display;
2807
command = XtCreateManagedWidget("new", commandWidgetClass, box,
2809
XtAddCallback(command, XtNcallback, NewScreenCallback, (XtPointer)node);
2810
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
2811
XtNeditType, XawtextEdit,
2813
node->data->screen.text = label;
2815
if (XtIsRealized(node->treeParent))
2816
XtRealizeWidget(box);
2821
NewScreenCallback(Widget w, XtPointer user_data, XtPointer call_data)
2823
TreeNode *parent, *node = (TreeNode*)user_data;
2824
XF86ConfScreenPtr scrn;
2828
XtSetArg(args[0], XtNstring, &label);
2829
XtGetValues(node->data->screen.text, args, 1);
2833
parent = node->parent;
2835
scrn = (XF86ConfScreenPtr)XtCalloc(1, sizeof(XF86ConfScreenRec));
2836
scrn->scrn_identifier = XtNewString(label);
2837
XF86Config->conf_screen_lst =
2838
xf86addScreen(XF86Config->conf_screen_lst, scrn);
2841
TreeNode *lay = layoutTree->child;
2844
/* last one is the "new" entry */
2845
while (lay && lay->next != NULL) {
2846
/* Adjacency is the first entry */
2847
TreeNode *adj = lay->child->child;
2849
while (adj != NULL) {
2850
sme = XtCreateManagedWidget(label, smeBSBObjectClass,
2851
adj->data->adjacency.menu, NULL, 0);
2852
XtAddCallback(sme, XtNcallback, adj->next != NULL ?
2853
AdjacencyMenuCallback : NewAdjacencyCallback,
2861
CreateScreen(parent, scrn);
2867
ScreenDestroy(TreeNode *node)
2869
if (node->data->screen.screen) {
2871
TreeNode *lay = layoutTree->child;
2873
/* last one is the "new" entry */
2874
while (lay && lay->next) {
2875
/* Adjacency is the first entry */
2876
TreeNode *adj = lay->child->child;
2877
CompositeWidget composite;
2880
TreeNode *next = adj->next;
2882
composite = (CompositeWidget)adj->data->adjacency.menu;
2884
for (i = 0; i < composite->composite.num_children; ++i)
2885
if (strcmp(XtName(composite->composite.children[i]),
2886
node->data->screen.screen->scrn_identifier) == 0) {
2887
XtDestroyWidget(composite->composite.children[i]);
2891
if (adj->data->adjacency.screen == node->data->screen.screen)
2900
for (i = 0; i < computer.num_screens; i++)
2901
if (computer.screens[i]->screen == node->data->screen.screen) {
2902
config = computer.screens[i]->widget;
2903
RemoveDeviceCallback(NULL, NULL, NULL);
2906
/* for the case of screens added and removed in the expert dialog */
2907
xf86removeScreen(XF86Config, node->data->screen.screen);
2912
ScreenUpdate(TreeNode *node)
2917
XtVaGetValues(node->data->screen.defaultDepth, XtNstring, &str, NULL);
2918
node->data->screen.screen->scrn_defaultdepth = strtoul(str, NULL, 0);
2921
XtVaGetValues(node->data->screen.defaultBpp, XtNstring, &str, NULL);
2922
node->data->screen.screen->scrn_defaultbpp = strtoul(str, NULL, 0);
2925
XtVaGetValues(node->data->screen.defaultFbBpp, XtNstring, &str, NULL);
2926
node->data->screen.screen->scrn_defaultfbbpp = strtoul(str, NULL, 0);
2929
/* XXX Monitor and Device should be changed to a menu interface */
2931
XtVaGetValues(node->data->screen.monitor, XtNstring, &str, NULL);
2932
XtFree(node->data->screen.screen->scrn_monitor_str);
2934
node->data->screen.screen->scrn_monitor_str = XtNewString(str);
2936
node->data->screen.screen->scrn_monitor_str = NULL;
2938
/* XXX Monitor and Device should be changed to a menu interface */
2940
XtVaGetValues(node->data->screen.device, XtNstring, &str, NULL);
2941
XtFree(node->data->screen.screen->scrn_device_str);
2943
node->data->screen.screen->scrn_device_str = XtNewString(str);
2945
node->data->screen.screen->scrn_device_str = NULL;
2949
CreateScreenAdaptor(TreeNode *parent, XF86ConfAdaptorLinkPtr lnk)
2951
TreeNode *node, *prev;
2954
if ((prev = parent->child) != NULL)
2959
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2960
data->adaptorlink.adaptorlink = lnk;
2961
node = NewNode(parent, NULL, NULL, parent->node, data);
2962
node->destroy = ScreenAdaptorDestroy;
2963
CreateScreenAdaptorField(node, False);
2964
if (parent->child == NULL)
2965
parent->child = node;
2969
lnk = (XF86ConfAdaptorLinkPtr)(lnk->list.next);
2971
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
2972
node = NewNode(parent, NULL, NULL, parent->node, data);
2973
if (parent->child == NULL)
2974
parent->child = node;
2978
CreateScreenAdaptorField(node, True);
2982
CreateScreenAdaptorField(TreeNode *node, Bool addnew)
2984
Widget box, command;
2986
box = XtVaCreateWidget("adaptor", formWidgetClass, tree,
2987
XtNtreeParent, node->treeParent, NULL);
2991
XF86ConfAdaptorLinkPtr lnk = node->data->adaptorlink.adaptorlink;
2993
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
2995
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
2996
(void) XtVaCreateManagedWidget("label", labelWidgetClass, box,
2997
XtNlabel, lnk->al_adaptor_str, NULL);
3001
XF86ConfVideoAdaptorPtr ptr = XF86Config->conf_videoadaptor_lst;
3003
command = XtVaCreateManagedWidget("new", menuButtonWidgetClass, box,
3004
XtNmenuName, "adaptorMenu", NULL);
3005
node->data->adaptorlink.menu =
3006
XtVaCreatePopupShell("adaptorMenu", simpleMenuWidgetClass, box,
3007
XtNleftMargin, 1, XtNrightMargin, 1,
3008
XtNtopMargin, 1, XtNbottomMargin, 1,
3011
sme = XtCreateManagedWidget(ptr->va_identifier, smeBSBObjectClass,
3012
node->data->adaptorlink.menu, NULL, 0);
3013
XtAddCallback(sme, XtNcallback, NewScreenAdaptorCallback,
3015
ptr = (XF86ConfVideoAdaptorPtr)(ptr->list.next);
3018
if (XtIsRealized(node->treeParent))
3019
XtRealizeWidget(box);
3025
NewScreenAdaptorCallback(Widget w, XtPointer user_data, XtPointer call_data)
3027
TreeNode *parent, *node = (TreeNode*)user_data;
3028
XF86ConfAdaptorLinkPtr link;
3029
char *ident = XtName(w);
3031
parent = node->parent;
3033
link = (XF86ConfAdaptorLinkPtr)XtCalloc(1, sizeof(XF86ConfAdaptorLinkRec));
3034
link->al_adaptor_str = XtNewString(ident);
3035
parent->parent->data->screen.screen->scrn_adaptor_lst =
3036
xf86addScreenAdaptor(parent->parent->data->screen.screen->scrn_adaptor_lst,
3039
CreateScreenAdaptor(parent, link);
3045
ScreenAdaptorDestroy(TreeNode *node)
3047
if (node->data->adaptorlink.adaptorlink)
3048
xf86removeScreenAdaptorLink(node->parent->parent->data->screen.screen,
3049
node->data->adaptorlink.adaptorlink);
3053
CreateScreenDisplay(TreeNode *parent, XF86ConfDisplayPtr dsp)
3055
TreeNode *node, *prev;
3058
if ((prev = parent->child) != NULL)
3063
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3064
data->display.display = dsp;
3065
node = NewNode(parent, NULL, NULL, parent->node, data);
3066
node->destroy = ScreenDisplayDestroy;
3067
node->update = ScreenDisplayUpdate;
3068
CreateScreenDisplayField(node, False);
3069
if (parent->child == NULL)
3070
parent->child = node;
3074
dsp = (XF86ConfDisplayPtr)(dsp->list.next);
3076
node = NewNode(parent, NULL, NULL, parent->node, NULL);
3077
if (parent->child == NULL)
3078
parent->child = node;
3082
CreateScreenDisplayField(node, True);
3086
CreateScreenDisplayField(TreeNode *node, Bool addnew)
3088
Widget box, command;
3090
box = XtVaCreateWidget("display", formWidgetClass, tree,
3091
XtNtreeParent, node->treeParent, NULL);
3095
char *str, buf[256];
3096
XF86OptionPtr *options;
3097
XF86ConfDisplayPtr dsp = node->data->display.display;
3100
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
3102
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
3103
options = &(dsp->disp_option_lst);
3104
command = XtCreateManagedWidget("options", commandWidgetClass, box,
3106
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
3108
XtCreateManagedWidget("viewportL", labelWidgetClass, box, NULL, 0);
3109
if (dsp->disp_frameX0 != 0 || dsp->disp_frameY0 != 0)
3110
XmuSnprintf(buf, sizeof(buf), "%d %d", dsp->disp_frameX0, dsp->disp_frameY0);
3113
node->data->display.viewport =
3114
XtVaCreateManagedWidget("viewport", asciiTextWidgetClass, box,
3115
XtNeditType, XawtextEdit,
3116
XtNstring, buf, NULL);
3118
XtCreateManagedWidget("virtualL", labelWidgetClass, box, NULL, 0);
3119
if (dsp->disp_virtualX != 0 || dsp->disp_virtualY != 0)
3120
XmuSnprintf(buf, sizeof(buf), "%d %d", dsp->disp_virtualX, dsp->disp_virtualY);
3123
node->data->display.c_virtual =
3124
XtVaCreateManagedWidget("virtual", asciiTextWidgetClass, box,
3125
XtNeditType, XawtextEdit,
3126
XtNstring, buf, NULL);
3128
XtCreateManagedWidget("depthL", labelWidgetClass, box, NULL, 0);
3129
if (dsp->disp_depth != 0)
3130
XmuSnprintf(buf, sizeof(buf), "%d", dsp->disp_depth);
3133
node->data->display.depth =
3134
XtVaCreateManagedWidget("depth", asciiTextWidgetClass, box,
3135
XtNeditType, XawtextEdit,
3136
XtNstring, buf, NULL);
3138
XtCreateManagedWidget("bppL", labelWidgetClass, box, NULL, 0);
3139
if (dsp->disp_bpp != 0)
3140
XmuSnprintf(buf, sizeof(buf), "%d", dsp->disp_bpp);
3143
node->data->display.bpp =
3144
XtVaCreateManagedWidget("bpp", asciiTextWidgetClass, box,
3145
XtNeditType, XawtextEdit,
3146
XtNstring, buf, NULL);
3148
XtCreateManagedWidget("visualL", labelWidgetClass, box, NULL, 0);
3149
str = dsp->disp_visual != NULL ? dsp->disp_visual : "";
3150
node->data->display.visual =
3151
XtVaCreateManagedWidget("visual", asciiTextWidgetClass, box,
3152
XtNeditType, XawtextEdit,
3153
XtNstring, str, NULL);
3155
XtCreateManagedWidget("weightL", labelWidgetClass, box, NULL, 0);
3156
if (dsp->disp_weight.red > 0)
3157
XmuSnprintf(buf, sizeof(buf), "%d %d %d",
3158
dsp->disp_weight.red, dsp->disp_weight.green, dsp->disp_weight.blue);
3161
node->data->display.weight =
3162
XtVaCreateManagedWidget("weight", asciiTextWidgetClass, box,
3163
XtNeditType, XawtextEdit,
3164
XtNstring, buf, NULL);
3166
XtCreateManagedWidget("blackL", labelWidgetClass, box, NULL, 0);
3167
if (dsp->disp_black.red >= 0)
3168
XmuSnprintf(buf, sizeof(buf), "0x%04x 0x%04x 0x%04x",
3169
dsp->disp_black.red, dsp->disp_black.green, dsp->disp_black.blue);
3172
node->data->display.black =
3173
XtVaCreateManagedWidget("black", asciiTextWidgetClass, box,
3174
XtNeditType, XawtextEdit,
3175
XtNstring, buf, NULL);
3177
XtCreateManagedWidget("whiteL", labelWidgetClass, box, NULL, 0);
3178
if (dsp->disp_white.red >= 0)
3179
XmuSnprintf(buf, sizeof(buf), "0x%04x 0x%04x 0x%04x",
3180
dsp->disp_white.red, dsp->disp_white.green, dsp->disp_white.blue);
3183
node->data->display.white =
3184
XtVaCreateManagedWidget("white", asciiTextWidgetClass, box,
3185
XtNeditType, XawtextEdit,
3186
XtNstring, buf, NULL);
3188
command = XtVaCreateManagedWidget("Modes", toggleWidgetClass, tree,
3189
XtNstate, True, XtNtreeParent, box,
3191
modes = NewNode(node, command, command, node->node, NULL);
3192
node->child = modes;
3193
CreateDisplayMode(modes, dsp->disp_mode_lst);
3196
command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0);
3197
XtAddCallback(command, XtNcallback, NewScreenDisplayCallback,
3200
if (XtIsRealized(node->treeParent))
3201
XtRealizeWidget(box);
3207
NewScreenDisplayCallback(Widget w, XtPointer user_data, XtPointer call_data)
3209
TreeNode *parent, *node = (TreeNode*)user_data;
3210
XF86ConfDisplayPtr dsp;
3212
parent = node->parent;
3214
dsp = (XF86ConfDisplayPtr)XtCalloc(1, sizeof(XF86ConfDisplayRec));
3215
dsp->disp_black.red = dsp->disp_black.green = dsp->disp_black.blue =
3216
dsp->disp_white.red = dsp->disp_white.green = dsp->disp_white.blue = -1;
3217
parent->parent->data->screen.screen->scrn_display_lst =
3218
xf86addScreenDisplay(parent->parent->data->screen.screen->scrn_display_lst,
3221
CreateScreenDisplay(parent, dsp);
3226
ScreenDisplayDestroy(TreeNode *node)
3228
if (node->data->display.display)
3229
xf86removeScreenDisplay(node->parent->parent->data->screen.screen,
3230
node->data->display.display);
3234
ScreenDisplayUpdate(TreeNode *node)
3240
XtVaGetValues(node->data->display.viewport, XtNstring, &str, NULL);
3241
if (sscanf(str, "%d %d", &x, &y) == 2) {
3242
node->data->display.display->disp_frameX0 = x;
3243
node->data->display.display->disp_frameY0 = y;
3247
XtVaGetValues(node->data->display.c_virtual, XtNstring, &str, NULL);
3248
if (sscanf(str, "%d %d", &x, &y) == 2) {
3249
node->data->display.display->disp_virtualX = x;
3250
node->data->display.display->disp_virtualY = y;
3254
XtVaGetValues(node->data->display.depth, XtNstring, &str, NULL);
3255
node->data->display.display->disp_depth = strtoul(str, NULL, 0);
3258
XtVaGetValues(node->data->display.bpp, XtNstring, &str, NULL);
3259
node->data->display.display->disp_bpp = strtoul(str, NULL, 0);
3262
XtVaGetValues(node->data->display.visual, XtNstring, &str, NULL);
3263
XtFree(node->data->display.display->disp_visual);
3265
node->data->display.display->disp_visual = XtNewString(str);
3267
node->data->display.display->disp_visual = NULL;
3270
XtVaGetValues(node->data->display.weight, XtNstring, &str, NULL);
3271
node->data->display.display->disp_weight.red = strtoul(str, &tmp, 0);
3273
node->data->display.display->disp_weight.red = 0;
3276
while (isspace(*str))
3278
node->data->display.display->disp_weight.green = strtoul(str, &tmp, 0);
3281
while (isspace(*str))
3283
node->data->display.display->disp_weight.blue = strtoul(str, &tmp, 0);
3288
XtVaGetValues(node->data->display.black, XtNstring, &str, NULL);
3289
node->data->display.display->disp_black.red = strtoul(str, &tmp, 0);
3291
node->data->display.display->disp_black.red = -1;
3294
while (isspace(*str))
3296
node->data->display.display->disp_black.green = strtoul(str, &tmp, 0);
3299
while (isspace(*str))
3301
node->data->display.display->disp_black.blue = strtoul(str, &tmp, 0);
3306
XtVaGetValues(node->data->display.white, XtNstring, &str, NULL);
3307
node->data->display.display->disp_white.red = strtoul(str, &tmp, 0);
3309
node->data->display.display->disp_white.red = -1;
3312
while (isspace(*str))
3314
node->data->display.display->disp_white.green = strtoul(str, &tmp, 0);
3317
while (isspace(*str))
3319
node->data->display.display->disp_white.blue = strtoul(str, &tmp, 0);
3325
CreateDisplayMode(TreeNode *parent, XF86ModePtr modes)
3327
TreeNode *node, *prev;
3330
if ((prev = parent->child) != NULL)
3335
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3336
data->mode.mode = modes;
3337
node = NewNode(parent, NULL, NULL, parent->node, data);
3338
node->destroy = DisplayModeDestroy;
3339
CreateDisplayModeField(node, False);
3340
if (parent->child == NULL)
3341
parent->child = node;
3345
modes = (XF86ModePtr)(modes->list.next);
3347
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3348
node = NewNode(parent, NULL, NULL, parent->node, data);
3349
if (parent->child == NULL)
3350
parent->child = node;
3354
CreateDisplayModeField(node, True);
3358
CreateDisplayModeField(TreeNode *node, Bool addnew)
3360
Widget box, command, text;
3362
box = XtVaCreateWidget("mode", formWidgetClass, tree,
3363
XtNtreeParent, node->treeParent, NULL);
3366
XF86ModePtr mode = node->data->mode.mode;
3368
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
3370
XtAddCallback(command, XtNcallback, DestroyCallback,
3372
text = XtVaCreateManagedWidget("label", labelWidgetClass, box,
3373
XtNlabel, mode->mode_name, NULL);
3376
command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0);
3377
XtAddCallback(command, XtNcallback, NewDisplayModeCallback,
3379
text = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
3380
XtNeditType, XawtextEdit, NULL);
3382
node->data->mode.text = text;
3383
if (node->treeParent && XtIsRealized(node->treeParent))
3384
XtRealizeWidget(box);
3390
NewDisplayModeCallback(Widget w, XtPointer user_data, XtPointer call_data)
3392
TreeNode *parent, *node = (TreeNode*)user_data;
3397
XtSetArg(args[0], XtNstring, &ident);
3398
XtGetValues(node->data->mode.text, args, 1);
3402
parent = node->parent;
3404
mode = (XF86ModePtr)XtCalloc(1, sizeof(XF86ModeRec));
3405
mode->mode_name = XtNewString(ident);
3406
parent->parent->data->display.display->disp_mode_lst =
3407
xf86addDisplayMode(parent->parent->data->display.display->disp_mode_lst,
3410
CreateDisplayMode(parent, mode);
3416
DisplayModeDestroy(TreeNode *node)
3418
if (node->data->mode.mode)
3419
xf86removeDisplayMode(node->parent->parent->data->display.display,
3420
node->data->mode.mode);
3425
CreateInput(TreeNode *parent, XF86ConfInputPtr input)
3427
TreeNode *prev, *node;
3430
if ((prev = parent->child) != NULL)
3435
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3436
data->input.input = input;
3437
node = NewNode(parent, NULL, NULL, parent->node, data);
3438
node->destroy = InputDestroy;
3439
node->update = InputUpdate;
3440
CreateInputField(node, False);
3441
if (parent->child == NULL)
3442
parent->child = node;
3446
input = (XF86ConfInputPtr)(input->list.next);
3449
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3450
node = NewNode(parent, NULL, NULL, parent->node, data);
3451
CreateInputField(node, True);
3452
if (parent->child == NULL)
3453
parent->child = node;
3459
CreateInputField(TreeNode *node, Bool addnew)
3461
Widget box, command;
3463
box = XtVaCreateWidget("input", formWidgetClass, tree,
3464
XtNtreeParent, node->treeParent, NULL);
3469
XF86OptionPtr *options;
3470
XF86ConfInputPtr inp = node->data->input.input;
3472
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
3474
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
3475
options = &(inp->inp_option_lst);
3476
command = XtCreateManagedWidget("options", commandWidgetClass, box,
3478
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
3479
XtVaCreateManagedWidget("label", labelWidgetClass, box,
3480
XtNlabel, inp->inp_identifier, NULL);
3482
XtCreateManagedWidget("driverL", labelWidgetClass, box, NULL, 0);
3483
str = inp->inp_driver != NULL ? inp->inp_driver : "";
3484
node->data->input.text =
3485
XtVaCreateManagedWidget("driver", asciiTextWidgetClass, box,
3486
XtNeditType, XawtextEdit,
3487
XtNstring, str, NULL);
3490
command = XtCreateManagedWidget("new", commandWidgetClass, box, NULL, 0);
3491
XtAddCallback(command, XtNcallback, NewInputCallback,
3493
node->data->input.text =
3494
XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
3495
XtNeditType, XawtextEdit, NULL);
3497
if (XtIsRealized(node->treeParent))
3498
XtRealizeWidget(box);
3504
NewInputCallback(Widget w, XtPointer user_data, XtPointer call_data)
3506
TreeNode *parent, *node = (TreeNode*)user_data;
3507
XF86ConfInputPtr input;
3511
XtSetArg(args[0], XtNstring, &ident);
3512
XtGetValues(node->data->input.text, args, 1);
3516
parent = node->parent;
3518
input = (XF86ConfInputPtr)XtCalloc(1, sizeof(XF86ConfInputRec));
3519
input->inp_identifier = XtNewString(ident);
3520
XF86Config->conf_input_lst =
3521
xf86addInput(XF86Config->conf_input_lst, input);
3524
TreeNode *lay = layoutTree->child;
3527
/* last one is the "new" entry */
3528
while (lay && lay->next != NULL) {
3529
/* Inputref is the second entry */
3530
TreeNode *iref = lay->child->next->child;
3532
while (iref && iref->next)
3534
sme = XtCreateManagedWidget(ident, smeBSBObjectClass,
3535
iref->data->inputref.menu, NULL, 0);
3536
XtAddCallback(sme, XtNcallback, NewInputrefCallback,
3542
CreateInput(parent, input);
3548
InputDestroy(TreeNode *node)
3550
if (node->data->input.input) {
3552
TreeNode *lay = layoutTree->child;
3554
/* last one is the "new" entry */
3555
while (lay && lay->next) {
3556
/* Inputref is the second entry */
3557
TreeNode *iref = lay->child->next->child;
3558
CompositeWidget composite;
3560
while (iref && iref->next) {
3561
TreeNode *next = iref->next;
3563
if (iref && strcmp(iref->data->inputref.inputref->iref_inputdev_str,
3564
node->data->input.input->inp_identifier) == 0)
3569
composite = (CompositeWidget)iref->data->inputref.menu;
3571
for (i = 0; i < composite->composite.num_children; ++i)
3572
if (strcmp(XtName(composite->composite.children[i]),
3573
node->data->input.input->inp_identifier) == 0)
3574
XtDestroyWidget(composite->composite.children[i]);
3579
for (i = 0; i < computer.num_devices; i++)
3580
if ((XF86ConfInputPtr)(computer.devices[i]->config) ==
3581
node->data->input.input) {
3582
config = computer.devices[i]->widget;
3583
RemoveDeviceCallback(NULL, NULL, NULL);
3589
InputUpdate(TreeNode *node)
3594
XtVaGetValues(node->data->input.text, XtNstring, &str, NULL);
3595
XtFree(node->data->input.input->inp_driver);
3597
node->data->input.input->inp_driver = XtNewString(str);
3599
node->data->input.input->inp_driver = NULL;
3604
CreateLayout(TreeNode *parent, XF86ConfLayoutPtr lay)
3606
TreeNode *prev, *node;
3609
if ((prev = parent->child) != NULL)
3614
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3615
data->layout.layout = lay;
3616
node = NewNode(parent, NULL, NULL, parent->node, data);
3617
node->destroy = LayoutDestroy;
3618
CreateLayoutField(node, False);
3619
if (parent->child == NULL)
3620
parent->child = node;
3624
lay = (XF86ConfLayoutPtr)(lay->list.next);
3627
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3628
node = NewNode(parent, NULL, NULL, parent->node, data);
3629
CreateLayoutField(node, True);
3630
if (parent->child == NULL)
3631
parent->child = node;
3637
CreateLayoutField(TreeNode *node, Bool addnew)
3639
Widget box, command, label;
3641
box = XtVaCreateWidget("layout", formWidgetClass, tree,
3642
XtNtreeParent, node->treeParent, NULL);
3646
TreeNode *adjacency, *inputref;
3647
XF86OptionPtr *options;
3648
XF86ConfLayoutPtr lay = node->data->layout.layout;
3650
options = &(lay->lay_option_lst);
3651
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
3653
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
3654
command = XtCreateManagedWidget("options", commandWidgetClass, box,
3656
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
3657
label = XtVaCreateManagedWidget("label", labelWidgetClass, box,
3658
XtNlabel, lay->lay_identifier, NULL);
3660
command = XtVaCreateManagedWidget("Adjacency", toggleWidgetClass, tree,
3661
XtNstate, True, XtNtreeParent, box,
3663
adjacency = NewNode(node, command, command, box, NULL);
3664
node->child = adjacency;
3665
CreateAdjacency(adjacency, lay->lay_adjacency_lst);
3667
command = XtVaCreateManagedWidget("Inputref", toggleWidgetClass, tree,
3668
XtNstate, True, XtNtreeParent, box,
3670
inputref = NewNode(node, command, command, box, NULL);
3671
adjacency->next = inputref;
3672
CreateInputref(inputref, lay->lay_input_lst);
3675
command = XtCreateManagedWidget("new", commandWidgetClass, box,
3677
XtAddCallback(command, XtNcallback, NewLayoutCallback, (XtPointer)node);
3678
label = XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
3679
XtNeditType, XawtextEdit,
3681
node->data->layout.text = label;
3683
if (XtIsRealized(node->treeParent))
3684
XtRealizeWidget(box);
3690
LayoutDestroy(TreeNode *node)
3692
if (node->data->layout.layout)
3693
xf86removeLayout(XF86Config, node->data->layout.layout);
3698
NewLayoutCallback(Widget unused, XtPointer user_data, XtPointer call_data)
3700
TreeNode *parent, *node = (TreeNode*)user_data;
3701
XF86ConfLayoutPtr lay;
3705
XtSetArg(args[0], XtNstring, &label);
3706
XtGetValues(node->data->layout.text, args, 1);
3710
parent = node->parent;
3712
lay = (XF86ConfLayoutPtr)XtCalloc(1, sizeof(XF86ConfLayoutRec));
3713
lay->lay_identifier = XtNewString(label);
3714
XF86Config->conf_layout_lst = xf86addLayout(XF86Config->conf_layout_lst, lay);
3716
CreateLayout(parent, lay);
3721
CreateAdjacency(TreeNode *parent, XF86ConfAdjacencyPtr adj)
3723
TreeNode *prev, *node;
3726
if ((prev = parent->child) != NULL)
3731
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3732
data->adjacency.screen = adj ? adj->adj_screen : NULL;
3733
data->adjacency.adjacency = adj;
3734
node = NewNode(parent, NULL, NULL, parent->node, data);
3735
node->destroy = AdjacencyDestroy;
3736
CreateAdjacencyField(node, False);
3737
if (parent->child == NULL)
3738
parent->child = node;
3742
adj = (XF86ConfAdjacencyPtr)(adj->list.next);
3745
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3746
node = NewNode(parent, NULL, NULL, parent->node, data);
3747
CreateAdjacencyField(node, True);
3748
if (parent->child == NULL)
3749
parent->child = node;
3755
CreateAdjacencyField(TreeNode *node, Bool addnew)
3757
Widget box, command, sme;
3758
XF86ConfScreenPtr ptr = XF86Config->conf_screen_lst;
3760
box = XtVaCreateWidget("adjacency", formWidgetClass, tree,
3761
XtNtreeParent, node->treeParent, NULL);
3764
node->data->adjacency.menu =
3765
XtVaCreatePopupShell("screenMenu", simpleMenuWidgetClass, box,
3766
XtNleftMargin, 1, XtNrightMargin, 1,
3767
XtNtopMargin, 1, XtNbottomMargin, 1,
3770
sme = XtCreateManagedWidget(ptr->scrn_identifier, smeBSBObjectClass,
3771
node->data->adjacency.menu, NULL, 0);
3772
XtAddCallback(sme, XtNcallback, !addnew ?
3773
AdjacencyMenuCallback : NewAdjacencyCallback,
3775
ptr = (XF86ConfScreenPtr)(ptr->list.next);
3780
Cardinal width, height;
3781
Widget left, right, above, below, relative, absolute;
3782
XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency;
3784
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
3786
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
3787
(void) XtVaCreateManagedWidget("label", labelWidgetClass, box,
3788
XtNlabel, adj->adj_screen->scrn_identifier,
3791
XtCreateManagedWidget("scrnumL", labelWidgetClass, box, NULL, 0);
3792
if (adj->adj_scrnum >= 0)
3793
XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_scrnum);
3796
node->data->adjacency.scrnum =
3797
XtVaCreateManagedWidget("scrnum", asciiTextWidgetClass, box,
3798
XtNeditType, XawtextEdit,
3799
XtNstring, buf, NULL);
3800
above = XtVaCreateManagedWidget("above", toggleWidgetClass, box,
3801
XtNstate, adj->adj_where == CONF_ADJ_ABOVE ?
3802
True : False, NULL);
3803
XtAddCallback(above, XtNcallback, AdjacencyToggleCallback, (XtPointer)node);
3804
left = XtVaCreateManagedWidget("leftOf", toggleWidgetClass, box,
3805
XtNradioGroup, above,
3806
XtNstate, adj->adj_where == CONF_ADJ_LEFTOF ?
3807
True : False, NULL);
3808
XtAddCallback(left, XtNcallback, AdjacencyToggleCallback, (XtPointer)node);
3810
node->data->adjacency.button =
3811
XtVaCreateManagedWidget("screen", menuButtonWidgetClass, box,
3812
XtNmenuName, "screenMenu", NULL);
3814
right = XtVaCreateManagedWidget("rightOf", toggleWidgetClass, box,
3815
XtNradioGroup, left,
3816
XtNstate, adj->adj_where == CONF_ADJ_RIGHTOF ?
3817
True : False, NULL);
3818
XtAddCallback(right, XtNcallback, AdjacencyToggleCallback, (XtPointer)node);
3819
below = XtVaCreateManagedWidget("below", toggleWidgetClass, box,
3820
XtNradioGroup, right,
3821
XtNstate, adj->adj_where == CONF_ADJ_BELOW ?
3822
True : False, NULL);
3823
XtAddCallback(below, XtNcallback, AdjacencyToggleCallback, (XtPointer)node);
3824
relative = XtVaCreateManagedWidget("relative", toggleWidgetClass, box,
3825
XtNradioGroup, below,
3826
XtNstate, adj->adj_where == CONF_ADJ_RELATIVE ?
3827
True : False, NULL);
3828
XtAddCallback(relative, XtNcallback, AdjacencyToggleCallback, (XtPointer)node);
3829
absolute = XtVaCreateManagedWidget("absolute", toggleWidgetClass, box,
3830
XtNradioGroup, relative,
3831
XtNstate, adj->adj_where == CONF_ADJ_ABSOLUTE ?
3832
True : False, NULL);
3833
XtAddCallback(absolute, XtNcallback, AdjacencyToggleCallback, (XtPointer)node);
3835
XtCreateManagedWidget("adjxL", labelWidgetClass, box, NULL, 0);
3836
XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_x);
3837
node->data->adjacency.adjx =
3838
XtVaCreateManagedWidget("adjx", asciiTextWidgetClass, box,
3839
XtNeditType, XawtextEdit,
3840
XtNstring, buf, NULL);
3842
XtCreateManagedWidget("adjyL", labelWidgetClass, box, NULL, 0);
3843
XmuSnprintf(buf, sizeof(buf), "%d", adj->adj_y);
3844
node->data->adjacency.adjy =
3845
XtVaCreateManagedWidget("adjy", asciiTextWidgetClass, box,
3846
XtNeditType, XawtextEdit,
3847
XtNstring, buf, NULL);
3849
XtVaGetValues(node->data->adjacency.button, XtNwidth, &width,
3850
XtNheight, &height, NULL);
3851
if (adj->adj_where > CONF_ADJ_ABSOLUTE &&
3852
adj->adj_where <= CONF_ADJ_RELATIVE)
3853
XtVaSetValues(node->data->adjacency.button, XtNlabel,
3854
adj->adj_refscreen, XtNwidth, width,
3855
XtNheight, height, NULL);
3857
XtVaSetValues(node->data->adjacency.button, XtNlabel, "",
3858
XtNwidth, width, XtNheight, height, NULL);
3861
XtVaCreateManagedWidget("new", menuButtonWidgetClass, box,
3862
XtNmenuName, "screenMenu", NULL);
3864
if (XtIsRealized(node->treeParent))
3865
XtRealizeWidget(box);
3870
AdjacencyDestroy(TreeNode *node)
3872
if (node->data->adjacency.adjacency)
3873
xf86removeAdjacency(node->parent->parent->data->layout.layout,
3874
node->data->adjacency.adjacency);
3879
NewAdjacencyCallback(Widget w, XtPointer user_data, XtPointer call_data)
3881
TreeNode *parent, *node = (TreeNode*)user_data;
3882
XF86ConfAdjacencyPtr adj;
3883
char *ident = XtName(w);
3885
parent = node->parent;
3887
adj = (XF86ConfAdjacencyPtr)XtCalloc(1, sizeof(XF86ConfAdjacencyRec));
3888
adj->adj_screen = xf86findScreen(ident, XF86Config->conf_screen_lst);
3889
if (adj->adj_screen)
3890
adj->adj_screen_str = XtNewString(adj->adj_screen->scrn_identifier);
3891
parent->parent->data->layout.layout->lay_adjacency_lst =
3892
xf86addAdjacency(parent->parent->data->layout.layout->lay_adjacency_lst,
3895
CreateAdjacency(parent, adj);
3901
AdjacencyMenuCallback(Widget w, XtPointer user_data, XtPointer call_data)
3903
TreeNode *node = (TreeNode*)user_data;
3904
XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency;
3906
XtFree(adj->adj_refscreen);
3907
adj->adj_refscreen = XtNewString(XtName(w));
3908
XtVaSetValues(node->data->adjacency.button, XtNlabel, XtName(w), NULL);
3912
AdjacencyToggleCallback(Widget w, XtPointer user_data, XtPointer call_data)
3914
TreeNode *node = (TreeNode*)user_data;
3915
XF86ConfAdjacencyPtr adj = node->data->adjacency.adjacency;
3918
if ((Bool)(long)call_data == False)
3921
XtVaGetValues(node->data->adjacency.adjx, XtNstring, &x, NULL);
3922
XtVaGetValues(node->data->adjacency.adjy, XtNstring, &y, NULL);
3924
adj->adj_x = strtol(x, NULL, 0);
3925
adj->adj_y = strtol(y, NULL, 0);
3927
if (strcmp(XtName(w), "absolute") == 0) {
3928
XtVaSetValues(node->data->adjacency.button, XtNlabel, "", NULL);
3929
adj->adj_where = CONF_ADJ_ABSOLUTE;
3932
if (strcmp(XtName(w), "relative") == 0)
3933
adj->adj_where = CONF_ADJ_RELATIVE;
3934
else if (strcmp(XtName(w), "leftOf") == 0)
3935
adj->adj_where = CONF_ADJ_LEFTOF;
3936
else if (strcmp(XtName(w), "rightOf") == 0)
3937
adj->adj_where = CONF_ADJ_RIGHTOF;
3938
else if (strcmp(XtName(w), "above") == 0)
3939
adj->adj_where = CONF_ADJ_ABOVE;
3940
else if (strcmp(XtName(w), "below") == 0)
3941
adj->adj_where = CONF_ADJ_BELOW;
3946
CreateInputref(TreeNode *parent, XF86ConfInputrefPtr input)
3948
TreeNode *prev, *node;
3951
if ((prev = parent->child) != NULL)
3956
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3957
data->inputref.inputref = input;
3958
node = NewNode(parent, NULL, NULL, parent->node, data);
3959
node->destroy = InputrefDestroy;
3960
CreateInputrefField(node, False);
3961
if (parent->child == NULL)
3962
parent->child = node;
3966
input = (XF86ConfInputrefPtr)(input->list.next);
3969
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
3970
node = NewNode(parent, NULL, NULL, parent->node, data);
3971
CreateInputrefField(node, True);
3972
if (parent->child == NULL)
3973
parent->child = node;
3979
CreateInputrefField(TreeNode *node, Bool addnew)
3981
Widget box, command;
3983
box = XtVaCreateWidget("inputref", formWidgetClass, tree,
3984
XtNtreeParent, node->treeParent, NULL);
3988
XF86OptionPtr *options;
3989
XF86ConfInputrefPtr inp = node->data->inputref.inputref;
3991
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
3993
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
3994
options = &(inp->iref_option_lst);
3995
command = XtCreateManagedWidget("options", commandWidgetClass, box,
3997
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
3998
XtVaCreateManagedWidget("label", labelWidgetClass, box,
3999
XtNlabel, inp->iref_inputdev_str, NULL);
4003
XF86ConfInputPtr ptr = XF86Config->conf_input_lst;
4005
XtVaCreateManagedWidget("new", menuButtonWidgetClass, box,
4006
XtNmenuName, "inputMenu", NULL);
4007
node->data->inputref.menu =
4008
XtVaCreatePopupShell("inputMenu", simpleMenuWidgetClass, box,
4009
XtNleftMargin, 1, XtNrightMargin, 1,
4010
XtNtopMargin, 1, XtNbottomMargin, 1,
4014
sme = XtCreateManagedWidget(ptr->inp_identifier, smeBSBObjectClass,
4015
node->data->inputref.menu, NULL, 0);
4016
XtAddCallback(sme, XtNcallback, NewInputrefCallback,
4018
ptr = (XF86ConfInputPtr)(ptr->list.next);
4021
if (XtIsRealized(node->treeParent))
4022
XtRealizeWidget(box);
4028
NewInputrefCallback(Widget w, XtPointer user_data, XtPointer call_data)
4030
TreeNode *parent, *node = (TreeNode*)user_data;
4031
XF86ConfInputrefPtr input;
4032
char *ident = XtName(w);
4034
parent = node->parent;
4036
input = (XF86ConfInputrefPtr)XtCalloc(1, sizeof(XF86ConfInputrefRec));
4037
input->iref_inputdev_str = XtNewString(ident);
4038
parent->parent->data->layout.layout->lay_input_lst =
4039
xf86addInputref(parent->parent->data->layout.layout->lay_input_lst, input);
4041
CreateInputref(parent, input);
4047
InputrefDestroy(TreeNode *node)
4049
if (node->data->inputref.inputref)
4050
xf86removeInputRef(node->parent->parent->data->layout.layout, node->data->inputref.inputref->iref_inputdev);
4055
CreateVendor(TreeNode *parent, XF86ConfVendorPtr vendor)
4057
TreeNode *prev, *node;
4060
if ((prev = parent->child) != NULL)
4065
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
4066
data->vendor.vendor = vendor;
4067
node = NewNode(parent, NULL, NULL, parent->node, data);
4068
node->destroy = VendorDestroy;
4069
CreateVendorField(node, False);
4070
if (parent->child == NULL)
4071
parent->child = node;
4075
vendor = (XF86ConfVendorPtr)(vendor->list.next);
4078
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
4079
node = NewNode(parent, NULL, NULL, parent->node, data);
4080
CreateVendorField(node, True);
4081
if (parent->child == NULL)
4082
parent->child = node;
4088
CreateVendorField(TreeNode *node, Bool addnew)
4090
Widget box, command;
4092
box = XtVaCreateWidget("vendor", formWidgetClass, tree,
4093
XtNtreeParent, node->treeParent, NULL);
4098
XF86OptionPtr *options;
4099
XF86ConfVendorPtr vendor = node->data->vendor.vendor;
4101
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
4103
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
4104
options = &(vendor->vnd_option_lst);
4105
command = XtCreateManagedWidget("options", commandWidgetClass, box,
4107
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
4108
XtVaCreateManagedWidget("label", labelWidgetClass, box,
4109
XtNlabel, vendor->vnd_identifier, NULL);
4111
command = XtVaCreateManagedWidget("VendSub", toggleWidgetClass, tree,
4115
sub = NewNode(node, command, command, box, NULL);
4117
CreateVendorSub(sub, vendor->vnd_sub_lst);
4120
command = XtCreateManagedWidget("new", commandWidgetClass, box,
4122
XtAddCallback(command, XtNcallback, NewVendorCallback, (XtPointer)node);
4123
node->data->vendor.text =
4124
XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
4125
XtNeditType, XawtextEdit, NULL);
4127
if (XtIsRealized(node->treeParent))
4128
XtRealizeWidget(box);
4133
VendorDestroy(TreeNode *node)
4135
if (node->data->vendor.vendor)
4136
xf86removeVendor(XF86Config, node->data->vendor.vendor);
4140
NewVendorCallback(Widget w, XtPointer user_data, XtPointer call_data)
4142
TreeNode *parent, *node = (TreeNode*)user_data;
4143
XF86ConfVendorPtr vnd;
4147
XtSetArg(args[0], XtNstring, &label);
4148
XtGetValues(node->data->vendor.text, args, 1);
4152
parent = node->parent;
4154
vnd = (XF86ConfVendorPtr)XtCalloc(1, sizeof(XF86ConfVendorRec));
4155
vnd->vnd_identifier = XtNewString(label);
4156
XF86Config->conf_vendor_lst = xf86addVendor(XF86Config->conf_vendor_lst, vnd);
4158
CreateVendor(parent, vnd);
4164
CreateVendorSub(TreeNode *parent, XF86ConfVendSubPtr vendor)
4166
TreeNode *prev, *node;
4169
if ((prev = parent->child) != NULL)
4174
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
4175
data->vendsub.vendsub = vendor;
4176
node = NewNode(parent, NULL, NULL, parent->node, data);
4177
node->destroy = VendorSubDestroy;
4178
node->update = VendorSubUpdate;
4179
CreateVendorSubField(node, False);
4180
if (parent->child == NULL)
4181
parent->child = node;
4185
vendor = (XF86ConfVendSubPtr)(vendor->list.next);
4188
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
4189
node = NewNode(parent, NULL, NULL, parent->node, data);
4190
CreateVendorSubField(node, True);
4191
if (parent->child == NULL)
4192
parent->child = node;
4198
CreateVendorSubField(TreeNode *node, Bool addnew)
4200
Widget box, command;
4202
box = XtVaCreateWidget("vendorSub", formWidgetClass, tree,
4203
XtNtreeParent, node->treeParent, NULL);
4207
XF86OptionPtr *options;
4208
XF86ConfVendSubPtr vendor = node->data->vendsub.vendsub;
4210
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
4212
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
4213
options = &(vendor->vs_option_lst);
4214
command = XtCreateManagedWidget("options", commandWidgetClass, box,
4216
XtAddCallback(command, XtNcallback, OptionsCallback, (XtPointer)options);
4217
XtVaCreateManagedWidget("label", labelWidgetClass, box,
4218
XtNlabel, vendor->vs_identifier, NULL);
4220
XtCreateManagedWidget("nameL", labelWidgetClass, box, NULL, 0);
4221
node->data->vendsub.text =
4222
XtVaCreateManagedWidget("name", asciiTextWidgetClass, box,
4223
XtNeditType, XawtextEdit, XtNstring,
4224
vendor->vs_name ? vendor->vs_name : "",
4228
command = XtCreateManagedWidget("new", commandWidgetClass, box,
4230
XtAddCallback(command, XtNcallback, NewVendorSubCallback, (XtPointer)node);
4231
node->data->vendsub.text =
4232
XtVaCreateManagedWidget("value", asciiTextWidgetClass, box,
4233
XtNeditType, XawtextEdit, NULL);
4235
if (XtIsRealized(node->treeParent))
4236
XtRealizeWidget(box);
4241
VendorSubDestroy(TreeNode *node)
4243
if (node->data->vendsub.vendsub)
4244
xf86removeVendorSub(node->parent->parent->data->vendor.vendor,
4245
node->data->vendsub.vendsub);
4249
VendorSubUpdate(TreeNode *node)
4253
XtVaGetValues(node->data->vendsub.text, XtNstring, &str, NULL);
4254
XtFree(node->data->vendsub.vendsub->vs_name);
4256
node->data->vendsub.vendsub->vs_name = XtNewString(str);
4258
node->data->vendsub.vendsub->vs_name = NULL;
4262
NewVendorSubCallback(Widget w, XtPointer user_data, XtPointer call_data)
4264
TreeNode *parent, *node = (TreeNode*)user_data;
4265
XF86ConfVendSubPtr vnd;
4269
XtSetArg(args[0], XtNstring, &label);
4270
XtGetValues(node->data->vendsub.text, args, 1);
4274
parent = node->parent;
4276
vnd = (XF86ConfVendSubPtr)XtCalloc(1, sizeof(XF86ConfVendSubRec));
4277
vnd->vs_identifier = XtNewString(label);
4278
parent->parent->data->vendor.vendor->vnd_sub_lst =
4279
xf86addVendorSub(parent->parent->data->vendor.vendor->vnd_sub_lst, vnd);
4281
CreateVendorSub(parent, vnd);
4287
CreateDRI(TreeNode *parent, XF86ConfDRIPtr dri)
4292
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
4293
data->dri.dri = dri;
4294
node = NewNode(parent, NULL, NULL, parent->node, data);
4295
parent->child = node;
4296
node->update = DRIUpdate;
4297
CreateDRIField(node);
4301
CreateDRIField(TreeNode *node)
4304
XF86ConfDRIPtr dri = node->data->dri.dri;
4308
box = XtVaCreateWidget("dri", formWidgetClass, tree,
4309
XtNtreeParent, node->treeParent, NULL);
4311
XtCreateManagedWidget("nameL", labelWidgetClass, box, NULL, 0);
4312
node->data->dri.name =
4313
XtVaCreateManagedWidget("name", asciiTextWidgetClass, box,
4314
XtNeditType, XawtextEdit, XtNstring,
4315
dri->dri_group_name ? dri->dri_group_name : "",
4318
XtCreateManagedWidget("groupL", labelWidgetClass, box, NULL, 0);
4319
if (dri->dri_group >= 0)
4320
XmuSnprintf(buf, sizeof(buf), "%d", dri->dri_group);
4323
node->data->dri.group =
4324
XtVaCreateManagedWidget("group", asciiTextWidgetClass, box,
4325
XtNeditType, XawtextEdit, XtNstring, buf,
4328
XtCreateManagedWidget("modeL", labelWidgetClass, box, NULL, 0);
4329
if (dri->dri_mode > 0)
4330
XmuSnprintf(buf, sizeof(buf), "0%o", dri->dri_mode);
4333
node->data->dri.mode =
4334
XtVaCreateManagedWidget("mode", asciiTextWidgetClass, box,
4335
XtNeditType, XawtextEdit, XtNstring, buf,
4338
toggle = XtVaCreateManagedWidget("Buffers", toggleWidgetClass, tree,
4339
XtNstate, True, XtNtreeParent, box,
4341
buffers = NewNode(node, toggle, toggle, box, NULL);
4342
node->child = buffers;
4343
CreateBuffers(buffers, dri->dri_buffers_lst);
4345
if (XtIsRealized(node->treeParent))
4346
XtRealizeWidget(box);
4351
DRIUpdate(TreeNode *node)
4356
XtVaGetValues(node->data->dri.name, XtNstring, &str, NULL);
4357
XtFree(node->data->dri.dri->dri_group_name);
4359
node->data->dri.dri->dri_group_name = XtNewString(str);
4361
node->data->dri.dri->dri_group_name = NULL;
4364
XtVaGetValues(node->data->dri.group, XtNstring, &str, NULL);
4366
node->data->dri.dri->dri_group = strtoul(str, NULL, 0);
4368
node->data->dri.dri->dri_group = -1;
4371
XtVaGetValues(node->data->dri.mode, XtNstring, &str, NULL);
4372
node->data->dri.dri->dri_mode = strtoul(str, NULL, 0);
4377
CreateBuffers(TreeNode *parent, XF86ConfBuffersPtr buf)
4379
TreeNode *node, *prev;
4382
if ((prev = parent->child) != NULL)
4387
data = (TreeData*)XtCalloc(1, sizeof(TreeData));
4388
data->buffers.buffers = buf;
4389
node = NewNode(parent, NULL, NULL, parent->node, data);
4390
node->destroy = BuffersDestroy;
4391
node->update = BuffersUpdate;
4392
CreateBuffersField(node, False);
4393
if (parent->child == NULL)
4394
parent->child = node;
4399
buf = (XF86ConfBuffersPtr)(buf->list.next);
4401
node = NewNode(parent, NULL, NULL, parent->node, NULL);
4402
CreateBuffersField(node, True);
4403
if (parent->child == NULL)
4404
parent->child = node;
4410
CreateBuffersField(TreeNode *node, Bool addnew)
4412
Widget box, command;
4414
box = XtVaCreateWidget("buffers", formWidgetClass, tree,
4415
XtNtreeParent, node->treeParent, NULL);
4420
XF86ConfBuffersPtr buf = node->data->buffers.buffers;
4422
command = XtCreateManagedWidget("remove", commandWidgetClass, box,
4424
XtAddCallback(command, XtNcallback, DestroyCallback, (XtPointer)node);
4426
XtCreateManagedWidget("countL", labelWidgetClass, box, NULL, 0);
4427
XmuSnprintf(str, sizeof(str), "%d", buf->buf_count);
4428
node->data->buffers.count =
4429
XtVaCreateManagedWidget("count", asciiTextWidgetClass, box,
4430
XtNeditType, XawtextEdit, XtNstring, str,
4433
XtCreateManagedWidget("sizeL", labelWidgetClass, box, NULL, 0);
4434
XmuSnprintf(str, sizeof(str), "%d", buf->buf_size);
4435
node->data->buffers.size =
4436
XtVaCreateManagedWidget("size", asciiTextWidgetClass, box,
4437
XtNeditType, XawtextEdit, XtNstring, str,
4440
XtCreateManagedWidget("flagsL", labelWidgetClass, box, NULL, 0);
4441
node->data->buffers.flags =
4442
XtVaCreateManagedWidget("flags", asciiTextWidgetClass, box,
4443
XtNeditType, XawtextEdit, XtNstring,
4444
buf->buf_flags ? buf->buf_flags : "",
4448
command = XtCreateManagedWidget("new", commandWidgetClass, box,
4450
XtAddCallback(command, XtNcallback, NewBuffersCallback, (XtPointer)node);
4452
if (XtIsRealized(node->treeParent))
4453
XtRealizeWidget(box);
4459
BuffersDestroy(TreeNode *node)
4461
if (node->data->buffers.buffers)
4462
xf86removeBuffers(XF86Config->conf_dri, node->data->buffers.buffers);
4467
NewBuffersCallback(Widget unused, XtPointer user_data, XtPointer call_data)
4469
TreeNode *parent, *node = (TreeNode*)user_data;
4470
XF86ConfBuffersPtr buf;
4472
parent = node->parent;
4474
buf = (XF86ConfBuffersPtr)XtCalloc(1, sizeof(XF86ConfBuffersRec));
4475
XF86Config->conf_dri->dri_buffers_lst =
4476
xf86addBuffers(XF86Config->conf_dri->dri_buffers_lst, buf);
4478
CreateBuffers(parent, buf);
4483
BuffersUpdate(TreeNode *node)
4488
XtVaGetValues(node->data->buffers.count, XtNstring, &str, NULL);
4489
node->data->buffers.buffers->buf_count = strtoul(str, NULL, 0);
4492
XtVaGetValues(node->data->buffers.size, XtNstring, &str, NULL);
4493
node->data->buffers.buffers->buf_size = strtoul(str, NULL, 0);
4496
XtVaGetValues(node->data->buffers.flags, XtNstring, &str, NULL);
4498
node->data->buffers.buffers->buf_flags = XtNewString(str);
4500
node->data->buffers.buffers->buf_flags = NULL;
4504
NewNode(TreeNode *parent, Widget node, Widget toggle, Widget treeParent,
4507
TreeNode *tree = (TreeNode*)XtCalloc(1, sizeof(TreeNode));
4509
tree->parent = parent;
4511
if ((tree->toggle = toggle) != NULL)
4512
XtAddCallback(toggle, XtNcallback, ToggleCallback, (XtPointer)tree);
4513
tree->treeParent = treeParent;
4520
DeleteNode(TreeNode *node)
4522
TreeNode *ptr = node->child;
4524
while (ptr != NULL) {
4525
TreeNode *next = ptr->next;
4531
if (node->parent && node->parent->child == node)
4532
node->parent->child = node->next;
4533
else if (node->parent) {
4534
for (ptr = node->parent->child; ptr && ptr->next != node;
4538
ptr->next = node->next;
4542
(node->destroy)(node);
4544
XtFree((XtPointer)node->data);
4546
/* sets treeParent to NULL so that RelayoutTree works correctly,
4547
* as the tree will properly calculate it's new size.
4549
XtVaSetValues(node->node, XtNtreeParent, NULL, NULL);
4551
XtDestroyWidget(node->node);
4552
XtFree((XtPointer)node);
4557
DestroyCallback(Widget w, XtPointer user_data, XtPointer call_data)
4559
TreeNode *node = (TreeNode*)user_data;
4566
ToggleNodeRecursive(TreeNode *node)
4569
if (!XtIsRealized(node->node))
4570
XtRealizeWidget(node->node);
4571
XtVaSetValues(node->node, XtNtreeParent, node->treeParent, NULL);
4572
XtManageChild(node->node);
4574
if (node->child && !node->toggle)
4575
ToggleNodeRecursive(node->child);
4582
ToggleNode(TreeNode *node, Bool toggle)
4586
if (!XtIsRealized(node->node))
4587
XtRealizeWidget(node->node);
4588
XtVaSetValues(node->node, XtNtreeParent, node->treeParent, NULL);
4589
XtManageChild(node->node);
4591
if (node->child && !node->toggle)
4592
ToggleNodeRecursive(node->child);
4596
ToggleNode(node->child, False);
4597
XtVaSetValues(node->node, XtNtreeParent, NULL, NULL);
4598
XtUnmanageChild(node->node);
4600
XtVaSetValues(node->toggle, XtNstate, False, NULL);
4607
* XXX This callback can show side effects in the way it is called. If
4608
* the structure holding the XF86OptionPtr is reallocated, a bogus pointer
4609
* will be passed to this callback.
4612
OptionsCallback(Widget w, XtPointer user_data, XtPointer call_data)
4614
XF86OptionPtr *options = (XF86OptionPtr*)user_data;
4617
OptionsPopup(options, NULL, NULL);
4619
OptionsPopup(options);
4627
Dimension sliderWidth, sliderHeight, canvasWidth, canvasHeight;
4629
XtSetArg(args[0], XtNwidth, &sliderWidth);
4630
XtSetArg(args[1], XtNheight, &sliderHeight);
4631
XtGetValues(shell, args, 2);
4633
XtSetArg(args[2], XtNwidth, &canvasWidth);
4634
XtSetArg(args[3], XtNheight, &canvasHeight);
4635
XtGetValues(tree, args + 2, 2);
4637
XtSetArg(args[0], XtNsliderWidth, sliderWidth);
4638
XtSetArg(args[1], XtNsliderHeight, sliderHeight);
4639
XtSetArg(args[2], XtNcanvasWidth, canvasWidth);
4640
XtSetArg(args[3], XtNcanvasHeight, canvasHeight);
4641
XtSetValues(panner, args, 4);
4645
ToggleCallback(Widget w, XtPointer user_data, XtPointer call_data)
4647
TreeNode *nodeParent = (TreeNode*)user_data;
4649
if (nodeParent->child) {
4650
if (XtIsRealized(tree))
4651
XtUnmapWidget(tree);
4652
ToggleNode(nodeParent->child, (Bool)(long)call_data);
4654
if (XtIsRealized(tree))
4661
PannerCallback(Widget w, XtPointer user_data, XtPointer call_data)
4664
XawPannerReport *rep = (XawPannerReport *)call_data;
4666
XtSetArg (args[0], XtNx, -rep->slider_x);
4667
XtSetArg (args[1], XtNy, -rep->slider_y);
4668
XtSetValues(tree, args, 2);
4673
PortholeCallback(Widget w, XtPointer user_data, XtPointer call_data)
4675
XawPannerReport *rep = (XawPannerReport*)call_data;
4679
XtSetArg (args[0], XtNsliderX, rep->slider_x);
4680
XtSetArg (args[1], XtNsliderY, rep->slider_y);
4681
if (rep->changed != (XawPRSliderX | XawPRSliderY)) {
4682
XtSetArg (args[2], XtNsliderWidth, rep->slider_width);
4683
XtSetArg (args[3], XtNsliderHeight, rep->slider_height);
4684
XtSetArg (args[4], XtNcanvasWidth, rep->canvas_width);
4685
XtSetArg (args[5], XtNcanvasHeight, rep->canvas_height);
4688
XtSetValues(panner, args, n);
4692
DestroyTree(TreeNode *node)
4695
TreeNode *next = node->next;
4697
DestroyTree(node->child);
4700
XtFree((XtPointer)node->data);
4701
XtFree((XtPointer)node);
4708
UpdateConfig(TreeNode *node)
4712
UpdateConfig(node->child);
4714
(node->update)(node);
4720
ExpertInitialize(void)
4722
Widget paned, vpane, close, config, files, modules, flags, video, modes,
4723
monitor, device, screen, input, layout, vendor, dri;
4725
Dimension width, height, canvasWidth, canvasHeight;
4731
shell = XtCreatePopupShell("Expert", transientShellWidgetClass,
4733
paned = XtVaCreateManagedWidget("paned", panedWidgetClass, shell,
4734
XtNorientation, XtorientHorizontal, NULL);
4735
vpane = XtCreateManagedWidget("vpane", panedWidgetClass, paned, NULL, 0);
4736
panner = XtCreateManagedWidget ("panner", pannerWidgetClass, vpane, NULL, 0);
4737
close = XtCreateManagedWidget("close", commandWidgetClass, vpane, NULL, 0);
4738
XtAddCallback(close, XtNcallback, PopdownCallback, NULL);
4740
expert = XtCreateManagedWidget("expert", portholeWidgetClass, paned, NULL, 0);
4741
XtAddCallback(expert, XtNreportCallback, PortholeCallback, NULL);
4742
XtAddCallback(panner, XtNreportCallback, PannerCallback, NULL);
4743
tree = XtCreateManagedWidget("tree", treeWidgetClass, expert, NULL, 0);
4745
config = XtVaCreateManagedWidget(__XCONFIGFILE__, toggleWidgetClass, tree,
4746
XtNstate, True, NULL);
4747
mainNode = NewNode(NULL, config, config, NULL, NULL);
4749
files = XtVaCreateManagedWidget("Files", toggleWidgetClass, tree,
4750
XtNtreeParent, config, NULL);
4751
node = NewNode(mainNode, files, files, config, NULL);
4752
mainNode->child = node;
4755
modules = XtVaCreateManagedWidget("Module", toggleWidgetClass, tree,
4756
XtNtreeParent, config, NULL);
4757
node->next = NewNode(mainNode, modules, modules, config, NULL);
4759
CreateModule(node, XF86Config->conf_modules ?
4760
XF86Config->conf_modules->mod_load_lst : NULL);
4762
flags = XtVaCreateManagedWidget("ServerFlags", commandWidgetClass, tree,
4763
XtNtreeParent, config, NULL);
4764
node->next = NewNode(mainNode, flags, NULL, config, NULL);
4766
if (XF86Config->conf_flags == NULL)
4767
XF86Config->conf_flags = (XF86ConfFlagsPtr)
4768
XtCalloc(1, sizeof(XF86ConfFlagsRec));
4769
XtAddCallback(flags, XtNcallback, OptionsCallback,
4770
(XtPointer)&(XF86Config->conf_flags->flg_option_lst));
4772
video = XtVaCreateManagedWidget("VideoAdaptor", toggleWidgetClass, tree,
4773
XtNtreeParent, config, NULL);
4774
node->next = NewNode(mainNode, video, video, config, NULL);
4776
CreateVideoAdaptor(node, XF86Config->conf_videoadaptor_lst);
4778
modes = XtVaCreateManagedWidget("Mode", toggleWidgetClass, tree,
4779
XtNtreeParent, config, NULL);
4780
node->next = NewNode(mainNode, modes, modes, config, NULL);
4782
CreateModes(node, XF86Config->conf_modes_lst);
4784
monitor = XtVaCreateManagedWidget("Monitor", toggleWidgetClass, tree,
4785
XtNtreeParent, config, NULL);
4786
node->next = NewNode(mainNode, monitor, monitor, config, NULL);
4788
CreateMonitor(monitorTree = node, XF86Config->conf_monitor_lst);
4790
device = XtVaCreateManagedWidget("Device", toggleWidgetClass, tree,
4791
XtNtreeParent, config, NULL);
4792
node->next = NewNode(mainNode, device, device, config, NULL);
4794
CreateDevice(node, XF86Config->conf_device_lst);
4796
screen = XtVaCreateManagedWidget("Screen", toggleWidgetClass, tree,
4797
XtNtreeParent, config, NULL);
4798
node->next = NewNode(mainNode, screen, screen, config, NULL);
4800
CreateScreen(screenTree = node, XF86Config->conf_screen_lst);
4802
input = XtVaCreateManagedWidget("Input", toggleWidgetClass, tree,
4803
XtNtreeParent, config, NULL);
4804
node->next = NewNode(mainNode, input, input, config, NULL);
4806
CreateInput(node, XF86Config->conf_input_lst);
4808
layout = XtVaCreateManagedWidget("Layout", toggleWidgetClass, tree,
4809
XtNtreeParent, config, NULL);
4810
node->next = NewNode(mainNode, layout, layout, config, NULL);
4812
CreateLayout(layoutTree = node, XF86Config->conf_layout_lst);
4814
vendor = XtVaCreateManagedWidget("Vendor", toggleWidgetClass, tree,
4815
XtNtreeParent, config, NULL);
4816
node->next = NewNode(mainNode, vendor, vendor, config, NULL);
4818
CreateVendor(node, XF86Config->conf_vendor_lst);
4820
dri = XtVaCreateManagedWidget("DRI", toggleWidgetClass, tree,
4821
XtNtreeParent, config, NULL);
4822
node->next = NewNode(mainNode, dri, dri, config, NULL);
4824
if (XF86Config->conf_dri == NULL)
4825
XF86Config->conf_dri = (XF86ConfDRIPtr)
4826
XtCalloc(1, sizeof(XF86ConfDRIRec));
4827
CreateDRI(node, XF86Config->conf_dri);
4829
XtRealizeWidget(shell);
4831
XtSetArg(args[0], XtNwidth, &width);
4832
XtSetArg(args[1], XtNheight, &height);
4833
XtGetValues(shell, args, 2);
4834
XtSetArg(args[0], XtNwidth, width);
4835
XtSetArg(args[1], XtNheight, height);
4836
XtSetValues(expert, args, 2);
4838
XtSetArg(args[0], XtNsliderWidth, width);
4839
XtSetArg(args[1], XtNsliderHeight, height);
4840
XtSetArg(args[2], XtNwidth, &canvasWidth);
4841
XtSetArg(args[3], XtNheight, &canvasHeight);
4842
XtGetValues(tree, args + 2, 2);
4843
XtSetArg(args[2], XtNcanvasWidth, canvasWidth);
4844
XtSetArg(args[3], XtNcanvasHeight, canvasHeight);
4845
XtSetValues(panner, args, 4);
4847
/* needs to do the apparently NOP code bellow to correctly layout the
4850
/* close all open entries */
4851
ToggleCallback(config, mainNode, (XtPointer)0);
4852
/* open first level */
4853
ToggleCallback(config, mainNode, (XtPointer)1);
4855
XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1);