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>
31 #include <X11/IntrinsicP.h>
32 #include <X11/StringDefs.h>
33 #include <X11/Composite.h>
34 #include <X11/Shell.h>
35 #include <X11/Xaw/AsciiText.h>
36 #include <X11/Xaw/Simple.h>
37 #include <X11/Xaw/Paned.h>
38 #include <X11/Xaw/Form.h>
39 #include <X11/Xaw/Command.h>
40 #include <X11/Xaw/MenuButton.h>
41 #include <X11/Xaw/SmeBSB.h>
42 #include <X11/Xaw/SmeLine.h>
43 #include <X11/Xaw/SimpleMenP.h>
44 #include <X11/Xaw/Dialog.h>
49 #include "xf86config.h"
50 #include "mouse-cfg.h"
51 #include "keyboard-cfg.h"
53 #include "monitor-cfg.h"
54 #include "screen-cfg.h"
62 #define randomize() srand((unsigned)time((time_t*)NULL))
64 #define DefaultXFree86Dir PROJECT_ROOT
66 #define DefaultXFree86Dir "/usr"
69 #define IS_KBDDRIV(S) ((strcasecmp((S),"kbd") == 0))
74 void DrawCables(void);
75 static void DrawCable(Display
*, Window
, int, int, int, int);
76 static void ComputerEventHandler(Widget
, XtPointer
, XEvent
*, Boolean
*);
77 void SelectDeviceAction(Widget
, XEvent
*, String
*, Cardinal
*);
78 void MoveDeviceAction(Widget
, XEvent
*, String
*, Cardinal
*);
79 void UnselectDeviceAction(Widget
, XEvent
*, String
*, Cardinal
*);
80 void RenameLayoutAction(Widget
, XEvent
*, String
*, Cardinal
*);
81 void DevicePopupMenu(Widget
, XEvent
*, String
*, Cardinal
*);
82 void DevicePopdownMenu(Widget
, XEvent
*, String
*, Cardinal
*);
83 void AddDeviceCallback(Widget
, XtPointer
, XtPointer
);
84 void QuitCallback(Widget
, XtPointer
, XtPointer
);
85 void SmeConfigureDeviceCallback(Widget
, XtPointer
, XtPointer
);
86 void ConfigureDeviceCallback(Widget
, XtPointer
, XtPointer
);
87 void EnableDeviceCallback(Widget
, XtPointer
, XtPointer
);
88 void DisableDeviceCallback(Widget
, XtPointer
, XtPointer
);
89 void RemoveDeviceCallback(Widget
, XtPointer
, XtPointer
);
90 void InitializeDevices(void);
91 void SetConfigModeCallback(Widget
, XtPointer
, XtPointer
);
92 void SelectLayoutCallback(Widget
, XtPointer
, XtPointer
);
93 void DefaultLayoutCallback(Widget
, XtPointer
, XtPointer
);
94 void RemoveLayoutCallback(Widget
, XtPointer
, XtPointer
);
95 void OptionsCallback(Widget
, XtPointer
, XtPointer
);
96 xf86cfgDevice
*AddDevice(int, XtPointer
, int, int);
97 static Bool
AskConfig(void);
98 void WriteConfigAction(Widget
, XEvent
*, String
*, Cardinal
*);
99 static void ScreenSetup(Bool
);
100 void QuitAction(Widget
, XEvent
*, String
*, Cardinal
*);
101 void PopdownErrorCallback(Widget
, XtPointer
, XtPointer
);
102 static void ErrorCancelAction(Widget
, XEvent
*, String
*, Cardinal
*);
103 static void QuitCancelAction(Widget
, XEvent
*, String
*, Cardinal
*);
104 static void HelpCallback(Widget
, XtPointer
, XtPointer
);
105 void UpdateMenuDeviceList(int);
107 extern void AccessXConfigureStart(void);
108 extern void AccessXConfigureEnd(void);
109 extern void CloseAccessXAction(Widget
, XEvent
*, String
*, Cardinal
*);
112 extern void TextMode(void);
115 static void Usage(void);
120 Widget toplevel
, work
, config
, layout
, layoutsme
, layoutp
, topMenu
;
125 char *XF86Config_path
= NULL
;
126 char *XF86Module_path
= NULL
;
127 char *XFree86_path
= NULL
;
128 char *XF86Font_path
= NULL
;
129 char *XF86RGB_path
= NULL
;
130 char *XkbConfig_path
= NULL
;
132 static char XF86Config_path_static
[1024];
133 static char XkbConfig_path_static
[1024];
134 Bool xf86config_set
= False
;
136 int textmode
= False
;
138 int nomodules
= False
;
140 int noverify
= False
;
142 xf86cfgComputer computer
;
143 xf86cfgDevice cpu_device
;
145 static Widget device
, layoutm
, popup
, commands
;
146 static int xpos
, ypos
;
148 static char no_cursor_data
[] = { 0,0,0,0, 0,0,0,0 };
149 static GC cablegc
, cablegcshadow
;
150 Atom wm_delete_window
;
151 static Bool config_set
= False
;
152 static Widget mouseSme
, mouseMenu
, keyboardSme
, keyboardMenu
,
153 cardSme
, cardMenu
, monitorSme
, monitorMenu
;
155 int config_mode
= CONFIG_LAYOUT
;
157 static XtActionsRec actions
[] = {
158 {"filter-card", CardFilterAction
},
159 {"select-device", SelectDeviceAction
},
160 {"move-device", MoveDeviceAction
},
161 {"unselect-device", UnselectDeviceAction
},
162 {"device-popup", DevicePopupMenu
},
163 {"device-popdown", DevicePopdownMenu
},
164 {"rename-layout", RenameLayoutAction
},
165 {"write-config", WriteConfigAction
},
166 {"quit", QuitAction
},
167 {"vidmode-restore", VidmodeRestoreAction
},
168 {"config-cancel", ConfigCancelAction
},
169 {"options-cancel", OptionsCancelAction
},
170 {"error-cancel", ErrorCancelAction
},
171 {"quit-cancel", QuitCancelAction
},
172 {"addmode-cancel", CancelAddModeAction
},
173 {"accessx-close", CloseAccessXAction
},
174 {"testmode-cancel", CancelTestModeAction
},
175 {"help-close", HelpCancelAction
},
176 {"expert-close", ExpertCloseAction
},
178 {"module-options-close", ModuleOptionsCancelAction
},
182 static char *device_names
[] = {
195 static XtResource appResources
[] = {
197 {"config", __XCONFIGFILE__
, XtRString
, sizeof(char*),
198 0, XtRString
, "/etc/X11/"__XCONFIGFILE__
},
200 {"menuBitmap", "MenuBitmap", XtRString
, sizeof(char*),
201 0, XtRString
, "menu10"},
209 " xorgcfg [-option ...]\n"
212 " -config <"__XCONFIGFILE__
"> Alternate configuration file.\n"
213 " -modulepath <module-path> "__XSERVERNAME__
" modules location.\n"
214 " -serverpath <server-path> X server to start (if $DISPLAY is not defined).\n"
215 " -fontpath <font-path> Font path for fonts.\n"
216 " -rgbpath <rgb-path> Where the rgb.txt file is located.\n"
218 " -textmode Use this option for the text only interface.\n"
221 " -nomodules Use this option if xorgcfg is slow to start.\n"
222 " -verbose <number> Verbosity used in the loader (default 1).\n"
224 " -verify Verify modules/options integrity.\n"
234 main(int argc
, char *argv
[])
236 Widget pane
, hpane
, expert
, popup
, mouse
, keyboard
, card
, monitor
;
237 Widget bottom
, sme
, smemodeline
, help
, quit
, layopt
;
241 XF86ConfLayoutPtr lay
;
243 char *menuPixmapPath
= NULL
;
246 if ((XFree86Dir
= getenv("XWINHOME")) == NULL
)
247 XFree86Dir
= DefaultXFree86Dir
;
256 for (i
= 1; i
< argc
; i
++) {
257 if (strcmp(argv
[i
], "-config") == 0 ||
258 strcmp(argv
[i
], "-xorgconfig") == 0 ||
259 strcmp(argv
[i
], "-xf86config") == 0) {
261 XF86Config_path
= argv
[++i
];
264 } else if (strcmp(argv
[i
], "-modulepath") == 0) {
266 XF86Module_path
= argv
[++i
];
267 } else if (strcmp(argv
[i
], "-serverpath") == 0) {
269 XFree86_path
= argv
[++i
];
270 } else if (strcmp(argv
[i
], "-fontpath") == 0) {
272 XF86Font_path
= argv
[++i
];
273 } else if (strcmp(argv
[i
], "-rgbpath") == 0) {
275 XF86RGB_path
= argv
[++i
];
278 else if (strcmp(argv
[i
], "-textmode") == 0)
282 else if (strcmp(argv
[i
], "-nomodules") == 0)
284 else if (strcmp(argv
[i
], "-verbose") == 0) {
286 xf86Verbose
= atoi(argv
[++i
]);
289 else if (strcmp(argv
[i
], "-verify") == 0)
303 if (XF86Config_path
== NULL
)
304 XF86Config_path
= XtNewString(__XCONFIGFILE__
);
305 if (XkbConfig_path
== NULL
) {
306 XmuSnprintf(XkbConfig_path_static
, sizeof(XkbConfig_path_static
),
307 "%s/%s%s", XFree86Dir
, XkbConfigDir
, XkbConfigFile
);
308 XkbConfig_path
= XkbConfig_path_static
;
310 toplevel
= XtAppInitialize(&appcon
, "XOrgCfg",
315 DPY
= XtDisplay(toplevel
);
317 XtGetApplicationResources(toplevel
, (XtPointer
)&menuPixmapPath
,
318 appResources
, XtNumber(appResources
), NULL
, 0);
319 if (menuPixmapPath
&& strlen(menuPixmapPath
)) {
320 from
.size
= strlen(menuPixmapPath
);
321 from
.addr
= menuPixmapPath
;
322 to
.size
= sizeof(Pixmap
);
323 to
.addr
= (XtPointer
)&(menuPixmap
);
324 XtConvertAndStore(toplevel
, XtRString
, &from
, XtRBitmap
, &to
);
327 XtAppAddActions(appcon
, actions
, XtNumber(actions
));
329 XawSimpleMenuAddGlobalActions(appcon
);
330 XtRegisterGrabAction(DevicePopupMenu
, True
,
331 ButtonPressMask
| ButtonReleaseMask
,
332 GrabModeAsync
, GrabModeAsync
);
334 pane
= XtCreateManagedWidget("pane", panedWidgetClass
,
336 hpane
= XtVaCreateManagedWidget("hpane", panedWidgetClass
, pane
,
337 XtNorientation
, XtorientHorizontal
, NULL
);
338 topMenu
= XtCreateManagedWidget("topM", menuButtonWidgetClass
,
340 expert
= XtCreateManagedWidget("expert", commandWidgetClass
, hpane
, NULL
, 0);
341 XtAddCallback(expert
, XtNcallback
, ExpertCallback
, NULL
);
342 popup
= XtCreatePopupShell("menu", simpleMenuWidgetClass
,
344 sme
= XtCreateManagedWidget("layout", smeBSBObjectClass
,
346 XtAddCallback(sme
, XtNcallback
, SetConfigModeCallback
,
347 (XtPointer
)CONFIG_LAYOUT
);
348 sme
= XtCreateManagedWidget("screen", smeBSBObjectClass
,
350 XtAddCallback(sme
, XtNcallback
, SetConfigModeCallback
,
351 (XtPointer
)CONFIG_SCREEN
);
352 smemodeline
= XtCreateManagedWidget("modeline", smeBSBObjectClass
,
354 XtAddCallback(smemodeline
, XtNcallback
, SetConfigModeCallback
,
355 (XtPointer
)CONFIG_MODELINE
);
356 sme
= XtCreateManagedWidget("accessx", smeBSBObjectClass
,
358 XtAddCallback(sme
, XtNcallback
, SetConfigModeCallback
,
359 (XtPointer
)CONFIG_ACCESSX
);
361 commands
= XtCreateManagedWidget("commands", formWidgetClass
,
364 mouse
= XtVaCreateManagedWidget("mouse", menuButtonWidgetClass
,
365 commands
, XtNmenuName
, "mouseP", NULL
);
366 popup
= XtCreatePopupShell("mouseP", simpleMenuWidgetClass
,
368 sme
= XtCreateManagedWidget("new", smeBSBObjectClass
,
370 XtAddCallback(sme
, XtNcallback
, AddDeviceCallback
, (XtPointer
)MOUSE
);
371 mouseSme
= XtCreateManagedWidget("configure", smeBSBObjectClass
,
373 XtAddCallback(mouseSme
, XtNcallback
, SmeConfigureDeviceCallback
,
376 keyboard
= XtVaCreateManagedWidget("keyboard", menuButtonWidgetClass
,
377 commands
, XtNmenuName
, "keyboardP", NULL
);
378 popup
= XtCreatePopupShell("keyboardP", simpleMenuWidgetClass
,
380 sme
= XtCreateManagedWidget("new", smeBSBObjectClass
,
382 XtAddCallback(sme
, XtNcallback
, AddDeviceCallback
, (XtPointer
)KEYBOARD
);
383 keyboardSme
= XtCreateManagedWidget("configure", smeBSBObjectClass
,
385 XtAddCallback(keyboardSme
, XtNcallback
, SmeConfigureDeviceCallback
,
386 (XtPointer
)KEYBOARD
);
388 card
= XtVaCreateManagedWidget("card", menuButtonWidgetClass
,
389 commands
, XtNmenuName
, "cardP", NULL
);
390 popup
= XtCreatePopupShell("cardP", simpleMenuWidgetClass
,
392 sme
= XtCreateManagedWidget("new", smeBSBObjectClass
,
394 XtAddCallback(sme
, XtNcallback
, AddDeviceCallback
, (XtPointer
)CARD
);
395 cardSme
= XtCreateManagedWidget("configure", smeBSBObjectClass
,
397 XtAddCallback(cardSme
, XtNcallback
, SmeConfigureDeviceCallback
,
400 monitor
= XtVaCreateManagedWidget("monitor", menuButtonWidgetClass
,
401 commands
, XtNmenuName
, "monitorP", NULL
);
402 popup
= XtCreatePopupShell("monitorP", simpleMenuWidgetClass
,
404 sme
= XtCreateManagedWidget("new", smeBSBObjectClass
,
406 XtAddCallback(sme
, XtNcallback
, AddDeviceCallback
, (XtPointer
)MONITOR
);
407 monitorSme
= XtCreateManagedWidget("configure", smeBSBObjectClass
,
409 XtAddCallback(monitorSme
, XtNcallback
, SmeConfigureDeviceCallback
,
412 work
= XtCreateManagedWidget("work", compositeWidgetClass
,
415 bottom
= XtCreateManagedWidget("bottom", formWidgetClass
,
417 layoutm
= XtCreateManagedWidget("select", menuButtonWidgetClass
,
419 layout
= XtVaCreateManagedWidget("layout", asciiTextWidgetClass
,
421 XtNeditType
, XawtextEdit
,
423 layoutp
= XtCreatePopupShell("menu", simpleMenuWidgetClass
,
425 sme
= XtCreateManagedWidget("new", smeBSBObjectClass
, layoutp
,
427 XtAddCallback(sme
, XtNcallback
, SelectLayoutCallback
, NULL
);
428 help
= XtCreateManagedWidget("help", commandWidgetClass
,
430 XtAddCallback(help
, XtNcallback
, HelpCallback
, NULL
);
431 quit
= XtCreateManagedWidget("quit", commandWidgetClass
,
433 XtAddCallback(quit
, XtNcallback
, QuitCallback
, NULL
);
435 XtRealizeWidget(toplevel
);
436 XtRealizeWidget(topMenu
);
438 pixmap
= XCreateBitmapFromData(XtDisplay(toplevel
), XtWindow(toplevel
),
439 no_cursor_data
, 8, 8);
440 XAllocNamedColor(XtDisplay(toplevel
), toplevel
->core
.colormap
, "black",
442 no_cursor
= XCreatePixmapCursor(XtDisplay(toplevel
), pixmap
, pixmap
,
443 &color
, &color
, 0, 0);
445 XAllocNamedColor(XtDisplay(toplevel
), toplevel
->core
.colormap
, "gray55",
447 values
.line_width
= 3;
448 values
.foreground
= color
.pixel
;
449 cablegcshadow
= XCreateGC(XtDisplay(toplevel
), XtWindow(toplevel
),
450 GCForeground
| GCLineWidth
, &values
);
451 XAllocNamedColor(XtDisplay(toplevel
), toplevel
->core
.colormap
, "gray85",
453 values
.line_width
= 1;
454 values
.foreground
= color
.pixel
;
455 cablegc
= XCreateGC(XtDisplay(toplevel
), XtWindow(toplevel
),
456 GCForeground
| GCLineWidth
, &values
);
458 computer
.cpu
= XtCreateManagedWidget("cpu", simpleWidgetClass
,
460 cpu_device
.widget
= computer
.cpu
;
461 cpu_device
.type
= SERVER
;
463 XtAddEventHandler(work
, ExposureMask
, False
,
464 ComputerEventHandler
, (XtPointer
)NULL
);
466 wm_delete_window
= XInternAtom(DPY
, "WM_DELETE_WINDOW", False
);
467 XSetWMProtocols(DPY
, XtWindow(toplevel
), &wm_delete_window
, 1);
471 UpdateMenuDeviceList(MOUSE
);
472 UpdateMenuDeviceList(KEYBOARD
);
473 UpdateMenuDeviceList(CARD
);
474 UpdateMenuDeviceList(MONITOR
);
475 XtSetSensitive(smemodeline
, VideoModeInitialize());
477 lay
= XF86Config
->conf_layout_lst
;
478 while (lay
!= NULL
) {
479 sme
= XtVaCreateManagedWidget("sme", smeBSBObjectClass
,
481 XtNlabel
, lay
->lay_identifier
,
482 XtNmenuName
, lay
->lay_identifier
,
483 XtNleftBitmap
, menuPixmap
,
485 XtAddCallback(sme
, XtNcallback
, SelectLayoutCallback
, (XtPointer
)lay
);
486 if (layoutsme
== NULL
)
488 layopt
= XtCreatePopupShell(lay
->lay_identifier
, simpleMenuWidgetClass
,
490 sme
= XtCreateManagedWidget("default", smeBSBObjectClass
,
492 XtAddCallback(sme
, XtNcallback
, DefaultLayoutCallback
, NULL
);
493 sme
= XtCreateManagedWidget("remove", smeBSBObjectClass
,
495 XtAddCallback(sme
, XtNcallback
, RemoveLayoutCallback
, NULL
);
496 XtRealizeWidget(layopt
);
498 lay
= (XF86ConfLayoutPtr
)(lay
->list
.next
);
500 SelectLayoutCallback(layoutsme
,
501 XF86Config
->conf_layout_lst
, NULL
);
509 XmuSnprintf(path
, sizeof(path
), "%s/bin/twm", XFree86Dir
);
510 execl(path
, "twm", (void *)NULL
);
514 fprintf(stderr
, "Cannot fork.\n");
524 LoaderInitializeOptions();
527 /* ReadCardsDatabase() must be called after LoaderInitializeOptions() */
530 if (!config_set
&& startedx
) {
531 XtFree(XF86Config_path
);
533 # define XF86CONFIG __XCONFIGFILE__
536 XF86Config_path
= XtNewString(XF86CONFIGDIR
"/" XF86CONFIG
);
538 XF86Config_path
= XtNewString("/etc/X11/" XF86CONFIG
);
541 XtAppMainLoop(appcon
);
548 static Widget shell_cf
;
549 static int write_cf
, asking_cf
;
550 static int cf_state
= 0;
551 #define CF_XF86Config 1
552 #define CF_XKBConfig 2
553 #define CF_First CF_XF86Config
554 #define CF_Last CF_XKBConfig
558 WriteConfig(Widget w
, XtPointer user_data
, XtPointer call_data
)
562 write_cf
= (long)user_data
;
567 QuitCancelAction(Widget w
, XEvent
*event
, String
*params
, Cardinal
*num_params
)
569 WriteConfig(w
, (XtPointer
)-1, NULL
);
574 WriteConfigAction(Widget w
, XEvent
*event
,
575 String
*params
, Cardinal
*num_params
)
577 WriteConfig(w
, (XtPointer
)True
, NULL
);
583 static Widget dialog
;
585 if (shell_cf
== NULL
) {
590 shell_cf
= XtCreatePopupShell("quit", transientShellWidgetClass
,
592 dialog
= XtVaCreateManagedWidget("ask", dialogWidgetClass
, shell_cf
,
593 XtNvalue
, XF86Config_path
, NULL
);
594 XawDialogAddButton(dialog
, "yes", WriteConfig
, (XtPointer
)1);
595 XawDialogAddButton(dialog
, "no", WriteConfig
, (XtPointer
)0);
596 XawDialogAddButton(dialog
, "cancel", WriteConfig
, (XtPointer
)-1);
597 XtRealizeWidget(shell_cf
);
598 XSetWMProtocols(DPY
, XtWindow(shell_cf
), &wm_delete_window
, 1);
599 XtSetArg(args
[0], XtNlabel
, &l
);
600 XtGetValues(dialog
, args
, 1);
601 label
= XtMalloc(len
= (strlen(l
) + strlen(XF86CONFIG
) + 2));
602 XmuSnprintf(label
, len
, "%s\n", XF86CONFIG
);
604 XtSetArg(args
[0], XtNlabel
, label
);
605 XtSetValues(dialog
, args
, 1);
610 Cardinal num_args
= 0;
611 char *l
, *label
= NULL
, *str
= "";
613 XtSetArg(args
[0], XtNlabel
, &l
);
614 XtGetValues(dialog
, args
, 1);
618 XtSetArg(args
[num_args
], XtNvalue
, XF86Config_path
);
623 XtSetArg(args
[num_args
], XtNvalue
, XkbConfig_path
);
629 label
= XtMalloc(strlen(str
) + strlen(l
) + 1);
632 XtSetArg(args
[num_args
], XtNlabel
, label
);
635 XtSetValues(dialog
, args
, num_args
);
642 XtPopup(shell_cf
, XtGrabExclusive
);
644 XtAppProcessEvent(XtWidgetToApplicationContext(shell_cf
), XtIMAll
);
649 XF86Config_path
= XawDialogGetValueString(dialog
);
650 XmuSnprintf(XF86Config_path_static
,
651 sizeof(XF86Config_path_static
),
652 "%s", XF86Config_path
);
653 XF86Config_path
= XF86Config_path_static
;
656 XkbConfig_path
= XawDialogGetValueString(dialog
);
657 XmuSnprintf(XkbConfig_path_static
,
658 sizeof(XkbConfig_path_static
),
659 "%s", XkbConfig_path
);
660 XkbConfig_path
= XkbConfig_path_static
;
670 PopdownErrorCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
672 XtPopdown((Widget
)user_data
);
677 ErrorCancelAction(Widget w
, XEvent
*event
, String
*params
, Cardinal
*num_params
)
679 XtPopdown((Widget
)w
);
684 QuitAction(Widget w
, XEvent
*event
, String
*params
, Cardinal
*num_params
)
686 QuitCallback(w
, NULL
, NULL
);
691 QuitCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
693 for (cf_state
= CF_First
; cf_state
<= CF_Last
; cf_state
++) {
694 if (cf_state
== CF_XKBConfig
&& xkb_info
== NULL
)
697 switch (AskConfig()) {
701 if ((cf_state
== CF_XF86Config
&&
702 !xf86writeConfigFile(XF86Config_path
, XF86Config
)) ||
703 (cf_state
== CF_XKBConfig
&&
704 !WriteXKBConfiguration(XkbConfig_path
,
705 &xkb_info
->config
))) {
711 shell
= XtCreatePopupShell("error",
712 transientShellWidgetClass
,
714 dialog
= XtVaCreateManagedWidget("notice",
716 shell
, XtNvalue
, NULL
,
718 XawDialogAddButton(dialog
, "ok", PopdownErrorCallback
,
720 XtRealizeWidget(shell
);
721 XSetWMProtocols(DPY
, XtWindow(shell
),
722 &wm_delete_window
, 1);
724 XtPopup(shell
, XtGrabExclusive
);
738 InitializeDevices(void)
740 xf86cfgDevice
*device
;
741 int mouse_x
, mouse_y
, keyboard_x
, keyboard_y
,
742 card_x
, card_y
, monitor_x
, monitor_y
, len
;
743 XF86ConfInputPtr input
= XF86Config
->conf_input_lst
;
744 XF86ConfDevicePtr card
= XF86Config
->conf_device_lst
;
745 XF86ConfMonitorPtr monitor
= XF86Config
->conf_monitor_lst
;
746 XF86OptionPtr flags
= NULL
;
747 char buffer
[4096], *tip
;
750 if (XF86Config
->conf_flags
!= NULL
)
751 flags
= XF86Config
->conf_flags
->flg_option_lst
;
754 while (flags
&& len
< sizeof(buffer
) - 1) {
755 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
) - len
,
758 if (flags
->opt_val
!= NULL
)
759 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
) - len
,
763 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
) - len
,
765 flags
= (XF86OptionPtr
)(flags
->list
.next
);
769 tip
= XtNewString(buffer
);
770 XtSetArg(args
[0], XtNtip
, tip
);
771 XtSetValues(computer
.cpu
, args
, 1);
774 #define DEFAULT_MOUSE_WIDTH 30
775 #define DEFAULT_MOUSE_HEIGHT 40
776 #define DEFAULT_KEYBOARD_WIDTH 48
777 #define DEFAULT_KEYBOARD_HEIGHT 36
778 mouse_x
= work
->core
.width
- (work
->core
.width
>> 2);
779 mouse_y
= work
->core
.height
- DEFAULT_MOUSE_HEIGHT
;
781 keyboard_y
= work
->core
.height
- DEFAULT_KEYBOARD_HEIGHT
;
783 while (input
!= NULL
) {
784 if (input
->inp_driver
) {
785 if (strcasecmp(input
->inp_driver
, "mouse") == 0) {
786 device
= AddDevice(MOUSE
, (XtPointer
)input
, mouse_x
, mouse_y
);
788 if ((mouse_x
+= DEFAULT_MOUSE_WIDTH
) > work
->core
.width
) {
789 if ((mouse_y
-= DEFAULT_MOUSE_HEIGHT
) < (work
->core
.height
>> 1))
790 mouse_y
= work
->core
.height
>> 1;
791 mouse_x
= work
->core
.width
- (work
->core
.width
>> 2);
794 else if (IS_KBDDRIV(input
->inp_driver
)) {
795 device
= AddDevice(KEYBOARD
, (XtPointer
)input
, keyboard_x
, keyboard_y
);
797 if ((keyboard_x
+= DEFAULT_KEYBOARD_WIDTH
) >
798 work
->core
.width
- (work
->core
.width
>> 2)) {
799 if ((keyboard_y
-= DEFAULT_KEYBOARD_HEIGHT
) < (work
->core
.height
>> 1))
800 keyboard_y
= work
->core
.height
>> 1;
805 input
= (XF86ConfInputPtr
)(input
->list
.next
);
808 #define DEFAULT_CARD_WIDTH 45
809 #define DEFAULT_CARD_HEIGHT 46
811 card_y
= (work
->core
.height
>> 1) - 20 - DEFAULT_CARD_HEIGHT
;
812 while (card
!= NULL
) {
813 device
= AddDevice(CARD
, (XtPointer
)card
, card_x
, card_y
);
815 if ((card_x
+= DEFAULT_CARD_WIDTH
) > work
->core
.width
) {
816 if ((card_y
-= DEFAULT_CARD_HEIGHT
) < (work
->core
.height
>> 2))
817 card_y
= work
->core
.height
>> 2;
820 card
= (XF86ConfDevicePtr
)(card
->list
.next
);
823 #define DEFAULT_MONITOR_WIDTH 48
824 #define DEFAULT_MONITOR_HEIGHT 48
827 while (monitor
!= NULL
) {
828 XF86ConfScreenPtr screen
= XF86Config
->conf_screen_lst
;
830 device
= AddDevice(MONITOR
, (XtPointer
)monitor
, monitor_x
, monitor_y
);
832 if ((monitor_x
+= DEFAULT_MONITOR_WIDTH
) > work
->core
.width
) {
833 if ((monitor_y
+= DEFAULT_MONITOR_HEIGHT
) >
834 (work
->core
.height
>> 2) - DEFAULT_MONITOR_HEIGHT
)
835 monitor_y
= (work
->core
.height
>> 2) - DEFAULT_MONITOR_HEIGHT
;
839 while (screen
!= NULL
) {
840 if (screen
->scrn_monitor
== monitor
) {
841 card
= XF86Config
->conf_device_lst
;
842 while (card
!= NULL
) {
843 if (screen
->scrn_device
== card
) {
844 xf86cfgScreen
*scr
= (xf86cfgScreen
*)
845 XtCalloc(1, sizeof(xf86cfgScreen
));
848 for (i
= 0; i
< computer
.num_devices
; i
++)
849 if ((XF86ConfDevicePtr
)(computer
.devices
[i
]->config
)
852 scr
->screen
= screen
;
853 scr
->card
= computer
.devices
[i
];
854 scr
->monitor
= device
;
856 ++scr
->card
->refcount
;
857 ++scr
->monitor
->refcount
;
858 computer
.screens
= (xf86cfgScreen
**)
859 XtRealloc((XtPointer
)computer
.screens
,
860 sizeof(xf86cfgScreen
*) *
861 (computer
.num_screens
+ 1));
862 CreateScreenWidget(scr
);
864 computer
.screens
[computer
.num_screens
++] = scr
;
865 SetTip((xf86cfgDevice
*)scr
);
868 card
= (XF86ConfDevicePtr
)(card
->list
.next
);
870 device
->state
= USED
;
872 screen
= (XF86ConfScreenPtr
)(screen
->list
.next
);
875 monitor
= (XF86ConfMonitorPtr
)(monitor
->list
.next
);
880 AddDevice(int type
, XtPointer config
, int x
, int y
)
887 computer
.devices
= (xf86cfgDevice
**)
888 XtRealloc((XtPointer
)computer
.devices
,
889 sizeof(xf86cfgDevice
*) * (computer
.num_devices
+ 1));
890 computer
.devices
[computer
.num_devices
] = (xf86cfgDevice
*)
891 XtCalloc(1, sizeof(xf86cfgDevice
));
892 computer
.devices
[computer
.num_devices
]->config
= config
;
893 computer
.devices
[computer
.num_devices
]->widget
=
894 XtVaCreateManagedWidget(device_names
[type
], simpleWidgetClass
,
900 computer
.devices
[computer
.num_devices
]->type
= type
;
901 computer
.devices
[computer
.num_devices
]->state
= UNUSED
;
902 computer
.devices
[computer
.num_devices
]->refcount
= 0;
903 ++computer
.num_devices
;
906 fprintf(stderr
, "Bad argument to AddDevice.\n");
911 UpdateMenuDeviceList(type
);
913 return (computer
.devices
[computer
.num_devices
- 1]);
918 HelpCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
922 switch (config_mode
) {
924 topic
= HELP_DEVICES
;
929 case CONFIG_MODELINE
:
930 topic
= HELP_MODELINE
;
933 topic
= HELP_ACCESSX
;
940 SelectLayoutCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
943 XF86ConfLayoutPtr lay
= (XF86ConfLayoutPtr
)user_data
;
944 XF86ConfInputrefPtr input
;
945 XF86ConfAdjacencyPtr adj
;
950 /* XXX Needs to check computer.layout,
951 * because this function should also create
954 if (lay
== computer
.layout
&& computer
.layout
)
957 if (computer
.layout
!= NULL
) {
958 for (i
= 0; i
< computer
.num_layouts
; i
++) {
959 if (computer
.layouts
[i
]->layout
== computer
.layout
)
962 if (i
< computer
.num_layouts
) {
963 XtFree((XtPointer
)computer
.layouts
[i
]->screen
);
964 XtFree((XtPointer
)computer
.layouts
[i
]->position
);
967 computer
.layouts
= (xf86cfgLayout
**)
968 XtRealloc((XtPointer
)computer
.layouts
, sizeof(xf86cfgLayout
*) *
969 (computer
.num_layouts
+ 1));
970 ++computer
.num_layouts
;
972 computer
.layouts
[i
] = (xf86cfgLayout
*)XtCalloc(1, sizeof(xf86cfgLayout
));
973 computer
.layouts
[i
]->layout
= computer
.layout
;
974 computer
.layouts
[i
]->num_layouts
= computer
.num_screens
;
975 computer
.layouts
[i
]->screen
= (xf86cfgScreen
**)
976 XtMalloc(sizeof(xf86cfgScreen
*) * computer
.num_screens
);
977 computer
.layouts
[i
]->position
= (XPoint
*)
978 XtMalloc(sizeof(XPoint
) * computer
.num_screens
);
979 for (j
= 0; j
< computer
.num_screens
; j
++) {
980 computer
.layouts
[i
]->screen
[j
] = computer
.screens
[j
];
981 computer
.layouts
[i
]->position
[j
].x
= computer
.screens
[j
]->widget
->core
.x
;
982 computer
.layouts
[i
]->position
[j
].y
= computer
.screens
[j
]->widget
->core
.y
;
987 for (i
= 0; i
< computer
.num_layouts
; i
++)
988 if (computer
.layouts
[i
]->layout
== lay
) {
989 for (j
= 0; j
< computer
.layouts
[i
]->num_layouts
; j
++) {
992 for (k
= 0; k
< computer
.num_screens
; k
++)
993 if (computer
.screens
[k
] == computer
.layouts
[i
]->screen
[j
]) {
994 XtMoveWidget(computer
.screens
[k
]->widget
,
995 computer
.layouts
[i
]->position
[j
].x
,
996 computer
.layouts
[i
]->position
[j
].y
);
1003 XtSetArg(args
[0], XtNlabel
, &str
);
1004 XtGetValues(w
, args
, 1);
1005 XtSetArg(args
[0], XtNstring
, str
);
1006 XtSetValues(layout
, args
, 1);
1009 computer
.layout
= lay
;
1011 for (i
= 0; i
< computer
.num_devices
; i
++)
1012 computer
.devices
[i
]->state
= UNUSED
;
1013 for (i
= 0; i
< computer
.num_screens
; i
++)
1014 computer
.screens
[i
]->state
= UNUSED
;
1018 XF86ConfLayoutPtr l
;
1019 int num_layouts
= 0;
1021 l
= XF86Config
->conf_layout_lst
;
1023 if (l
->lay_adjacency_lst
== NULL
&&
1024 l
->lay_inactive_lst
== NULL
&&
1025 l
->lay_input_lst
== NULL
&&
1026 l
->lay_option_lst
== NULL
&&
1027 l
->lay_comment
== NULL
) {
1029 i
< ((CompositeWidget
)layout
)->composite
.num_children
; i
++)
1030 if (strcmp(XtName(((CompositeWidget
)layout
)->composite
.
1031 children
[i
]), l
->lay_identifier
) == 0) {
1032 layoutsme
= ((CompositeWidget
)layout
)->composite
.children
[i
];
1034 computer
.layout
= l
;
1035 XtSetArg(args
[0], XtNstring
, l
->lay_identifier
);
1036 XtSetValues(layout
, args
, 1);
1037 if (config_mode
== CONFIG_LAYOUT
)
1039 if (config_mode
== CONFIG_SCREEN
)
1044 l
= (XF86ConfLayoutPtr
)(l
->list
.next
);
1047 XmuSnprintf(name
, sizeof(name
), "Layout%d", num_layouts
);
1049 } while (xf86findLayout(name
,
1050 XF86Config
->conf_layout_lst
) != NULL
);
1051 l
= (XF86ConfLayoutPtr
)XtCalloc(1, sizeof(XF86ConfLayoutRec
));
1053 l
->lay_identifier
= XtNewString(name
);
1054 XF86Config
->conf_layout_lst
=
1055 xf86addLayout(XF86Config
->conf_layout_lst
, l
);
1056 layoutsme
= XtVaCreateManagedWidget("sme", smeBSBObjectClass
,
1059 XtNmenuName
, l
->lay_identifier
,
1060 XtNleftBitmap
, menuPixmap
,
1062 XtAddCallback(layoutsme
, XtNcallback
,
1063 SelectLayoutCallback
, (XtPointer
)l
);
1065 layopt
= XtCreatePopupShell(l
->lay_identifier
, simpleMenuWidgetClass
,
1067 sme
= XtCreateManagedWidget("default", smeBSBObjectClass
,
1069 XtAddCallback(sme
, XtNcallback
, DefaultLayoutCallback
, NULL
);
1070 sme
= XtCreateManagedWidget("remove", smeBSBObjectClass
,
1072 XtAddCallback(sme
, XtNcallback
, RemoveLayoutCallback
, NULL
);
1073 XtRealizeWidget(layopt
);
1075 computer
.layout
= l
;
1076 XtSetArg(args
[0], XtNstring
, name
);
1077 XtSetValues(layout
, args
, 1);
1078 if (config_mode
== CONFIG_LAYOUT
)
1080 if (config_mode
== CONFIG_SCREEN
)
1085 input
= lay
->lay_input_lst
;
1086 adj
= lay
->lay_adjacency_lst
;
1088 for (i
= 0; i
< computer
.num_devices
; i
++)
1089 if (computer
.devices
[i
]->config
!= NULL
&&
1090 (computer
.devices
[i
]->type
== MOUSE
||
1091 computer
.devices
[i
]->type
== KEYBOARD
)) {
1092 while (input
!= NULL
) {
1093 if (strcmp(input
->iref_inputdev_str
, ((XF86ConfInputPtr
)
1094 (computer
.devices
[i
]->config
))->inp_identifier
) == 0) {
1095 computer
.devices
[i
]->state
= USED
;
1098 input
= (XF86ConfInputrefPtr
)(input
->list
.next
);
1100 input
= lay
->lay_input_lst
;
1103 for (i
= 0; i
< computer
.num_devices
; i
++)
1104 if (computer
.devices
[i
]->type
== CARD
) {
1105 while (adj
!= NULL
) {
1106 XF86ConfScreenPtr screen
= adj
->adj_screen
;
1108 if (computer
.devices
[i
]->config
!= NULL
&&
1109 strcmp(screen
->scrn_device_str
, ((XF86ConfDevicePtr
)
1110 (computer
.devices
[i
]->config
))->dev_identifier
) == 0) {
1113 for (j
= 0; j
< computer
.num_screens
; j
++)
1114 if (computer
.screens
[j
]->card
== computer
.devices
[i
])
1116 computer
.screens
[j
]->card
->state
= USED
;
1117 if (computer
.screens
[j
]->monitor
!= NULL
)
1118 computer
.screens
[j
]->monitor
->state
= USED
;
1119 computer
.screens
[j
]->state
= USED
;
1122 adj
= (XF86ConfAdjacencyPtr
)(adj
->list
.next
);
1124 adj
= lay
->lay_adjacency_lst
;
1127 if (config_mode
== CONFIG_LAYOUT
)
1129 else if (config_mode
== CONFIG_SCREEN
)
1135 DefaultLayoutCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1140 XF86ConfLayoutPtr prev
, tmp
, lay
;
1142 str
= w
&& XtParent(w
) ? XtName(XtParent(w
)) : NULL
;
1146 prev
= XF86Config
->conf_layout_lst
;
1147 lay
= xf86findLayout(str
, prev
);
1152 while (tmp
!= NULL
) {
1156 tmp
= (XF86ConfLayoutPtr
)(tmp
->list
.next
);
1159 for (i
= 1; i
< ((CompositeWidget
)layoutp
)->composite
.num_children
; i
++)
1160 XtDestroyWidget(((CompositeWidget
)layoutp
)->composite
.children
[i
]);
1161 for (i
= 0; i
< layoutp
->core
.num_popups
; i
++)
1162 XtDestroyWidget(layoutp
->core
.popup_list
[i
]);
1164 prev
->list
.next
= lay
->list
.next
;
1165 lay
->list
.next
= XF86Config
->conf_layout_lst
;
1166 XF86Config
->conf_layout_lst
= lay
;
1169 lay
= XF86Config
->conf_layout_lst
;
1170 while (lay
!= NULL
) {
1171 sme
= XtVaCreateManagedWidget("sme", smeBSBObjectClass
,
1173 XtNlabel
, lay
->lay_identifier
,
1174 XtNmenuName
, lay
->lay_identifier
,
1175 XtNleftBitmap
, menuPixmap
,
1177 XtAddCallback(sme
, XtNcallback
, SelectLayoutCallback
, (XtPointer
)lay
);
1178 if (layoutsme
== NULL
)
1180 layopt
= XtCreatePopupShell(lay
->lay_identifier
, simpleMenuWidgetClass
,
1182 sme
= XtCreateManagedWidget("default", smeBSBObjectClass
,
1184 XtAddCallback(sme
, XtNcallback
, DefaultLayoutCallback
, NULL
);
1185 sme
= XtCreateManagedWidget("remove", smeBSBObjectClass
,
1187 XtAddCallback(sme
, XtNcallback
, RemoveLayoutCallback
, NULL
);
1188 XtRealizeWidget(layopt
);
1190 lay
= (XF86ConfLayoutPtr
)(lay
->list
.next
);
1192 SelectLayoutCallback(layoutsme
,
1193 XF86Config
->conf_layout_lst
, NULL
);
1198 RemoveLayoutCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1200 XF86ConfLayoutPtr prev
, tmp
, lay
, rem
;
1206 str
= w
&& XtParent(w
) ? XtName(XtParent(w
)) : NULL
;
1210 prev
= XF86Config
->conf_layout_lst
;
1211 lay
= xf86findLayout(str
, prev
);
1213 while (tmp
!= NULL
) {
1217 tmp
= (XF86ConfLayoutPtr
)(tmp
->list
.next
);
1222 lay
= (XF86ConfLayoutPtr
)(tmp
->list
.next
);
1223 if (lay
== NULL
&& prev
!= tmp
)
1229 for (i
= 0; i
< ((CompositeWidget
)layoutp
)->composite
.num_children
;
1231 XtSetArg(args
[0], XtNlabel
, &str
);
1232 XtGetValues(((CompositeWidget
)layoutp
)->composite
.children
[i
],
1234 if (strcmp(lay
->lay_identifier
, str
) == 0) {
1235 layoutsme
= ((CompositeWidget
)layoutp
)->composite
.children
[i
];
1239 SelectLayoutCallback(layoutsme
, lay
, NULL
);
1242 computer
.layout
= NULL
;
1243 XtSetArg(args
[0], XtNstring
, "");
1244 XtSetValues(layout
, args
, 1);
1246 for (i
= 0; i
< computer
.num_devices
; i
++)
1247 computer
.devices
[i
]->state
= UNUSED
;
1251 for (i
= 0; i
< ((CompositeWidget
)layoutp
)->composite
.num_children
; i
++) {
1252 XtSetArg(args
[0], XtNlabel
, &str
);
1253 XtGetValues(((CompositeWidget
)layoutp
)->composite
.children
[i
], args
, 1);
1254 if (strcmp(rem
->lay_identifier
, str
) == 0) {
1255 sme
= ((CompositeWidget
)layoutp
)->composite
.children
[i
];
1260 xf86removeLayout(XF86Config
, rem
);
1262 XtDestroyWidget(sme
);
1266 SetTip(xf86cfgDevice
*device
)
1268 XF86OptionPtr option
= NULL
;
1269 char *tip
, buffer
[4096];
1273 XtSetArg(args
[0], XtNtip
, &tip
);
1274 XtGetValues(device
->widget
, args
, 1);
1276 switch (device
->type
) {
1278 XF86ConfInputPtr mouse
= (XF86ConfInputPtr
)device
->config
;
1282 len
= XmuSnprintf(buffer
, sizeof(buffer
),
1283 "Identifier \"%s\"\n"
1284 "Driver \"mouse\"\n",
1285 mouse
->inp_identifier
);
1286 option
= mouse
->inp_option_lst
;
1289 XF86ConfInputPtr keyboard
= (XF86ConfInputPtr
)device
->config
;
1291 if (keyboard
== NULL
)
1293 len
= XmuSnprintf(buffer
, sizeof(buffer
),
1294 "Identifier \"%s\"\n"
1295 "Driver \"keyboard\"\n",
1296 keyboard
->inp_identifier
);
1297 option
= keyboard
->inp_option_lst
;
1300 XF86ConfDevicePtr card
= (XF86ConfDevicePtr
)device
->config
;
1304 len
= XmuSnprintf(buffer
, sizeof(buffer
),
1305 "Identifier \"%s\"\n"
1307 card
->dev_identifier
,
1309 option
= card
->dev_option_lst
;
1312 XF86ConfMonitorPtr monitor
= (XF86ConfMonitorPtr
)device
->config
;
1314 if (monitor
== NULL
)
1316 if (monitor
->mon_vendor
!= NULL
)
1317 len
= XmuSnprintf(buffer
, sizeof(buffer
),
1318 "Identifier \"%s\"\n"
1320 monitor
->mon_identifier
,
1321 monitor
->mon_vendor
);
1323 len
= XmuSnprintf(buffer
, sizeof(buffer
),
1324 "Identifier \"%s\"\n",
1325 monitor
->mon_identifier
);
1326 option
= monitor
->mon_option_lst
;
1329 XF86ConfScreenPtr screen
= (XF86ConfScreenPtr
)device
->config
;
1333 len
= XmuSnprintf(buffer
, sizeof(buffer
),
1334 "Identifier \"%s\"\n",
1335 screen
->scrn_identifier
);
1336 if (screen
->scrn_device_str
!= NULL
)
1337 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
),
1339 screen
->scrn_device_str
);
1340 if (screen
->scrn_monitor_str
!= NULL
)
1341 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
),
1343 screen
->scrn_monitor_str
);
1344 option
= screen
->scrn_option_lst
;
1347 len
= XmuSnprintf(buffer
, sizeof(buffer
),
1348 "%s\n", "Server Flags");
1349 option
= XF86Config
->conf_flags
->flg_option_lst
;
1353 while (option
&& len
< sizeof(buffer
) - 1) {
1354 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
) - len
,
1357 if (option
->opt_val
!= NULL
)
1358 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
) - len
,
1362 len
+= XmuSnprintf(buffer
+ len
, sizeof(buffer
) - len
,
1364 option
= (XF86OptionPtr
)(option
->list
.next
);
1368 XtSetArg(args
[0], XtNtip
, tip
);
1369 XtSetValues(device
->widget
, args
, 1);
1374 AddDeviceCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1376 AddDevice((long)user_data
, NULL
, 6, 6);
1380 SmeConfigureDeviceCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1384 switch ((long)user_data
) {
1389 for (i
= 0; i
< computer
.num_devices
; i
++)
1390 if (computer
.devices
[i
]->type
== (long)user_data
) {
1391 config
= computer
.devices
[i
]->widget
;
1392 ConfigureDeviceCallback(w
, NULL
, NULL
);
1396 /* hack for newly added devices */
1397 case -(MOUSE
+ 100):
1398 case -(KEYBOARD
+ 100):
1400 case -(MONITOR
+ 100):
1401 for (i
= 0; i
< computer
.num_devices
; i
++)
1402 if (-(computer
.devices
[i
]->type
+ 100) == (long)user_data
&&
1403 computer
.devices
[i
]->config
== NULL
) {
1404 config
= computer
.devices
[i
]->widget
;
1405 ConfigureDeviceCallback(w
, NULL
, NULL
);
1410 for (i
= 0; i
< computer
.num_devices
; i
++)
1411 if (computer
.devices
[i
]->config
== user_data
) {
1412 config
= computer
.devices
[i
]->widget
;
1413 ConfigureDeviceCallback(w
, NULL
, NULL
);
1420 ConfigureDeviceCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1424 if (config_mode
== CONFIG_LAYOUT
) {
1425 for (i
= 0; i
< computer
.num_devices
; i
++) {
1426 if (computer
.devices
[i
]->widget
== config
) {
1427 switch (computer
.devices
[i
]->type
) {
1429 XF86ConfInputPtr mouse
=
1430 MouseConfig(computer
.devices
[i
]->config
);
1432 if (mouse
!= NULL
&& computer
.devices
[i
]->config
== NULL
) {
1433 XF86Config
->conf_input_lst
=
1434 xf86addInput(XF86Config
->conf_input_lst
,
1436 computer
.devices
[i
]->config
= (XtPointer
)mouse
;
1438 SetTip(computer
.devices
[i
]);
1441 XF86ConfInputPtr keyboard
=
1442 KeyboardConfig(computer
.devices
[i
]->config
);
1444 if (keyboard
!= NULL
&& computer
.devices
[i
]->config
== NULL
) {
1445 XF86Config
->conf_input_lst
=
1446 xf86addInput(XF86Config
->conf_input_lst
,
1448 computer
.devices
[i
]->config
= (XtPointer
)keyboard
;
1450 SetTip(computer
.devices
[i
]);
1453 XF86ConfDevicePtr card
=
1454 CardConfig(computer
.devices
[i
]->config
);
1456 if (card
!= NULL
&& computer
.devices
[i
]->config
== NULL
) {
1457 XF86Config
->conf_device_lst
=
1458 xf86addDevice(XF86Config
->conf_device_lst
,
1460 computer
.devices
[i
]->config
= (XtPointer
)card
;
1462 SetTip(computer
.devices
[i
]);
1463 for (j
= 0; j
< computer
.num_screens
; j
++)
1464 if (computer
.screens
[j
]->card
->widget
== config
)
1465 SetTip((xf86cfgDevice
*)computer
.screens
[j
]);
1468 XF86ConfMonitorPtr monitor
=
1469 MonitorConfig(computer
.devices
[i
]->config
);
1471 if (monitor
!= NULL
&& computer
.devices
[i
]->config
== NULL
) {
1472 XF86Config
->conf_monitor_lst
=
1473 xf86addMonitor(XF86Config
->conf_monitor_lst
,
1475 computer
.devices
[i
]->config
= (XtPointer
)monitor
;
1477 SetTip(computer
.devices
[i
]);
1478 for (j
= 0; j
< computer
.num_screens
; j
++)
1479 if (computer
.screens
[j
]->monitor
->widget
== config
)
1480 SetTip((xf86cfgDevice
*)computer
.screens
[j
]);
1483 /* Need to update because it may have been renamed */
1484 UpdateMenuDeviceList(computer
.devices
[i
]->type
);
1489 else if (config_mode
== CONFIG_SCREEN
) {
1490 for (i
= 0; i
< computer
.num_screens
; i
++)
1491 if (computer
.screens
[i
]->widget
== config
) {
1492 if (ScreenConfig(computer
.screens
[i
]->screen
) != NULL
)
1493 SetTip((xf86cfgDevice
*)computer
.screens
[i
]);
1499 OptionsCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1502 XF86OptionPtr
*options
= NULL
;
1504 xf86cfgModuleOptions
*drv_opts
= NULL
;
1507 if (config_mode
== CONFIG_SCREEN
) {
1508 for (i
= 0; i
< computer
.num_screens
; i
++)
1509 if (computer
.screens
[i
]->widget
== config
) {
1510 options
= &(computer
.screens
[i
]->screen
->scrn_option_lst
);
1515 for (i
= 0; i
< computer
.num_devices
; i
++)
1516 if (computer
.devices
[i
]->widget
== config
)
1519 if (i
>= computer
.num_devices
) {
1520 if (XF86Config
->conf_flags
== NULL
)
1521 XF86Config
->conf_flags
= (XF86ConfFlagsPtr
)
1522 XtCalloc(1, sizeof(XF86ConfFlagsRec
));
1523 options
= &(XF86Config
->conf_flags
->flg_option_lst
);
1526 switch (computer
.devices
[i
]->type
) {
1529 options
= (XF86OptionPtr
*)&(((XF86ConfInputPtr
)
1530 (computer
.devices
[i
]->config
))->inp_option_lst
);
1533 char *drv
= ((XF86ConfInputPtr
)
1534 (computer
.devices
[i
]->config
))->inp_driver
;
1537 drv_opts
= module_options
;
1539 if (drv_opts
->type
== InputModule
&&
1540 strcmp(drv_opts
->name
, drv
) == 0)
1542 drv_opts
= drv_opts
->next
;
1550 options
= (XF86OptionPtr
*)&(((XF86ConfDevicePtr
)
1551 (computer
.devices
[i
]->config
))->dev_option_lst
);
1554 char *drv
= ((XF86ConfDevicePtr
)
1555 (computer
.devices
[i
]->config
))->dev_driver
;
1558 drv_opts
= module_options
;
1560 if (drv_opts
->type
== VideoModule
&&
1561 strcmp(drv_opts
->name
, drv
) == 0)
1563 drv_opts
= drv_opts
->next
;
1570 options
= (XF86OptionPtr
*)&(((XF86ConfMonitorPtr
)
1571 (computer
.devices
[i
]->config
))->mon_option_lst
);
1578 OptionsPopup(options
, drv_opts
? drv_opts
->name
: NULL
,
1579 drv_opts
? drv_opts
->option
: NULL
);
1581 OptionsPopup(options
);
1583 if (config_mode
== CONFIG_SCREEN
) {
1584 XF86OptionPtr option
, options
;
1587 options
= computer
.screens
[i
]->screen
->scrn_option_lst
;
1588 if ((option
= xf86findOption(options
, "Rotate")) != NULL
) {
1589 if (option
->opt_val
!= NULL
)
1590 rotate
= strcasecmp(option
->opt_val
, "CW") == 0 ? 1 :
1591 strcasecmp(option
->opt_val
, "CCW") == 0 ? -1 : 0;
1592 XtFree(option
->opt_val
);
1593 option
->opt_val
= XtNewString(rotate
> 0 ? "CW" : "CCW");
1594 computer
.screens
[i
]->rotate
= rotate
;
1597 computer
.screens
[i
]->rotate
= 0;
1600 SetTip((xf86cfgDevice
*)computer
.screens
[i
]);
1603 if (i
>= computer
.num_devices
)
1604 SetTip(&cpu_device
);
1606 SetTip(computer
.devices
[i
]);
1611 EnableDeviceCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1615 if (config_mode
== CONFIG_SCREEN
) {
1616 for (i
= 0; i
< computer
.num_screens
; i
++)
1617 if (computer
.screens
[i
]->widget
== config
) {
1618 computer
.screens
[i
]->state
= USED
;
1619 computer
.screens
[i
]->card
->state
= USED
;
1625 for (i
= 0; i
< computer
.num_devices
; i
++)
1626 if (computer
.devices
[i
]->widget
== config
) {
1627 if (computer
.devices
[i
]->state
== USED
)
1629 computer
.devices
[i
]->state
= USED
;
1633 if (i
>= computer
.num_devices
|| computer
.layout
== NULL
)
1635 switch (computer
.devices
[i
]->type
) {
1638 int nmouses
= 0, nkeyboards
= 0;
1639 XF86ConfInputPtr input
= (XF86ConfInputPtr
)
1640 (computer
.devices
[i
]->config
);
1641 XF86ConfInputrefPtr nex
, iref
= computer
.layout
->lay_input_lst
;
1642 XF86OptionPtr option
;
1645 while (nex
!= NULL
) {
1646 if (strcasecmp(nex
->iref_inputdev
->inp_driver
, "mouse") == 0)
1648 else if (IS_KBDDRIV(nex
->iref_inputdev
->inp_driver
))
1651 nex
= (XF86ConfInputrefPtr
)(nex
->list
.next
);
1653 nex
= (XF86ConfInputrefPtr
)XtCalloc(1, sizeof(XF86ConfInputrefRec
));
1654 nex
->list
.next
= NULL
;
1655 nex
->iref_inputdev
= input
;
1656 nex
->iref_inputdev_str
= XtNewString(input
->inp_identifier
);
1657 if (nmouses
== 0 && computer
.devices
[i
]->type
== MOUSE
)
1658 option
= xf86newOption(XtNewString("CorePointer"), NULL
);
1659 else if (nkeyboards
== 0 && computer
.devices
[i
]->type
== KEYBOARD
)
1660 option
= xf86newOption(XtNewString("CoreKeyboard"), NULL
);
1662 option
= xf86newOption(XtNewString("SendCoreEvents"), NULL
);
1663 nex
->iref_option_lst
= option
;
1664 computer
.layout
->lay_input_lst
=
1665 xf86addInputref(computer
.layout
->lay_input_lst
, nex
);
1668 for (i
= 0; i
< computer
.num_screens
; i
++) {
1669 if (computer
.screens
[i
]->card
->widget
== config
&&
1670 computer
.screens
[i
]->state
!= USED
) {
1671 XF86ConfAdjacencyPtr adj
;
1673 adj
= (XF86ConfAdjacencyPtr
)
1674 XtCalloc(1, sizeof(XF86ConfAdjacencyRec
));
1675 adj
->adj_screen
= computer
.screens
[i
]->screen
;
1676 adj
->adj_screen_str
= XtNewString(computer
.screens
[i
]->
1677 screen
->scrn_identifier
);
1678 computer
.layout
->lay_adjacency_lst
= (XF86ConfAdjacencyPtr
)
1679 xf86addListItem((GenericListPtr
)computer
.layout
->
1680 lay_adjacency_lst
, (GenericListPtr
)adj
);
1681 computer
.screens
[i
]->state
= USED
;
1691 DisableDeviceCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1695 if (config_mode
== CONFIG_SCREEN
) {
1696 for (i
= 0; i
< computer
.num_screens
; i
++)
1697 if (computer
.screens
[i
]->widget
== config
) {
1698 computer
.screens
[i
]->state
= UNUSED
;
1699 computer
.screens
[i
]->card
->state
= UNUSED
;
1705 for (i
= 0; i
< computer
.num_devices
; i
++)
1706 if (computer
.devices
[i
]->widget
== config
) {
1707 if (computer
.devices
[i
]->state
== UNUSED
)
1709 computer
.devices
[i
]->state
= UNUSED
;
1713 if (i
>= computer
.num_devices
|| computer
.layout
== NULL
)
1715 switch (computer
.devices
[i
]->type
) {
1718 xf86removeInputRef(computer
.layout
,
1719 (XF86ConfInputPtr
)(computer
.devices
[i
]->config
));
1722 XF86ConfAdjacencyPtr adj
;
1725 if (computer
.layout
== NULL
)
1727 for (j
= 0; j
< computer
.num_screens
; j
++)
1728 if (computer
.screens
[j
]->card
->widget
== config
) {
1729 adj
= computer
.layout
->lay_adjacency_lst
;
1730 while (adj
!= NULL
) {
1731 if (adj
->adj_screen
== computer
.screens
[j
]->screen
) {
1732 xf86removeAdjacency(computer
.layout
, adj
);
1735 adj
= (XF86ConfAdjacencyPtr
)(adj
->list
.next
);
1737 computer
.screens
[j
]->state
= UNUSED
;
1748 RemoveDeviceCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
1752 for (i
= 0; i
< computer
.num_screens
; i
++)
1753 if (computer
.screens
[i
]->widget
== config
) {
1754 RemoveScreen(computer
.screens
[i
]->monitor
,
1755 computer
.screens
[i
]->card
);
1760 for (i
= 0; i
< computer
.num_devices
; i
++) {
1761 if (computer
.devices
[i
]->widget
== config
) {
1762 switch (computer
.devices
[i
]->type
) {
1765 xf86removeInput(XF86Config
,
1766 (XF86ConfInputPtr
)(computer
.devices
[i
]->config
));
1773 if (computer
.devices
[i
]->type
== CARD
) {
1774 for (j
= 0; j
< computer
.num_screens
; j
++)
1775 if (computer
.screens
[j
]->card
== computer
.devices
[i
]) {
1776 RemoveScreen(computer
.screens
[j
]->monitor
,
1777 computer
.devices
[i
]);
1780 if (computer
.devices
[i
]->refcount
<= 0)
1781 xf86removeDevice(XF86Config
,
1782 (XF86ConfDevicePtr
)(computer
.devices
[i
]->config
));
1784 else if (computer
.devices
[i
]->type
== MONITOR
) {
1785 for (j
= 0; j
< computer
.num_screens
; j
++)
1786 if (computer
.screens
[j
]->monitor
== computer
.devices
[i
]) {
1787 RemoveScreen(computer
.devices
[i
],
1788 computer
.screens
[j
]->card
);
1791 if (computer
.devices
[i
]->refcount
<= 0)
1792 xf86removeMonitor(XF86Config
,
1793 (XF86ConfMonitorPtr
)(computer
.devices
[i
]->config
));
1796 if (computer
.devices
[i
]->refcount
<= 0) {
1797 int type
= computer
.devices
[i
]->type
;
1799 XtDestroyWidget(computer
.devices
[i
]->widget
);
1800 XtFree((XtPointer
)computer
.devices
[i
]);
1801 if (--computer
.num_devices
> i
)
1802 memmove(&computer
.devices
[i
], &computer
.devices
[i
+ 1],
1803 (computer
.num_devices
- i
) * sizeof(xf86cfgDevice
*));
1806 UpdateMenuDeviceList(type
);
1815 UpdateMenuDeviceList(int type
)
1817 Widget sme
= NULL
, menu
= NULL
;
1819 static char *mouseM
= "mouseM", *keyboardM
= "keyboardM",
1820 *cardM
= "cardM", *monitorM
= "monitorM";
1822 for (i
= count
= 0; i
< computer
.num_devices
; i
++)
1823 if (computer
.devices
[i
]->type
== type
)
1833 menu
= keyboardMenu
;
1846 for (i
= ((CompositeWidget
)menu
)->composite
.num_children
- 1; i
>= 0; i
--)
1847 XtDestroyWidget(((CompositeWidget
)menu
)->composite
.children
[i
]);
1850 XtVaSetValues(sme
, XtNmenuName
, NULL
, XtNleftBitmap
, None
, NULL
);
1856 if (mouseMenu
== NULL
)
1858 XtCreatePopupShell(mouseM
, simpleMenuWidgetClass
,
1859 XtParent(mouseSme
), NULL
, 0);
1860 XtVaSetValues(mouseSme
, XtNmenuName
, mouseM
,
1861 XtNleftBitmap
, menuPixmap
, NULL
);
1864 if (keyboardMenu
== NULL
)
1865 menu
= keyboardMenu
=
1866 XtCreatePopupShell(keyboardM
, simpleMenuWidgetClass
,
1867 XtParent(keyboardSme
), NULL
, 0);
1868 XtVaSetValues(keyboardSme
, XtNmenuName
, keyboardM
,
1869 XtNleftBitmap
, menuPixmap
, NULL
);
1872 if (cardMenu
== NULL
)
1874 XtCreatePopupShell(cardM
, simpleMenuWidgetClass
,
1875 XtParent(cardSme
), NULL
, 0);
1876 XtVaSetValues(cardSme
, XtNmenuName
, cardM
,
1877 XtNleftBitmap
, menuPixmap
, NULL
);
1880 if (monitorMenu
== NULL
)
1881 menu
= monitorMenu
=
1882 XtCreatePopupShell(monitorM
, simpleMenuWidgetClass
,
1883 XtParent(monitorSme
), NULL
, 0);
1884 XtVaSetValues(monitorSme
, XtNmenuName
, monitorM
,
1885 XtNleftBitmap
, menuPixmap
, NULL
);
1889 for (i
= 0; i
< computer
.num_devices
; i
++)
1890 if (computer
.devices
[i
]->type
== type
) {
1893 if (computer
.devices
[i
]->config
) {
1897 label
= ((XF86ConfInputPtr
)computer
.devices
[i
]->config
)
1901 label
= ((XF86ConfDevicePtr
)computer
.devices
[i
]->config
)
1905 label
= ((XF86ConfMonitorPtr
)computer
.devices
[i
]->config
)
1916 label
= "newKeyboard";
1922 label
= "newMonitor";
1927 sme
= XtCreateManagedWidget(label
, smeBSBObjectClass
, menu
, NULL
, 0);
1928 XtAddCallback(sme
, XtNcallback
, SmeConfigureDeviceCallback
,
1929 computer
.devices
[i
]->config
?
1930 computer
.devices
[i
]->config
:
1931 (XtPointer
) (-((long)type
+ 100)));
1937 SelectDeviceAction(Widget w
, XEvent
*event
, String
*params
, Cardinal
*num_params
)
1940 xpos
= event
->xbutton
.x_root
;
1941 ypos
= event
->xbutton
.y_root
;
1942 XDefineCursor(XtDisplay(device
), XtWindow(device
), no_cursor
);
1944 if (config_mode
== CONFIG_SCREEN
) {
1945 sxpos
= device
->core
.x
;
1946 sypos
= device
->core
.y
;
1952 MoveDeviceAction(Widget w
, XEvent
*event
, String
*params
, Cardinal
*num_params
)
1954 int dx
, dy
, x
, y
, oldx
, oldy
;
1956 if (device
== NULL
|| device
!= w
)
1959 dx
= event
->xbutton
.x_root
- xpos
;
1960 dy
= event
->xbutton
.y_root
- ypos
;
1962 oldx
= device
->core
.x
;
1963 oldy
= device
->core
.y
;
1964 x
= device
->core
.x
+ dx
;
1965 y
= device
->core
.y
+ dy
;
1969 else if (x
+ device
->core
.width
> XtParent(device
)->core
.width
)
1970 x
= XtParent(device
)->core
.width
- device
->core
.width
;
1973 else if (y
+ device
->core
.height
> XtParent(device
)->core
.height
)
1974 y
= XtParent(device
)->core
.height
- device
->core
.height
;
1979 XRaiseWindow(XtDisplay(device
), XtWindow(device
));
1980 XtMoveWidget(device
, x
, y
);
1988 UnselectDeviceAction(Widget w
, XEvent
*ev
, String
*params
, Cardinal
*num_params
)
1990 if (device
!= NULL
) {
1991 XUndefineCursor(XtDisplay(device
), XtWindow(device
));
1993 if (config_mode
== CONFIG_SCREEN
)
2001 DevicePopupMenu(Widget w
, XEvent
*event
, String
*params
, Cardinal
*num_params
)
2003 static Widget configure
, options
, enable
, disable
, remove
;
2004 static int first
= 1;
2011 popup
= XtCreatePopupShell("popup", simpleMenuWidgetClass
,
2013 configure
= XtCreateManagedWidget("configure", smeBSBObjectClass
,
2015 XtAddCallback(configure
, XtNcallback
, ConfigureDeviceCallback
, NULL
);
2016 options
= XtCreateManagedWidget("options", smeBSBObjectClass
,
2018 XtAddCallback(options
, XtNcallback
, OptionsCallback
, NULL
);
2019 XtCreateManagedWidget("line", smeLineObjectClass
,
2021 enable
= XtCreateManagedWidget("enable", smeBSBObjectClass
,
2023 XtAddCallback(enable
, XtNcallback
, EnableDeviceCallback
, NULL
);
2024 disable
= XtCreateManagedWidget("disable", smeBSBObjectClass
,
2026 XtAddCallback(disable
, XtNcallback
, DisableDeviceCallback
, NULL
);
2027 XtCreateManagedWidget("line", smeLineObjectClass
,
2029 remove
= XtCreateManagedWidget("remove", smeBSBObjectClass
,
2031 XtAddCallback(remove
, XtNcallback
, RemoveDeviceCallback
, NULL
);
2033 XtRealizeWidget(popup
);
2037 if (config_mode
== CONFIG_LAYOUT
) {
2038 for (i
= 0; i
< computer
.num_devices
; i
++)
2039 if (computer
.devices
[i
]->widget
== w
) {
2040 dev
= computer
.devices
[i
];
2043 if (i
>= computer
.num_devices
&& strcmp(XtName(w
), "cpu"))
2048 else if (config_mode
== CONFIG_SCREEN
) {
2049 for (i
= 0; i
< computer
.num_screens
; i
++)
2050 if (computer
.screens
[i
]->widget
== w
) {
2051 dev
= (xf86cfgDevice
*)computer
.screens
[i
];
2060 if (dev
->type
!= SERVER
) {
2061 XtSetSensitive(configure
, True
);
2062 XtSetSensitive(remove
, True
);
2063 XtSetSensitive(options
, dev
->config
!= NULL
);
2064 if (computer
.layout
== NULL
|| dev
->config
== NULL
||
2065 dev
->type
== MONITOR
) {
2066 XtSetSensitive(enable
, False
);
2067 XtSetSensitive(disable
, False
);
2069 else if (dev
->state
== USED
) {
2070 XtSetSensitive(enable
, False
);
2071 XtSetSensitive(disable
, True
);
2074 XtSetSensitive(enable
, True
);
2075 XtSetSensitive(disable
, False
);
2079 XtSetSensitive(configure
, False
);
2080 XtSetSensitive(options
, True
);
2081 XtSetSensitive(enable
, False
);
2082 XtSetSensitive(disable
, False
);
2083 XtSetSensitive(remove
, False
);
2086 XtMoveWidget(popup
, event
->xbutton
.x_root
, event
->xbutton
.y_root
);
2087 XtPopup(popup
, XtGrabNone
);
2092 DevicePopdownMenu(Widget w
, XEvent
*event
, String
*params
, Cardinal
*num_params
)
2094 if (popup
&& XtIsRealized(popup
))
2098 void RenameLayoutAction(Widget w
, XEvent
*event
,
2099 String
*params
, Cardinal
*num_params
)
2101 XF86ConfLayoutPtr lay
= XF86Config
->conf_layout_lst
;
2105 XtSetArg(args
[0], XtNstring
, &name
);
2106 XtGetValues(layout
, args
, 1);
2108 if (computer
.layout
== NULL
|| (computer
.layout
&&
2109 strcasecmp(name
, computer
.layout
->lay_identifier
)) == 0)
2112 if (name
== NULL
&& *name
== '\0') {
2113 /* tell user about error */
2118 if (strcasecmp(name
, lay
->lay_identifier
) == 0)
2119 /* tell user about error */
2121 lay
= (XF86ConfLayoutPtr
)(lay
->list
.next
);
2124 XtSetArg(args
[0], XtNlabel
, name
);
2125 XtSetValues(layoutsme
, args
, 1);
2126 xf86renameLayout(XF86Config
, computer
.layout
, name
);
2131 ComputerEventHandler(Widget w
, XtPointer closure
,
2132 XEvent
*event
, Boolean
*continue_to_dispatch
)
2134 if (event
->xexpose
.count
> 1)
2137 if (config_mode
== CONFIG_LAYOUT
)
2147 xf86cfgScreen
**scr
= computer
.screens
;
2149 if (config_mode
!= CONFIG_LAYOUT
)
2152 ox
= computer
.cpu
->core
.x
+ (computer
.cpu
->core
.width
>> 1);
2153 oy
= computer
.cpu
->core
.y
+ (computer
.cpu
->core
.height
>> 1);
2155 display
= XtDisplay(work
);
2156 window
= XtWindow(work
);
2157 XClearWindow(display
, window
);
2159 for (i
= 0; i
< computer
.num_devices
; i
++) {
2160 if (computer
.devices
[i
]->state
== USED
&&
2161 computer
.devices
[i
]->type
!= MONITOR
)
2162 DrawCable(display
, window
, ox
, oy
,
2163 computer
.devices
[i
]->widget
->core
.x
+
2164 (computer
.devices
[i
]->widget
->core
.width
>>1),
2165 computer
.devices
[i
]->widget
->core
.y
+
2166 (computer
.devices
[i
]->widget
->core
.height
>>1));
2169 for (i
= 0; i
< computer
.num_screens
; i
++) {
2170 if (scr
[i
]->monitor
!= NULL
)
2171 DrawCable(display
, window
,
2172 scr
[i
]->card
->widget
->core
.x
+
2173 (scr
[i
]->card
->widget
->core
.width
>>1),
2174 scr
[i
]->card
->widget
->core
.y
+
2175 (scr
[i
]->card
->widget
->core
.height
>>1),
2176 scr
[i
]->monitor
->widget
->core
.x
+
2177 (scr
[i
]->monitor
->widget
->core
.width
>>1),
2178 scr
[i
]->monitor
->widget
->core
.y
+
2179 (scr
[i
]->monitor
->widget
->core
.height
>>1));
2184 DrawCable(Display
*display
, Window window
, int o_x
, int o_y
, int d_x
, int d_y
)
2186 XDrawLine(display
, window
, cablegcshadow
, o_x
, o_y
, d_x
, d_y
);
2187 XDrawLine(display
, window
, cablegc
, o_x
, o_y
, d_x
, d_y
);
2192 SetConfigModeCallback(Widget w
, XtPointer user_data
, XtPointer call_data
)
2194 int i
, mode
= (long)user_data
;
2197 static Dimension height
;
2199 if (mode
== config_mode
)
2201 XtSetArg(args
[0], XtNlabel
, &ptr
);
2202 XtGetValues(w
, args
, 1);
2203 XtSetArg(args
[0], XtNlabel
, ptr
);
2204 XtSetValues(topMenu
, args
, 1);
2206 if (config_mode
== CONFIG_LAYOUT
) {
2207 XtSetArg(args
[0], XtNheight
, &height
);
2208 XtGetValues(commands
, args
, 1);
2209 for (i
= 0; i
< computer
.num_devices
; i
++)
2210 XtUnmapWidget(computer
.devices
[i
]->widget
);
2211 XtUnmapWidget(commands
);
2212 XtUnmapWidget(computer
.cpu
);
2213 XtSetSensitive(commands
, False
);
2214 XtSetArg(args
[0], XtNheight
, 1);
2215 XtSetArg(args
[1], XtNmin
, 1);
2216 XtSetArg(args
[2], XtNmax
, 1);
2217 XtSetValues(commands
, args
, 3);
2219 else if (config_mode
== CONFIG_SCREEN
) {
2220 for (i
= 0; i
< computer
.num_screens
; i
++)
2221 XtUnmapWidget(computer
.screens
[i
]->widget
);
2223 else if (config_mode
== CONFIG_MODELINE
) {
2224 VideoModeConfigureEnd();
2225 XtSetSensitive(layout
, True
);
2226 XtSetSensitive(layoutm
, True
);
2228 else if (config_mode
== CONFIG_ACCESSX
) {
2229 AccessXConfigureEnd();
2230 XtSetSensitive(layout
, True
);
2231 XtSetSensitive(layoutm
, True
);
2235 XClearWindow(XtDisplay(work
), XtWindow(work
));
2236 if (mode
== CONFIG_LAYOUT
) {
2237 for (i
= 0; i
< computer
.num_devices
; i
++)
2238 XtMapWidget(computer
.devices
[i
]->widget
);
2239 XtSetArg(args
[0], XtNheight
, height
);
2240 XtSetArg(args
[1], XtNmin
, height
);
2241 XtSetArg(args
[2], XtNmax
, height
);
2242 XtSetValues(commands
, args
, 3);
2243 XtMapWidget(commands
);
2244 XtMapWidget(computer
.cpu
);
2245 XtSetSensitive(commands
, True
);
2248 else if (mode
== CONFIG_SCREEN
) {
2249 for (i
= 0; i
< computer
.num_screens
; i
++)
2250 XtMapWidget(computer
.screens
[i
]->widget
);
2253 else if (mode
== CONFIG_MODELINE
) {
2254 VideoModeConfigureStart();
2255 XtSetSensitive(layout
, False
);
2256 XtSetSensitive(layoutm
, False
);
2258 else if (mode
== CONFIG_ACCESSX
) {
2259 AccessXConfigureStart();
2260 XtSetSensitive(layout
, False
);
2261 XtSetSensitive(layoutm
, False
);
2266 ScreenSetup(Bool check
)
2271 for (i
= 0; i
< computer
.num_layouts
; i
++)
2272 if (computer
.layouts
[i
]->layout
== computer
.layout
)
2275 /* Just to put the screens in the correct positions */
2276 if (i
>= computer
.num_layouts
)