InitialI.h revision 2265a131
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 87_XFUNCPROTOBEGIN 88 89typedef struct _TimerEventRec { 90 struct timeval te_timer_value; 91 struct _TimerEventRec *te_next; 92 XtTimerCallbackProc te_proc; 93 XtAppContext app; 94 XtPointer te_closure; 95} TimerEventRec; 96 97typedef struct _InputEvent { 98 XtInputCallbackProc ie_proc; 99 XtPointer ie_closure; 100 struct _InputEvent *ie_next; 101 struct _InputEvent *ie_oq; 102 XtAppContext app; 103 int ie_source; 104 XtInputMask ie_condition; 105} InputEvent; 106 107typedef struct _SignalEventRec { 108 XtSignalCallbackProc se_proc; 109 XtPointer se_closure; 110 struct _SignalEventRec *se_next; 111 XtAppContext app; 112 Boolean se_notice; 113} SignalEventRec; 114 115typedef struct _WorkProcRec { 116 XtWorkProc proc; 117 XtPointer closure; 118 struct _WorkProcRec *next; 119 XtAppContext app; 120} WorkProcRec; 121 122 123typedef struct 124{ 125#ifndef USE_POLL 126 fd_set rmask; 127 fd_set wmask; 128 fd_set emask; 129#endif 130 int nfds; 131} FdStruct; 132 133typedef struct _LangProcRec { 134 XtLanguageProc proc; 135 XtPointer closure; 136} LangProcRec; 137 138typedef struct _ProcessContextRec { 139 XtAppContext defaultAppContext; 140 XtAppContext appContextList; 141 ConverterTable globalConverterTable; 142 LangProcRec globalLangProcRec; 143} ProcessContextRec, *ProcessContext; 144 145typedef struct { 146 char* start; 147 char* current; 148 int bytes_remaining; 149} Heap; 150 151typedef struct _DestroyRec DestroyRec; 152 153 154typedef struct _XtAppStruct { 155 XtAppContext next; /* link to next app in process context */ 156 ProcessContext process; /* back pointer to our process context */ 157 InternalCallbackList destroy_callbacks; 158 Display **list; 159 TimerEventRec *timerQueue; 160 WorkProcRec *workQueue; 161 InputEvent **input_list; 162 InputEvent *outstandingQueue; 163 SignalEventRec *signalQueue; 164 XrmDatabase errorDB; 165 XtErrorMsgHandler errorMsgHandler, warningMsgHandler; 166 XtErrorHandler errorHandler, warningHandler; 167 struct _ActionListRec *action_table; 168 ConverterTable converterTable; 169 unsigned long selectionTimeout; 170 FdStruct fds; 171 short count; /* num of assigned entries in list */ 172 short max; /* allocate size of list */ 173 short last; 174 short input_count; 175 short input_max; /* elts input_list init'd with */ 176 Boolean sync, being_destroyed, error_inited; 177#ifndef NO_IDENTIFY_WINDOWS 178 Boolean identify_windows; /* debugging hack */ 179#endif 180 Heap heap; 181 String * fallback_resources; /* Set by XtAppSetFallbackResources. */ 182 struct _ActionHookRec* action_hook_list; 183 struct _BlockHookRec* block_hook_list; 184 int destroy_list_size; /* state data for 2-phase destroy */ 185 int destroy_count; 186 int dispatch_level; 187 DestroyRec* destroy_list; 188 Widget in_phase2_destroy; 189 LangProcRec langProcRec; 190 struct _TMBindCacheRec * free_bindings; 191 String display_name_tried; 192 Display **dpy_destroy_list; 193 int dpy_destroy_count; 194 Boolean exit_flag; 195 Boolean rebuild_fdlist; 196#ifdef XTHREADS 197 LockPtr lock_info; 198 ThreadAppProc lock; 199 ThreadAppProc unlock; 200 ThreadAppYieldLockProc yield_lock; 201 ThreadAppRestoreLockProc restore_lock; 202 ThreadAppProc free_lock; 203#endif 204} XtAppStruct; 205 206extern void _XtHeapInit(Heap* heap); 207extern void _XtHeapFree(Heap* heap); 208 209#ifdef XTTRACEMEMORY 210 211 212extern char *_XtHeapMalloc( 213 Heap* /* heap */, 214 Cardinal /* size */, 215 char * /* file */, 216 int /* line */ 217); 218 219#define _XtHeapAlloc(heap,bytes) _XtHeapMalloc(heap, bytes, __FILE__, __LINE__) 220 221#else /* XTTRACEMEMORY */ 222 223extern char* _XtHeapAlloc( 224 Heap* /* heap */, 225 Cardinal /* size */ 226); 227 228#endif /* XTTRACEMEMORY */ 229 230extern void _XtSetDefaultErrorHandlers( 231 XtErrorMsgHandler* /* errMsg */, 232 XtErrorMsgHandler* /* warnMsg */, 233 XtErrorHandler* /* err */, 234 XtErrorHandler* /* warn */ 235); 236 237extern void _XtSetDefaultSelectionTimeout( 238 unsigned long* /* timeout */ 239); 240 241extern XtAppContext _XtDefaultAppContext( 242 void 243); 244 245extern ProcessContext _XtGetProcessContext( 246 void 247); 248 249Display * 250_XtAppInit( 251 XtAppContext* /* app_context_return */, 252 String /* application_class */, 253 XrmOptionDescRec* /* options */, 254 Cardinal /* num_options */, 255 int* /* argc_in_out */, 256 String** /* argv_in_out */, 257 String* /* fallback_resources */ 258); 259 260extern void _XtDestroyAppContexts( 261 void 262); 263 264extern void _XtCloseDisplays( 265 XtAppContext /* app */ 266); 267 268extern int _XtAppDestroyCount; 269 270extern int _XtWaitForSomething( 271 XtAppContext /* app */, 272 _XtBoolean /* ignoreEvents */, 273 _XtBoolean /* ignoreTimers */, 274 _XtBoolean /* ignoreInputs */, 275 _XtBoolean /* ignoreSignals */, 276 _XtBoolean /* block */, 277#ifdef XTHREADS 278 _XtBoolean /* drop_lock */, 279#endif 280 unsigned long* /* howlong */ 281); 282 283typedef struct _CaseConverterRec *CaseConverterPtr; 284typedef struct _CaseConverterRec { 285 KeySym start; /* first KeySym valid in converter */ 286 KeySym stop; /* last KeySym valid in converter */ 287 XtCaseProc proc; /* case converter function */ 288 CaseConverterPtr next; /* next converter record */ 289} CaseConverterRec; 290 291typedef struct _ExtensionSelectorRec { 292 XtExtensionSelectProc proc; 293 int min, max; 294 XtPointer client_data; 295} ExtSelectRec; 296 297typedef struct _XtPerDisplayStruct { 298 InternalCallbackList destroy_callbacks; 299 Region region; 300 CaseConverterPtr case_cvt; /* user-registered case converters */ 301 XtKeyProc defaultKeycodeTranslator; 302 XtAppContext appContext; 303 unsigned long keysyms_serial; /* for tracking MappingNotify events */ 304 KeySym *keysyms; /* keycode to keysym table */ 305 int keysyms_per_keycode; /* number of keysyms for each keycode*/ 306 int min_keycode, max_keycode; /* range of keycodes */ 307 KeySym *modKeysyms; /* keysym values for modToKeysysm */ 308 ModToKeysymTable *modsToKeysyms; /* modifiers to Keysysms index table*/ 309 unsigned char isModifier[32]; /* key-is-modifier-p bit table */ 310 KeySym lock_meaning; /* Lock modifier meaning */ 311 Modifiers mode_switch; /* keyboard group modifiers */ 312 Modifiers num_lock; /* keyboard numlock modifiers */ 313 Boolean being_destroyed; 314 Boolean rv; /* reverse_video resource */ 315 XrmName name; /* resolved app name */ 316 XrmClass class; /* application class */ 317 Heap heap; 318 struct _GCrec *GClist; /* support for XtGetGC */ 319 Drawable **pixmap_tab; /* ditto for XtGetGC */ 320 String language; /* XPG language string */ 321 XEvent last_event; /* last event dispatched */ 322 Time last_timestamp; /* from last event dispatched */ 323 int multi_click_time; /* for XtSetMultiClickTime */ 324 struct _TMKeyContextRec* tm_context; /* for XtGetActionKeysym */ 325 InternalCallbackList mapping_callbacks; /* special case for TM */ 326 XtPerDisplayInputRec pdi; /* state for modal grabs & kbd focus */ 327 struct _WWTable *WWtable; /* window to widget table */ 328 XrmDatabase *per_screen_db; /* per screen resource databases */ 329 XrmDatabase cmd_db; /* db from command line, if needed */ 330 XrmDatabase server_db; /* resource property else .Xdefaults */ 331 XtEventDispatchProc* dispatcher_list; 332 ExtSelectRec* ext_select_list; 333 int ext_select_count; 334 Widget hook_object; 335#ifndef X_NO_RESOURCE_CONFIGURATION_MANAGEMENT 336 Atom rcm_init; /* ResConfig - initialize */ 337 Atom rcm_data; /* ResConfig - data atom */ 338#endif 339} XtPerDisplayStruct, *XtPerDisplay; 340 341typedef struct _PerDisplayTable { 342 Display *dpy; 343 XtPerDisplayStruct perDpy; 344 struct _PerDisplayTable *next; 345} PerDisplayTable, *PerDisplayTablePtr; 346 347extern PerDisplayTablePtr _XtperDisplayList; 348 349extern XtPerDisplay _XtSortPerDisplayList( 350 Display* /* dpy */ 351); 352 353extern XtPerDisplay _XtGetPerDisplay( 354 Display* /* dpy */ 355); 356 357extern XtPerDisplayInputRec* _XtGetPerDisplayInput( 358 Display* /* dpy */ 359); 360 361#if 0 362#ifdef DEBUG 363#define _XtGetPerDisplay(display) \ 364 ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \ 365 ? &_XtperDisplayList->perDpy \ 366 : _XtSortPerDisplayList(display)) 367#define _XtGetPerDisplayInput(display) \ 368 ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \ 369 ? &_XtperDisplayList->perDpy.pdi \ 370 : &_XtSortPerDisplayList(display)->pdi) 371#else 372#define _XtGetPerDisplay(display) \ 373 ((_XtperDisplayList->dpy == (display)) \ 374 ? &_XtperDisplayList->perDpy \ 375 : _XtSortPerDisplayList(display)) 376#define _XtGetPerDisplayInput(display) \ 377 ((_XtperDisplayList->dpy == (display)) \ 378 ? &_XtperDisplayList->perDpy.pdi \ 379 : &_XtSortPerDisplayList(display)->pdi) 380#endif /*DEBUG*/ 381#endif 382 383extern void _XtDisplayInitialize( 384 Display* /* dpy */, 385 XtPerDisplay /* pd */, 386 _Xconst char* /* name */, 387 XrmOptionDescRec* /* urlist */, 388 Cardinal /* num_urs */, 389 int* /* argc */, 390 char** /* argv */ 391); 392 393extern void _XtCacheFlushTag( 394 XtAppContext /* app */, 395 XtPointer /* tag */ 396); 397 398extern void _XtFreeActions( 399 struct _ActionListRec* /* action_table */ 400); 401 402extern void _XtDoPhase2Destroy( 403 XtAppContext /* app */, 404 int /* dispatch_level */ 405); 406 407extern void _XtDoFreeBindings( 408 XtAppContext /* app */ 409); 410 411extern void _XtExtensionSelect( 412 Widget /* widget */ 413); 414 415#define _XtSafeToDestroy(app) ((app)->dispatch_level == 0) 416 417extern void _XtAllocWWTable( 418 XtPerDisplay pd 419); 420 421extern void _XtFreeWWTable( 422 XtPerDisplay pd 423); 424 425extern String _XtGetUserName(String dest, int len); 426extern XrmDatabase _XtPreparseCommandLine(XrmOptionDescRec *urlist, 427 Cardinal num_urs, int argc, String *argv, 428 String *applName, String *displayName, 429 String *language); 430 431_XFUNCPROTOEND 432 433#endif /* _XtinitialI_h */ 434