home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xt / InitialI.h.orig < prev    next >
Encoding:
Text File  |  1991-07-12  |  9.9 KB  |  357 lines

  1. /* $XConsortium: InitialI.h,v 1.61 91/07/12 12:33:51 rws Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  5. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.                         All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its 
  10. documentation for any purpose and without fee is hereby granted, 
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in 
  13. supporting documentation, and that the names of Digital or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.  
  16.  
  17. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ******************************************************************/
  26.  
  27. /****************************************************************
  28.  *
  29.  * Displays
  30.  *
  31.  ****************************************************************/
  32.  
  33. #ifndef X_NOT_POSIX
  34. #ifdef _POSIX_SOURCE
  35. #include <limits.h>
  36. #else
  37. #define _POSIX_SOURCE
  38. #include <limits.h>
  39. #undef _POSIX_SOURCE
  40. #endif
  41. #endif
  42. #ifndef PATH_MAX
  43. #include <sys/param.h>
  44. #ifdef MAXPATHLEN
  45. #define PATH_MAX MAXPATHLEN
  46. #else
  47. #define PATH_MAX 1024
  48. #endif
  49. #endif
  50.  
  51. #ifndef MAX
  52. #define MAX(a,b) (((a) > (b)) ? (a) : (b))
  53. #endif
  54.  
  55. #ifndef MIN
  56. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  57. #endif
  58.  
  59. #include "fd.h"
  60.  
  61. typedef struct _TimerEventRec {
  62.         struct timeval        te_timer_value;
  63.     struct _TimerEventRec *te_next;
  64.     Display              *te_dpy;
  65.     XtTimerCallbackProc   te_proc;
  66.     XtAppContext          app;
  67.     XtPointer          te_closure;
  68. } TimerEventRec;
  69.  
  70. typedef struct _InputEvent {
  71.     XtInputCallbackProc   ie_proc;
  72.     XtPointer          ie_closure;
  73.     struct _InputEvent    *ie_next;
  74.     struct _InputEvent    *ie_oq;
  75.     XtAppContext          app;
  76.     int              ie_source;
  77.     XtInputMask          ie_condition;
  78. } InputEvent;
  79.  
  80. typedef struct _WorkProcRec {
  81.     XtWorkProc proc;
  82.     XtPointer closure;
  83.     struct _WorkProcRec *next;
  84.     XtAppContext app;
  85. } WorkProcRec;
  86.  
  87.  
  88. typedef struct 
  89. {
  90.       Fd_set rmask;
  91.     Fd_set wmask;
  92.     Fd_set emask;
  93.     int    nfds;
  94.     int    count;
  95. } FdStruct;
  96.  
  97. typedef struct _LangProcRec {
  98.     XtLanguageProc    proc;
  99.     XtPointer        closure;
  100. } LangProcRec;
  101.  
  102. typedef struct _ProcessContextRec {
  103.     XtAppContext    defaultAppContext;
  104.     XtAppContext    appContextList;
  105.     ConverterTable    globalConverterTable;
  106.     LangProcRec        globalLangProcRec;
  107. } ProcessContextRec, *ProcessContext;
  108.  
  109. typedef struct {
  110.     char*    start;
  111.     char*    current;
  112.     int        bytes_remaining;
  113. } Heap;
  114.  
  115. typedef struct _DestroyRec DestroyRec;
  116.  
  117. typedef struct _XtAppStruct {
  118.     XtAppContext next;        /* link to next app in process context */
  119.     ProcessContext process;    /* back pointer to our process context */
  120.     InternalCallbackList destroy_callbacks;
  121.     Display **list;
  122.     TimerEventRec *timerQueue;
  123.     WorkProcRec *workQueue;
  124.     InputEvent **input_list;
  125.     InputEvent *outstandingQueue;
  126.     XrmDatabase errorDB;
  127.     XtErrorMsgHandler errorMsgHandler, warningMsgHandler;
  128.     XtErrorHandler errorHandler, warningHandler;
  129.     struct _ActionListRec *action_table;
  130.     ConverterTable converterTable;
  131.     unsigned long selectionTimeout;
  132.     FdStruct fds;
  133.     short count;            /* num of assigned entries in list */
  134.     short max;                /* allocate size of list */
  135.     short last;
  136.     short input_max;            /* elts input_list init'd with */
  137.     Boolean sync, being_destroyed, error_inited;
  138. #ifndef NO_IDENTIFY_WINDOWS
  139.     Boolean identify_windows;        /* debugging hack */
  140. #endif
  141.     Heap heap;
  142.     String * fallback_resources;    /* Set by XtAppSetFallbackResources. */
  143.     struct _ActionHookRec* action_hook_list;
  144.     int destroy_list_size;        /* state data for 2-phase destroy */
  145.     int destroy_count;
  146.     int dispatch_level;
  147.     DestroyRec* destroy_list;
  148.     Widget in_phase2_destroy;
  149.     LangProcRec langProcRec;
  150. } XtAppStruct;
  151.  
  152. #ifdef XTTRACEMEMORY
  153.  
  154.  
  155. extern char *_XtHeapMalloc(
  156. #if NeedFunctionPrototypes
  157.     Heap*    /* heap */,
  158.     Cardinal    /* size */,
  159.     char *    /* file */,
  160.     int        /* line */
  161. #endif
  162. );
  163.  
  164. #define _XtHeapAlloc(heap,bytes) _XtHeapMalloc(heap, bytes, __FILE__, __LINE__)
  165.  
  166. #else /* XTTRACEMEMORY */
  167.  
  168. extern char* _XtHeapAlloc(
  169. #if NeedFunctionPrototypes
  170.     Heap*    /* heap */,
  171.     Cardinal    /* size */
  172. #endif
  173. );
  174.  
  175. #endif /* XTTRACEMEMORY */
  176.  
  177. extern void _XtSetDefaultErrorHandlers(
  178. #if NeedFunctionPrototypes
  179.     XtErrorMsgHandler*    /* errMsg */,
  180.     XtErrorMsgHandler*    /* warnMsg */,
  181.     XtErrorHandler*    /* err */,
  182.     XtErrorHandler*    /* warn */
  183. #endif
  184. );
  185.  
  186. extern void _XtSetDefaultSelectionTimeout(
  187. #if NeedFunctionPrototypes
  188.     unsigned long* /* timeout */
  189. #endif
  190. );
  191.  
  192. extern XtAppContext _XtDefaultAppContext(
  193. #if NeedFunctionPrototypes
  194.     void
  195. #endif
  196. );
  197.  
  198. extern ProcessContext _XtGetProcessContext(
  199. #if NeedFunctionPrototypes
  200.     void
  201. #endif
  202. );
  203.  
  204. Display *
  205. _XtAppInit(
  206. #if NeedFunctionPrototypes
  207.     XtAppContext*    /* app_context_return */,
  208.     String        /* application_class */,
  209.     XrmOptionDescRec*    /* options */,
  210.     Cardinal        /* num_options */,
  211.     int*        /* argc_in_out */,
  212.     String**        /* argv_in_out */,
  213.     String*        /* fallback_resources */
  214. #endif
  215. );
  216.  
  217. extern void _XtDestroyAppContexts(
  218. #if NeedFunctionPrototypes
  219.     void
  220. #endif
  221. );
  222.  
  223. extern void _XtCloseDisplays(
  224. #if NeedFunctionPrototypes
  225.     void
  226. #endif
  227. );
  228.  
  229. extern int _XtAppDestroyCount;
  230. extern int _XtDpyDestroyCount;
  231.  
  232. extern int _XtwaitForSomething(
  233. #if NeedFunctionPrototypes
  234.     _XtBoolean         /* ignoreTimers */,
  235.     _XtBoolean         /* ignoreInputs */,
  236.     _XtBoolean         /* ignoreEvents */,
  237.     _XtBoolean         /* block */,
  238.     unsigned long*    /* howlong */,
  239.     XtAppContext     /* app */
  240. #endif
  241. );
  242.  
  243. typedef struct _CaseConverterRec *CaseConverterPtr;
  244. typedef struct _CaseConverterRec {
  245.     KeySym        start;        /* first KeySym valid in converter */
  246.     KeySym        stop;        /* last KeySym valid in converter */
  247.     XtCaseProc        proc;        /* case converter function */
  248.     CaseConverterPtr    next;        /* next converter record */
  249. } CaseConverterRec;
  250.  
  251. typedef struct _XtPerDisplayStruct {
  252.     InternalCallbackList destroy_callbacks;
  253.     Region region;
  254.     CaseConverterPtr case_cvt;        /* user-registered case converters */
  255.     XtKeyProc defaultKeycodeTranslator;
  256.     XtAppContext appContext;
  257.     unsigned long keysyms_serial;      /* for tracking MappingNotify events */
  258.     KeySym *keysyms;                   /* keycode to keysym table */
  259.     int keysyms_per_keycode;           /* number of keysyms for each keycode*/
  260.     int min_keycode, max_keycode;      /* range of keycodes */
  261.     KeySym *modKeysyms;                /* keysym values for modToKeysysm */
  262.     ModToKeysymTable *modsToKeysyms;   /* modifiers to Keysysms index table*/
  263.     unsigned char isModifier[32];      /* key-is-modifier-p bit table */
  264.     KeySym lock_meaning;           /* Lock modifier meaning */
  265.     Modifiers mode_switch;           /* keyboard group modifiers */
  266.     Boolean being_destroyed;
  267.     Boolean rv;                   /* reverse_video resource */
  268.     XrmName name;               /* resolved app name */
  269.     XrmClass class;               /* application class */
  270.     Heap heap;
  271.     struct _GCrec *GClist;           /* support for XtGetGC */
  272.     Drawable **pixmap_tab;             /* ditto for XtGetGC */
  273.     String language;               /* XPG language string */
  274.     Time last_timestamp;           /* from last event dispatched */
  275.     int multi_click_time;           /* for XtSetMultiClickTime */
  276.     struct _TMKeyContextRec* tm_context;     /* for XtGetActionKeysym */
  277.     InternalCallbackList mapping_callbacks;  /* special case for TM */
  278.     XtPerDisplayInputRec pdi;           /* state for modal grabs & kbd focus */
  279.     struct _WWTable *WWtable;           /* window to widget table */
  280.     XrmDatabase *per_screen_db;        /* per screen resource databases */
  281.     XrmDatabase cmd_db;               /* db from command line, if needed */
  282.     XrmDatabase server_db;           /* resource property else .Xdefaults */
  283. } XtPerDisplayStruct, *XtPerDisplay;
  284.  
  285. typedef struct _PerDisplayTable {
  286.     Display *dpy;
  287.     XtPerDisplayStruct perDpy;
  288.     struct _PerDisplayTable *next;
  289. } PerDisplayTable, *PerDisplayTablePtr;
  290.  
  291. extern PerDisplayTablePtr _XtperDisplayList;
  292.  
  293. extern XtPerDisplay _XtSortPerDisplayList(
  294. #if NeedFunctionPrototypes
  295.     Display* /* dpy */
  296. #endif
  297. );
  298.  
  299. /*
  300. extern XtPerDisplay _XtGetPerDisplay( Display* );
  301. extern XtPerDisplayInputRec* _XtGetPerDisplayInput( Display* );
  302. */
  303.  
  304. #ifdef DEBUG
  305. #define _XtGetPerDisplay(display) \
  306.     ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
  307.      ? &_XtperDisplayList->perDpy \
  308.      : _XtSortPerDisplayList(display))
  309. #define _XtGetPerDisplayInput(display) \
  310.     ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
  311.      ? &_XtperDisplayList->perDpy.pdi \
  312.      : &_XtSortPerDisplayList(display)->pdi)
  313. #else
  314. #define _XtGetPerDisplay(display) \
  315.     ((_XtperDisplayList->dpy == (display)) \
  316.      ? &_XtperDisplayList->perDpy \
  317.      : _XtSortPerDisplayList(display))
  318. #define _XtGetPerDisplayInput(display) \
  319.     ((_XtperDisplayList->dpy == (display)) \
  320.      ? &_XtperDisplayList->perDpy.pdi \
  321.      : &_XtSortPerDisplayList(display)->pdi)
  322. #endif /*DEBUG*/
  323.  
  324. extern void _XtDisplayInitialize(
  325. #if NeedFunctionPrototypes
  326.     Display*        /* dpy */,
  327.     XtPerDisplay    /* pd */,
  328.     _Xconst char*    /* name */,
  329.     XrmOptionDescRec*    /* urlist */,
  330.     Cardinal         /* num_urs */,
  331.     int*        /* argc */,
  332.     char**         /* argv */
  333. #endif
  334. );
  335.  
  336. extern void _XtCacheFlushTag(
  337. #if NeedFunctionPrototypes
  338.     XtAppContext /* app */,
  339.     XtPointer     /* tag */
  340. #endif
  341. );
  342.  
  343. extern void _XtFreeActions(
  344. #if NeedFunctionPrototypes
  345.     struct _ActionListRec* /* action_table */
  346. #endif
  347. );
  348.  
  349. extern void _XtDoPhase2Destroy(
  350. #if NeedFunctionPrototypes
  351.     XtAppContext /* app */,
  352.     int         /* dispatch_level */
  353. #endif
  354. );
  355.  
  356. #define _XtSafeToDestroy(app) ((app)->dispatch_level == 0)
  357.