summaryrefslogtreecommitdiff
path: root/hw/xfree86/utils/xorgcfg/config.h
blob: 62187b0d454d0fa18ced19aa60444b555c9086b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*
 * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *  
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 * Except as contained in this notice, the name of Conectiva Linux shall
 * not be used in advertising or otherwise to promote the sale, use or other
 * dealings in this Software without prior written authorization from
 * Conectiva Linux.
 *
 * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
 *
 */

#ifdef HAVE_CONFIG_H
# include "xorg-config.h"
#endif

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/SysUtil.h>
#include <X11/Xos.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#ifdef sun
#undef index
#undef rindex
#include <strings.h>
#endif
#include <unistd.h>

#include <stdarg.h>

#ifdef __UNIXOS2__
#define strcasecmp stricmp
#define setenv putenv
#define PATH_MAX 260
#endif

/* Get PATH_MAX */
#ifndef PATH_MAX
# if defined(_POSIX_SOURCE)
#  include <limits.h>
# else
#  define _POSIX_SOURCE
#  include <limits.h>
#  undef _POSIX_SOURCE
# endif
# ifndef PATH_MAX
#  ifdef MAXPATHLEN
#   define PATH_MAX MAXPATHLEN
#  else
#   define PATH_MAX 1024
#  endif
# endif
#endif

#include <xf86Parser.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBgeom.h>
#include <X11/extensions/XKM.h>
#include <X11/extensions/XKBfile.h>
#include <X11/extensions/XKBui.h>
#include <X11/extensions/XKBrules.h>

#ifndef _xf86cfg_config_h
#define _xf86cfg_config_h

/* Must match the offset in the xf86info structure at config.c,
 * and is used also by interface.c
 */
#define MOUSE			0
#define KEYBOARD		1
#define CARD			2
#define MONITOR			3
#define SCREEN			4
#define SERVER			5

#define	UNUSED			0
#define	USED			1

#define CONFIG_LAYOUT	0
#define CONFIG_SCREEN	1
#define CONFIG_MODELINE	2
#define CONFIG_ACCESSX	3
extern int config_mode;

#ifndef __UNIXOS2__
#define CONFPATH	"%A," "%R," \
			"/etc/X11/%R," "%P/etc/X11/%R," \
			"%E," "%F," \
			"/etc/X11/%F," "%P/etc/X11/%F," \
			"%D/%X," \
			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
			"%P/etc/X11/%X," \
			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
			"%P/lib/X11/%X"
#define USER_CONFPATH	"/etc/X11/%S," "%P/etc/X11/%S," \
                        "/etc/X11/%G," "%P/etc/X11/%G," \
			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
			"%P/etc/X11/%X," \
			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
			"%P/lib/X11/%X"
#else
#define CONFPATH	"%&"XF86CONFIGDIR"/%R," "%&"XF86CONFIGDIR"/%X," \
			"%A," "%R," \
			"/etc/X11/%R," "%P/etc/X11/%R," \
			"%E," "%F," \
			"/etc/X11/%F," "%P/etc/X11/%F," \
			"%D/%X," \
			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
			"%P/etc/X11/%X," \
			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
			"%P/lib/X11/%X"
#define USER_CONFPATH	"%&"XF86CONFIGDIR"/%X," "%&"XF86CONFIGDIR"/%X," \
			"/etc/X11/%S," "%P/etc/X11/%S," \
                        "/etc/X11/%G," "%P/etc/X11/%G," \
			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
			"%P/etc/X11/%X," \
			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
			"%P/lib/X11/%X"
#endif

/*
 * Types
 */
typedef struct _XF86SetupInfo XF86SetupInfo;
typedef void (*XF86SetupFunction)(XF86SetupInfo*);

typedef struct _XF86SetupFunctionList {
    XF86SetupFunction *functions;
    int num_functions;
    int cur_function;
} XF86SetupFunctionList;

struct _XF86SetupInfo {
    int num_lists;
    int cur_list;
    XF86SetupFunctionList *lists;
};

typedef Bool (*ConfigCheckFunction)(void);

typedef struct _xf86cfgDevice xf86cfgDevice;

struct _xf86cfgDevice {
    XtPointer config;
    Widget widget;
    int type, state, refcount;
};

typedef struct {
    XF86ConfScreenPtr screen;
    Widget widget;
    int type, state, refcount;
    xf86cfgDevice *card;
    xf86cfgDevice *monitor;
    short row, column;
    XRectangle rect;
    short rotate;
} xf86cfgScreen;

/* this structure is used just to restore
   properly the monitors layout in the
   screen window configuration.
 */
typedef struct {
    XF86ConfLayoutPtr layout;
    xf86cfgScreen **screen;
    XPoint *position;
    int num_layouts;
} xf86cfgLayout;

/* The vidmode extension usage is controlled by this structure.
 * The information is read at startup, and added monitors cannot
 * be configured, since they are not attached to a particular screen.
 */
typedef struct _xf86cfgVidMode xf86cfgVidmode;

typedef struct {
    XF86ConfLayoutPtr layout;	/* current layout */
    Widget cpu;
    xf86cfgLayout **layouts;
    Cardinal num_layouts;
    xf86cfgScreen **screens;
    Cardinal num_screens;
    xf86cfgDevice **devices;
    Cardinal num_devices;
    xf86cfgVidmode **vidmodes;
    Cardinal num_vidmodes;
} xf86cfgComputer;

/*
 * Prototypes
 */
void StartConfig(void);
Bool ConfigLoop(ConfigCheckFunction);
void ConfigError(void);
void ChangeScreen(XF86ConfMonitorPtr, XF86ConfMonitorPtr,
		  XF86ConfDevicePtr, XF86ConfDevicePtr);
void SetTip(xf86cfgDevice*);
Bool startx(void);
void endx(void);
void startaccessx(void);
void ConfigCancelAction(Widget, XEvent*, String*, Cardinal*);
void ExpertConfigureStart(void);
void ExpertConfigureEnd(void);
void ExpertCloseAction(Widget, XEvent*, String*, Cardinal*);
void ExpertCallback(Widget, XtPointer, XtPointer);

/*
 * Initialization
 */
extern Widget toplevel, configp, current, back, next;
extern XtAppContext appcon;
extern XF86SetupInfo xf86info;
extern Widget ident_widget;
extern char *ident_string;
extern XF86ConfigPtr XF86Config;
extern char *XF86Config_path;
extern char *XF86Module_path;
extern char *XFree86_path;
extern char *XF86Font_path;
extern char *XF86RGB_path;
extern char *XFree86Dir;
extern xf86cfgComputer computer;
extern Atom wm_delete_window;
extern Display *DPY;
extern Pixmap menuPixmap;
#ifdef USE_MODULES
extern int nomodules;
#endif

#endif /* _xf86cfg_config_h */