1 | /*
|
---|
2 | * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
|
---|
3 | *
|
---|
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:
|
---|
10 | *
|
---|
11 | * The above copyright notice and this permission notice shall be included in
|
---|
12 | * all copies or substantial portions of the Software.
|
---|
13 | *
|
---|
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
|
---|
20 | * SOFTWARE.
|
---|
21 | *
|
---|
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
|
---|
25 | * Conectiva Linux.
|
---|
26 | *
|
---|
27 | * Author: Paulo César Pereira de Andrade <[email protected]>
|
---|
28 | *
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifdef HAVE_CONFIG_H
|
---|
32 | # include "xorg-config.h"
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #include <X11/IntrinsicP.h>
|
---|
36 | #include <X11/StringDefs.h>
|
---|
37 | #include <X11/Xmu/SysUtil.h>
|
---|
38 | #include <X11/Xos.h>
|
---|
39 | #include <stdio.h>
|
---|
40 | #include <stdlib.h>
|
---|
41 | #include <dirent.h>
|
---|
42 | #include <string.h>
|
---|
43 | #ifdef sun
|
---|
44 | #undef index
|
---|
45 | #undef rindex
|
---|
46 | #include <strings.h>
|
---|
47 | #endif
|
---|
48 | #include <unistd.h>
|
---|
49 |
|
---|
50 | #include <stdarg.h>
|
---|
51 |
|
---|
52 | /* Get PATH_MAX */
|
---|
53 | #ifndef PATH_MAX
|
---|
54 | # if defined(_POSIX_SOURCE)
|
---|
55 | # include <limits.h>
|
---|
56 | # else
|
---|
57 | # define _POSIX_SOURCE
|
---|
58 | # include <limits.h>
|
---|
59 | # undef _POSIX_SOURCE
|
---|
60 | # endif
|
---|
61 | # ifndef PATH_MAX
|
---|
62 | # ifdef MAXPATHLEN
|
---|
63 | # define PATH_MAX MAXPATHLEN
|
---|
64 | # else
|
---|
65 | # define PATH_MAX 1024
|
---|
66 | # endif
|
---|
67 | # endif
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #include <xf86Parser.h>
|
---|
71 | #include <X11/XKBlib.h>
|
---|
72 | #include <X11/extensions/XKBgeom.h>
|
---|
73 | #include <X11/extensions/XKM.h>
|
---|
74 | #include <X11/extensions/XKBfile.h>
|
---|
75 | #include <X11/extensions/XKBui.h>
|
---|
76 | #include <X11/extensions/XKBrules.h>
|
---|
77 |
|
---|
78 | #ifndef _xf86cfg_config_h
|
---|
79 | #define _xf86cfg_config_h
|
---|
80 |
|
---|
81 | /* Must match the offset in the xf86info structure at config.c,
|
---|
82 | * and is used also by interface.c
|
---|
83 | */
|
---|
84 | #define MOUSE 0
|
---|
85 | #define KEYBOARD 1
|
---|
86 | #define CARD 2
|
---|
87 | #define MONITOR 3
|
---|
88 | #define SCREEN 4
|
---|
89 | #define SERVER 5
|
---|
90 |
|
---|
91 | #define UNUSED 0
|
---|
92 | #define USED 1
|
---|
93 |
|
---|
94 | #define CONFIG_LAYOUT 0
|
---|
95 | #define CONFIG_SCREEN 1
|
---|
96 | #define CONFIG_MODELINE 2
|
---|
97 | #define CONFIG_ACCESSX 3
|
---|
98 | extern int config_mode;
|
---|
99 |
|
---|
100 | #define CONFPATH "%A," "%R," \
|
---|
101 | "/etc/X11/%R," "%P/etc/X11/%R," \
|
---|
102 | "%E," "%F," \
|
---|
103 | "/etc/X11/%F," "%P/etc/X11/%F," \
|
---|
104 | "%D/%X," \
|
---|
105 | "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
|
---|
106 | "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
|
---|
107 | "%P/etc/X11/%X," \
|
---|
108 | "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
|
---|
109 | "%P/lib/X11/%X"
|
---|
110 | #define USER_CONFPATH "/etc/X11/%S," "%P/etc/X11/%S," \
|
---|
111 | "/etc/X11/%G," "%P/etc/X11/%G," \
|
---|
112 | "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
|
---|
113 | "%P/etc/X11/%X," \
|
---|
114 | "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
|
---|
115 | "%P/lib/X11/%X"
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * Types
|
---|
119 | */
|
---|
120 | typedef struct _XF86SetupInfo XF86SetupInfo;
|
---|
121 | typedef void (*XF86SetupFunction)(XF86SetupInfo*);
|
---|
122 |
|
---|
123 | typedef struct _XF86SetupFunctionList {
|
---|
124 | XF86SetupFunction *functions;
|
---|
125 | int num_functions;
|
---|
126 | int cur_function;
|
---|
127 | } XF86SetupFunctionList;
|
---|
128 |
|
---|
129 | struct _XF86SetupInfo {
|
---|
130 | int num_lists;
|
---|
131 | int cur_list;
|
---|
132 | XF86SetupFunctionList *lists;
|
---|
133 | };
|
---|
134 |
|
---|
135 | typedef Bool (*ConfigCheckFunction)(void);
|
---|
136 |
|
---|
137 | typedef struct _xf86cfgDevice xf86cfgDevice;
|
---|
138 |
|
---|
139 | struct _xf86cfgDevice {
|
---|
140 | XtPointer config;
|
---|
141 | Widget widget;
|
---|
142 | int type, state, refcount;
|
---|
143 | };
|
---|
144 |
|
---|
145 | typedef struct {
|
---|
146 | XF86ConfScreenPtr screen;
|
---|
147 | Widget widget;
|
---|
148 | int type, state, refcount;
|
---|
149 | xf86cfgDevice *card;
|
---|
150 | xf86cfgDevice *monitor;
|
---|
151 | short row, column;
|
---|
152 | XRectangle rect;
|
---|
153 | short rotate;
|
---|
154 | } xf86cfgScreen;
|
---|
155 |
|
---|
156 | /* this structure is used just to restore
|
---|
157 | properly the monitors layout in the
|
---|
158 | screen window configuration.
|
---|
159 | */
|
---|
160 | typedef struct {
|
---|
161 | XF86ConfLayoutPtr layout;
|
---|
162 | xf86cfgScreen **screen;
|
---|
163 | XPoint *position;
|
---|
164 | int num_layouts;
|
---|
165 | } xf86cfgLayout;
|
---|
166 |
|
---|
167 | /* The vidmode extension usage is controlled by this structure.
|
---|
168 | * The information is read at startup, and added monitors cannot
|
---|
169 | * be configured, since they are not attached to a particular screen.
|
---|
170 | */
|
---|
171 | typedef struct _xf86cfgVidMode xf86cfgVidmode;
|
---|
172 |
|
---|
173 | typedef struct {
|
---|
174 | XF86ConfLayoutPtr layout; /* current layout */
|
---|
175 | Widget cpu;
|
---|
176 | xf86cfgLayout **layouts;
|
---|
177 | Cardinal num_layouts;
|
---|
178 | xf86cfgScreen **screens;
|
---|
179 | Cardinal num_screens;
|
---|
180 | xf86cfgDevice **devices;
|
---|
181 | Cardinal num_devices;
|
---|
182 | xf86cfgVidmode **vidmodes;
|
---|
183 | Cardinal num_vidmodes;
|
---|
184 | } xf86cfgComputer;
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * Prototypes
|
---|
188 | */
|
---|
189 | void StartConfig(void);
|
---|
190 | Bool ConfigLoop(ConfigCheckFunction);
|
---|
191 | void ConfigError(void);
|
---|
192 | void ChangeScreen(XF86ConfMonitorPtr, XF86ConfMonitorPtr,
|
---|
193 | XF86ConfDevicePtr, XF86ConfDevicePtr);
|
---|
194 | void SetTip(xf86cfgDevice*);
|
---|
195 | Bool startx(void);
|
---|
196 | void endx(void);
|
---|
197 | void startaccessx(void);
|
---|
198 | void ConfigCancelAction(Widget, XEvent*, String*, Cardinal*);
|
---|
199 | void ExpertConfigureStart(void);
|
---|
200 | void ExpertConfigureEnd(void);
|
---|
201 | void ExpertCloseAction(Widget, XEvent*, String*, Cardinal*);
|
---|
202 | void ExpertCallback(Widget, XtPointer, XtPointer);
|
---|
203 |
|
---|
204 | /*
|
---|
205 | * Initialization
|
---|
206 | */
|
---|
207 | extern Widget toplevel, configp, current, back, next;
|
---|
208 | extern XtAppContext appcon;
|
---|
209 | extern XF86SetupInfo xf86info;
|
---|
210 | extern Widget ident_widget;
|
---|
211 | extern char *ident_string;
|
---|
212 | extern XF86ConfigPtr XF86Config;
|
---|
213 | extern char *XF86Config_path;
|
---|
214 | extern char *XF86Module_path;
|
---|
215 | extern char *XFree86_path;
|
---|
216 | extern char *XF86Font_path;
|
---|
217 | extern char *XF86RGB_path;
|
---|
218 | extern char *XFree86Dir;
|
---|
219 | extern xf86cfgComputer computer;
|
---|
220 | extern Atom wm_delete_window;
|
---|
221 | extern Display *DPY;
|
---|
222 | extern Pixmap menuPixmap;
|
---|
223 | #ifdef USE_MODULES
|
---|
224 | extern int nomodules;
|
---|
225 | #endif
|
---|
226 |
|
---|
227 | #endif /* _xf86cfg_config_h */
|
---|