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 | #ifdef __UNIXOS2__
|
---|
53 | #define strcasecmp stricmp
|
---|
54 | #define setenv putenv
|
---|
55 | #define PATH_MAX 260
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | /* Get PATH_MAX */
|
---|
59 | #ifndef PATH_MAX
|
---|
60 | # if defined(_POSIX_SOURCE)
|
---|
61 | # include <limits.h>
|
---|
62 | # else
|
---|
63 | # define _POSIX_SOURCE
|
---|
64 | # include <limits.h>
|
---|
65 | # undef _POSIX_SOURCE
|
---|
66 | # endif
|
---|
67 | # ifndef PATH_MAX
|
---|
68 | # ifdef MAXPATHLEN
|
---|
69 | # define PATH_MAX MAXPATHLEN
|
---|
70 | # else
|
---|
71 | # define PATH_MAX 1024
|
---|
72 | # endif
|
---|
73 | # endif
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | #include <xf86Parser.h>
|
---|
77 | #include <X11/XKBlib.h>
|
---|
78 | #include <X11/extensions/XKBgeom.h>
|
---|
79 | #include <X11/extensions/XKM.h>
|
---|
80 | #include <X11/extensions/XKBfile.h>
|
---|
81 | #include <X11/extensions/XKBui.h>
|
---|
82 | #include <X11/extensions/XKBrules.h>
|
---|
83 |
|
---|
84 | #ifndef _xf86cfg_config_h
|
---|
85 | #define _xf86cfg_config_h
|
---|
86 |
|
---|
87 | /* Must match the offset in the xf86info structure at config.c,
|
---|
88 | * and is used also by interface.c
|
---|
89 | */
|
---|
90 | #define MOUSE 0
|
---|
91 | #define KEYBOARD 1
|
---|
92 | #define CARD 2
|
---|
93 | #define MONITOR 3
|
---|
94 | #define SCREEN 4
|
---|
95 | #define SERVER 5
|
---|
96 |
|
---|
97 | #define UNUSED 0
|
---|
98 | #define USED 1
|
---|
99 |
|
---|
100 | #define CONFIG_LAYOUT 0
|
---|
101 | #define CONFIG_SCREEN 1
|
---|
102 | #define CONFIG_MODELINE 2
|
---|
103 | #define CONFIG_ACCESSX 3
|
---|
104 | extern int config_mode;
|
---|
105 |
|
---|
106 | #ifndef __UNIXOS2__
|
---|
107 | #define CONFPATH "%A," "%R," \
|
---|
108 | "/etc/X11/%R," "%P/etc/X11/%R," \
|
---|
109 | "%E," "%F," \
|
---|
110 | "/etc/X11/%F," "%P/etc/X11/%F," \
|
---|
111 | "%D/%X," \
|
---|
112 | "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
|
---|
113 | "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
|
---|
114 | "%P/etc/X11/%X," \
|
---|
115 | "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
|
---|
116 | "%P/lib/X11/%X"
|
---|
117 | #define USER_CONFPATH "/etc/X11/%S," "%P/etc/X11/%S," \
|
---|
118 | "/etc/X11/%G," "%P/etc/X11/%G," \
|
---|
119 | "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
|
---|
120 | "%P/etc/X11/%X," \
|
---|
121 | "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
|
---|
122 | "%P/lib/X11/%X"
|
---|
123 | #else
|
---|
124 | #define CONFPATH "%&"XF86CONFIGDIR"/%R," "%&"XF86CONFIGDIR"/%X," \
|
---|
125 | "%A," "%R," \
|
---|
126 | "/etc/X11/%R," "%P/etc/X11/%R," \
|
---|
127 | "%E," "%F," \
|
---|
128 | "/etc/X11/%F," "%P/etc/X11/%F," \
|
---|
129 | "%D/%X," \
|
---|
130 | "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
|
---|
131 | "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
|
---|
132 | "%P/etc/X11/%X," \
|
---|
133 | "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
|
---|
134 | "%P/lib/X11/%X"
|
---|
135 | #define USER_CONFPATH "%&"XF86CONFIGDIR"/%X," "%&"XF86CONFIGDIR"/%X," \
|
---|
136 | "/etc/X11/%S," "%P/etc/X11/%S," \
|
---|
137 | "/etc/X11/%G," "%P/etc/X11/%G," \
|
---|
138 | "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
|
---|
139 | "%P/etc/X11/%X," \
|
---|
140 | "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
|
---|
141 | "%P/lib/X11/%X"
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | /*
|
---|
145 | * Types
|
---|
146 | */
|
---|
147 | typedef struct _XF86SetupInfo XF86SetupInfo;
|
---|
148 | typedef void (*XF86SetupFunction)(XF86SetupInfo*);
|
---|
149 |
|
---|
150 | typedef struct _XF86SetupFunctionList {
|
---|
151 | XF86SetupFunction *functions;
|
---|
152 | int num_functions;
|
---|
153 | int cur_function;
|
---|
154 | } XF86SetupFunctionList;
|
---|
155 |
|
---|
156 | struct _XF86SetupInfo {
|
---|
157 | int num_lists;
|
---|
158 | int cur_list;
|
---|
159 | XF86SetupFunctionList *lists;
|
---|
160 | };
|
---|
161 |
|
---|
162 | typedef Bool (*ConfigCheckFunction)(void);
|
---|
163 |
|
---|
164 | typedef struct _xf86cfgDevice xf86cfgDevice;
|
---|
165 |
|
---|
166 | struct _xf86cfgDevice {
|
---|
167 | XtPointer config;
|
---|
168 | Widget widget;
|
---|
169 | int type, state, refcount;
|
---|
170 | };
|
---|
171 |
|
---|
172 | typedef struct {
|
---|
173 | XF86ConfScreenPtr screen;
|
---|
174 | Widget widget;
|
---|
175 | int type, state, refcount;
|
---|
176 | xf86cfgDevice *card;
|
---|
177 | xf86cfgDevice *monitor;
|
---|
178 | short row, column;
|
---|
179 | XRectangle rect;
|
---|
180 | short rotate;
|
---|
181 | } xf86cfgScreen;
|
---|
182 |
|
---|
183 | /* this structure is used just to restore
|
---|
184 | properly the monitors layout in the
|
---|
185 | screen window configuration.
|
---|
186 | */
|
---|
187 | typedef struct {
|
---|
188 | XF86ConfLayoutPtr layout;
|
---|
189 | xf86cfgScreen **screen;
|
---|
190 | XPoint *position;
|
---|
191 | int num_layouts;
|
---|
192 | } xf86cfgLayout;
|
---|
193 |
|
---|
194 | /* The vidmode extension usage is controlled by this structure.
|
---|
195 | * The information is read at startup, and added monitors cannot
|
---|
196 | * be configured, since they are not attached to a particular screen.
|
---|
197 | */
|
---|
198 | typedef struct _xf86cfgVidMode xf86cfgVidmode;
|
---|
199 |
|
---|
200 | typedef struct {
|
---|
201 | XF86ConfLayoutPtr layout; /* current layout */
|
---|
202 | Widget cpu;
|
---|
203 | xf86cfgLayout **layouts;
|
---|
204 | Cardinal num_layouts;
|
---|
205 | xf86cfgScreen **screens;
|
---|
206 | Cardinal num_screens;
|
---|
207 | xf86cfgDevice **devices;
|
---|
208 | Cardinal num_devices;
|
---|
209 | xf86cfgVidmode **vidmodes;
|
---|
210 | Cardinal num_vidmodes;
|
---|
211 | } xf86cfgComputer;
|
---|
212 |
|
---|
213 | /*
|
---|
214 | * Prototypes
|
---|
215 | */
|
---|
216 | void StartConfig(void);
|
---|
217 | Bool ConfigLoop(ConfigCheckFunction);
|
---|
218 | void ConfigError(void);
|
---|
219 | void ChangeScreen(XF86ConfMonitorPtr, XF86ConfMonitorPtr,
|
---|
220 | XF86ConfDevicePtr, XF86ConfDevicePtr);
|
---|
221 | void SetTip(xf86cfgDevice*);
|
---|
222 | Bool startx(void);
|
---|
223 | void endx(void);
|
---|
224 | void startaccessx(void);
|
---|
225 | void ConfigCancelAction(Widget, XEvent*, String*, Cardinal*);
|
---|
226 | void ExpertConfigureStart(void);
|
---|
227 | void ExpertConfigureEnd(void);
|
---|
228 | void ExpertCloseAction(Widget, XEvent*, String*, Cardinal*);
|
---|
229 | void ExpertCallback(Widget, XtPointer, XtPointer);
|
---|
230 |
|
---|
231 | /*
|
---|
232 | * Initialization
|
---|
233 | */
|
---|
234 | extern Widget toplevel, configp, current, back, next;
|
---|
235 | extern XtAppContext appcon;
|
---|
236 | extern XF86SetupInfo xf86info;
|
---|
237 | extern Widget ident_widget;
|
---|
238 | extern char *ident_string;
|
---|
239 | extern XF86ConfigPtr XF86Config;
|
---|
240 | extern char *XF86Config_path;
|
---|
241 | extern char *XF86Module_path;
|
---|
242 | extern char *XFree86_path;
|
---|
243 | extern char *XF86Font_path;
|
---|
244 | extern char *XF86RGB_path;
|
---|
245 | extern char *XFree86Dir;
|
---|
246 | extern xf86cfgComputer computer;
|
---|
247 | extern Atom wm_delete_window;
|
---|
248 | extern Display *DPY;
|
---|
249 | extern Pixmap menuPixmap;
|
---|
250 | #ifdef USE_MODULES
|
---|
251 | extern int nomodules;
|
---|
252 | #endif
|
---|
253 |
|
---|
254 | #endif /* _xf86cfg_config_h */
|
---|