InitialI.h revision 444c061a
1/* $Xorg: InitialI.h,v 1.4 2001/02/09 02:03:55 xorgcvs Exp $ */
2
3/***********************************************************
4
5Copyright 1987, 1988, 1994, 1998  The Open Group
6
7Permission to use, copy, modify, distribute, and sell this software and its
8documentation for any purpose is hereby granted without fee, provided that
9the above copyright notice appear in all copies and that both that
10copyright notice and this permission notice appear in supporting
11documentation.
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from The Open Group.
26
27
28Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30                        All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49/* $XFree86: xc/lib/Xt/InitialI.h,v 3.10 2001/12/14 19:56:18 dawes Exp $ */
50
51#ifndef _XtinitialI_h
52#define _XtinitialI_h
53
54/****************************************************************
55 *
56 * Displays
57 *
58 ****************************************************************/
59
60#ifndef X_NOT_POSIX
61#ifdef _POSIX_SOURCE
62#include <limits.h>
63#else
64#define _POSIX_SOURCE
65#include <limits.h>
66#undef _POSIX_SOURCE
67#endif
68#endif
69#ifndef PATH_MAX
70#ifdef WIN32
71#define PATH_MAX 512
72#else
73#include <sys/param.h>
74#endif
75#ifndef PATH_MAX
76#ifdef MAXPATHLEN
77#define PATH_MAX MAXPATHLEN
78#else
79#define PATH_MAX 1024
80#endif
81#endif
82#endif
83
84#include <X11/Xos.h>
85#include <X11/Xpoll.h>
86
87typedef struct _TimerEventRec {
88        struct timeval        te_timer_value;
89	struct _TimerEventRec *te_next;
90	XtTimerCallbackProc   te_proc;
91	XtAppContext	      app;
92	XtPointer	      te_closure;
93} TimerEventRec;
94
95typedef struct _InputEvent {
96	XtInputCallbackProc   ie_proc;
97	XtPointer	      ie_closure;
98	struct _InputEvent    *ie_next;
99	struct _InputEvent    *ie_oq;
100	XtAppContext	      app;
101	int		      ie_source;
102	XtInputMask	      ie_condition;
103} InputEvent;
104
105typedef struct _SignalEventRec {
106	XtSignalCallbackProc  se_proc;
107	XtPointer	      se_closure;
108	struct _SignalEventRec *se_next;
109	XtAppContext	      app;
110	Boolean		      se_notice;
111} SignalEventRec;
112
113typedef struct _WorkProcRec {
114	XtWorkProc proc;
115	XtPointer closure;
116	struct _WorkProcRec *next;
117	XtAppContext app;
118} WorkProcRec;
119
120
121typedef struct
122{
123#ifndef USE_POLL
124  	fd_set rmask;
125	fd_set wmask;
126	fd_set emask;
127#endif
128	int	nfds;
129} FdStruct;
130
131typedef struct _LangProcRec {
132    XtLanguageProc	proc;
133    XtPointer		closure;
134} LangProcRec;
135
136typedef struct _ProcessContextRec {
137    XtAppContext	defaultAppContext;
138    XtAppContext	appContextList;
139    ConverterTable	globalConverterTable;
140    LangProcRec		globalLangProcRec;
141} ProcessContextRec, *ProcessContext;
142
143typedef struct {
144    char*	start;
145    char*	current;
146    int		bytes_remaining;
147} Heap;
148
149typedef struct _DestroyRec DestroyRec;
150
151
152typedef struct _XtAppStruct {
153    XtAppContext next;		/* link to next app in process context */
154    ProcessContext process;	/* back pointer to our process context */
155    InternalCallbackList destroy_callbacks;
156    Display **list;
157    TimerEventRec *timerQueue;
158    WorkProcRec *workQueue;
159    InputEvent **input_list;
160    InputEvent *outstandingQueue;
161    SignalEventRec *signalQueue;
162    XrmDatabase errorDB;
163    XtErrorMsgHandler errorMsgHandler, warningMsgHandler;
164    XtErrorHandler errorHandler, warningHandler;
165    struct _ActionListRec *action_table;
166    ConverterTable converterTable;
167    unsigned long selectionTimeout;
168    FdStruct fds;
169    short count;			/* num of assigned entries in list */
170    short max;				/* allocate size of list */
171    short last;
172    short input_count;
173    short input_max;			/* elts input_list init'd with */
174    Boolean sync, being_destroyed, error_inited;
175#ifndef NO_IDENTIFY_WINDOWS
176    Boolean identify_windows;		/* debugging hack */
177#endif
178    Heap heap;
179    String * fallback_resources;	/* Set by XtAppSetFallbackResources. */
180    struct _ActionHookRec* action_hook_list;
181    struct _BlockHookRec* block_hook_list;
182    int destroy_list_size;		/* state data for 2-phase destroy */
183    int destroy_count;
184    int dispatch_level;
185    DestroyRec* destroy_list;
186    Widget in_phase2_destroy;
187    LangProcRec langProcRec;
188    struct _TMBindCacheRec * free_bindings;
189    String display_name_tried;
190    Display **dpy_destroy_list;
191    int dpy_destroy_count;
192    Boolean exit_flag;
193    Boolean rebuild_fdlist;
194#ifdef XTHREADS
195    LockPtr lock_info;
196    ThreadAppProc lock;
197    ThreadAppProc unlock;
198    ThreadAppYieldLockProc yield_lock;
199    ThreadAppRestoreLockProc restore_lock;
200    ThreadAppProc free_lock;
201#endif
202} XtAppStruct;
203
204extern void _XtHeapInit(Heap* heap);
205extern void _XtHeapFree(Heap* heap);
206
207#ifdef XTTRACEMEMORY
208
209
210extern char *_XtHeapMalloc(
211    Heap*	/* heap */,
212    Cardinal	/* size */,
213    char *	/* file */,
214    int		/* line */
215);
216
217#define _XtHeapAlloc(heap,bytes) _XtHeapMalloc(heap, bytes, __FILE__, __LINE__)
218
219#else /* XTTRACEMEMORY */
220
221extern char* _XtHeapAlloc(
222    Heap*	/* heap */,
223    Cardinal	/* size */
224);
225
226#endif /* XTTRACEMEMORY */
227
228extern void _XtSetDefaultErrorHandlers(
229    XtErrorMsgHandler*	/* errMsg */,
230    XtErrorMsgHandler*	/* warnMsg */,
231    XtErrorHandler*	/* err */,
232    XtErrorHandler*	/* warn */
233);
234
235extern void _XtSetDefaultSelectionTimeout(
236    unsigned long* /* timeout */
237);
238
239extern XtAppContext _XtDefaultAppContext(
240    void
241);
242
243extern ProcessContext _XtGetProcessContext(
244    void
245);
246
247Display *
248_XtAppInit(
249    XtAppContext*	/* app_context_return */,
250    String		/* application_class */,
251    XrmOptionDescRec*	/* options */,
252    Cardinal		/* num_options */,
253    int*		/* argc_in_out */,
254    String**		/* argv_in_out */,
255    String*		/* fallback_resources */
256);
257
258extern void _XtDestroyAppContexts(
259    void
260);
261
262extern void _XtCloseDisplays(
263    XtAppContext	/* app */
264);
265
266extern int _XtAppDestroyCount;
267
268extern int _XtWaitForSomething(
269    XtAppContext	/* app */,
270    _XtBoolean 		/* ignoreEvents */,
271    _XtBoolean 		/* ignoreTimers */,
272    _XtBoolean 		/* ignoreInputs */,
273    _XtBoolean		/* ignoreSignals */,
274    _XtBoolean 		/* block */,
275#ifdef XTHREADS
276    _XtBoolean		/* drop_lock */,
277#endif
278    unsigned long*	/* howlong */
279);
280
281typedef struct _CaseConverterRec *CaseConverterPtr;
282typedef struct _CaseConverterRec {
283    KeySym		start;		/* first KeySym valid in converter */
284    KeySym		stop;		/* last KeySym valid in converter */
285    XtCaseProc		proc;		/* case converter function */
286    CaseConverterPtr	next;		/* next converter record */
287} CaseConverterRec;
288
289typedef struct _ExtensionSelectorRec {
290    XtExtensionSelectProc proc;
291    int min, max;
292    XtPointer client_data;
293} ExtSelectRec;
294
295typedef struct _XtPerDisplayStruct {
296    InternalCallbackList destroy_callbacks;
297    Region region;
298    CaseConverterPtr case_cvt;		/* user-registered case converters */
299    XtKeyProc defaultKeycodeTranslator;
300    XtAppContext appContext;
301    unsigned long keysyms_serial;      /* for tracking MappingNotify events */
302    KeySym *keysyms;                   /* keycode to keysym table */
303    int keysyms_per_keycode;           /* number of keysyms for each keycode*/
304    int min_keycode, max_keycode;      /* range of keycodes */
305    KeySym *modKeysyms;                /* keysym values for modToKeysysm */
306    ModToKeysymTable *modsToKeysyms;   /* modifiers to Keysysms index table*/
307    unsigned char isModifier[32];      /* key-is-modifier-p bit table */
308    KeySym lock_meaning;	       /* Lock modifier meaning */
309    Modifiers mode_switch;	       /* keyboard group modifiers */
310    Modifiers num_lock;		       /* keyboard numlock modifiers */
311    Boolean being_destroyed;
312    Boolean rv;			       /* reverse_video resource */
313    XrmName name;		       /* resolved app name */
314    XrmClass class;		       /* application class */
315    Heap heap;
316    struct _GCrec *GClist;	       /* support for XtGetGC */
317    Drawable **pixmap_tab;             /* ditto for XtGetGC */
318    String language;		       /* XPG language string */
319    XEvent last_event;		       /* last event dispatched */
320    Time last_timestamp;	       /* from last event dispatched */
321    int multi_click_time;	       /* for XtSetMultiClickTime */
322    struct _TMKeyContextRec* tm_context;     /* for XtGetActionKeysym */
323    InternalCallbackList mapping_callbacks;  /* special case for TM */
324    XtPerDisplayInputRec pdi;	       /* state for modal grabs & kbd focus */
325    struct _WWTable *WWtable;	       /* window to widget table */
326    XrmDatabase *per_screen_db;        /* per screen resource databases */
327    XrmDatabase cmd_db;		       /* db from command line, if needed */
328    XrmDatabase server_db;	       /* resource property else .Xdefaults */
329    XtEventDispatchProc* dispatcher_list;
330    ExtSelectRec* ext_select_list;
331    int ext_select_count;
332    Widget hook_object;
333#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT
334    Atom rcm_init;			/* ResConfig - initialize */
335    Atom rcm_data;			/* ResConfig - data atom */
336#endif
337} XtPerDisplayStruct, *XtPerDisplay;
338
339typedef struct _PerDisplayTable {
340	Display *dpy;
341	XtPerDisplayStruct perDpy;
342	struct _PerDisplayTable *next;
343} PerDisplayTable, *PerDisplayTablePtr;
344
345extern PerDisplayTablePtr _XtperDisplayList;
346
347extern XtPerDisplay _XtSortPerDisplayList(
348    Display* /* dpy */
349);
350
351extern XtPerDisplay _XtGetPerDisplay(
352    Display*		/* dpy */
353);
354
355extern XtPerDisplayInputRec* _XtGetPerDisplayInput(
356    Display* 		/* dpy */
357);
358
359#if 0
360#ifdef DEBUG
361#define _XtGetPerDisplay(display) \
362    ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
363     ? &_XtperDisplayList->perDpy \
364     : _XtSortPerDisplayList(display))
365#define _XtGetPerDisplayInput(display) \
366    ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
367     ? &_XtperDisplayList->perDpy.pdi \
368     : &_XtSortPerDisplayList(display)->pdi)
369#else
370#define _XtGetPerDisplay(display) \
371    ((_XtperDisplayList->dpy == (display)) \
372     ? &_XtperDisplayList->perDpy \
373     : _XtSortPerDisplayList(display))
374#define _XtGetPerDisplayInput(display) \
375    ((_XtperDisplayList->dpy == (display)) \
376     ? &_XtperDisplayList->perDpy.pdi \
377     : &_XtSortPerDisplayList(display)->pdi)
378#endif /*DEBUG*/
379#endif
380
381extern void _XtDisplayInitialize(
382    Display*		/* dpy */,
383    XtPerDisplay	/* pd */,
384    _Xconst char*	/* name */,
385    XrmOptionDescRec*	/* urlist */,
386    Cardinal 		/* num_urs */,
387    int*		/* argc */,
388    char** 		/* argv */
389);
390
391extern void _XtCacheFlushTag(
392    XtAppContext /* app */,
393    XtPointer	 /* tag */
394);
395
396extern void _XtFreeActions(
397    struct _ActionListRec* /* action_table */
398);
399
400extern void _XtDoPhase2Destroy(
401    XtAppContext /* app */,
402    int		 /* dispatch_level */
403);
404
405extern void _XtDoFreeBindings(
406    XtAppContext /* app */
407);
408
409extern void _XtExtensionSelect(
410    Widget /* widget */
411);
412
413#define _XtSafeToDestroy(app) ((app)->dispatch_level == 0)
414
415extern void _XtAllocWWTable(
416    XtPerDisplay pd
417);
418
419extern void _XtFreeWWTable(
420    XtPerDisplay pd
421);
422
423extern String _XtGetUserName(String dest, int len);
424extern XrmDatabase _XtPreparseCommandLine(XrmOptionDescRec *urlist,
425			Cardinal num_urs, int argc, String *argv,
426			String *applName, String *displayName,
427			String *language);
428
429#endif /* _XtinitialI_h */
430