home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xt / InitialI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-21  |  9.8 KB  |  350 lines

  1. /* $XConsortium: InitialI.h,v 1.64 93/01/08 16:04:57 converse 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. #ifndef PATH_MAX
  45. #ifdef MAXPATHLEN
  46. #define PATH_MAX MAXPATHLEN
  47. #else
  48. #define PATH_MAX 1024
  49. #endif
  50. #endif
  51. #endif
  52.  
  53. #include "fd.h"
  54.  
  55. typedef struct _TimerEventRec {
  56.         struct timeval        te_timer_value;
  57.     struct _TimerEventRec *te_next;
  58.     XtTimerCallbackProc   te_proc;
  59.     XtAppContext          app;
  60.     XtPointer          te_closure;
  61. } TimerEventRec;
  62.  
  63. typedef struct _InputEvent {
  64.     XtInputCallbackProc   ie_proc;
  65.     XtPointer          ie_closure;
  66.     struct _InputEvent    *ie_next;
  67.     struct _InputEvent    *ie_oq;
  68.     XtAppContext          app;
  69.     int              ie_source;
  70.     XtInputMask          ie_condition;
  71. } InputEvent;
  72.  
  73. typedef struct _WorkProcRec {
  74.     XtWorkProc proc;
  75.     XtPointer closure;
  76.     struct _WorkProcRec *next;
  77.     XtAppContext app;
  78. } WorkProcRec;
  79.  
  80.  
  81. typedef struct 
  82. {
  83.       Fd_set rmask;
  84.     Fd_set wmask;
  85.     Fd_set emask;
  86.     int    nfds;
  87.     int    count;
  88. } FdStruct;
  89.  
  90. typedef struct _LangProcRec {
  91.     XtLanguageProc    proc;
  92.     XtPointer        closure;
  93. } LangProcRec;
  94.  
  95. typedef struct _ProcessContextRec {
  96.     XtAppContext    defaultAppContext;
  97.     XtAppContext    appContextList;
  98.     ConverterTable    globalConverterTable;
  99.     LangProcRec        globalLangProcRec;
  100. } ProcessContextRec, *ProcessContext;
  101.  
  102. typedef struct {
  103.     char*    start;
  104.     char*    current;
  105.     int        bytes_remaining;
  106. } Heap;
  107.  
  108. typedef struct _DestroyRec DestroyRec;
  109.  
  110. typedef struct _XtAppStruct {
  111.     XtAppContext next;        /* link to next app in process context */
  112.     ProcessContext process;    /* back pointer to our process context */
  113.     InternalCallbackList destroy_callbacks;
  114.     Display **list;
  115.     TimerEventRec *timerQueue;
  116.     WorkProcRec *workQueue;
  117.     InputEvent **input_list;
  118.     InputEvent *outstandingQueue;
  119.     XrmDatabase errorDB;
  120.     XtErrorMsgHandler errorMsgHandler, warningMsgHandler;
  121.     XtErrorHandler errorHandler, warningHandler;
  122.     struct _ActionListRec *action_table;
  123.     ConverterTable converterTable;
  124.     unsigned long selectionTimeout;
  125.     FdStruct fds;
  126.     short count;            /* num of assigned entries in list */
  127.     short max;                /* allocate size of list */
  128.     short last;
  129.     short input_max;            /* elts input_list init'd with */
  130.     Boolean sync, being_destroyed, error_inited;
  131. #ifndef NO_IDENTIFY_WINDOWS
  132.     Boolean identify_windows;        /* debugging hack */
  133. #endif
  134.     Heap heap;
  135.     String * fallback_resources;    /* Set by XtAppSetFallbackResources. */
  136.     struct _ActionHookRec* action_hook_list;
  137.     int destroy_list_size;        /* state data for 2-phase destroy */
  138.     int destroy_count;
  139.     int dispatch_level;
  140.     DestroyRec* destroy_list;
  141.     Widget in_phase2_destroy;
  142.     LangProcRec langProcRec;
  143. } XtAppStruct;
  144.  
  145. #ifdef XTTRACEMEMORY
  146.  
  147.  
  148. extern char *_XtHeapMalloc(
  149. #if NeedFunctionPrototypes
  150.     Heap*    /* heap */,
  151.     Cardinal    /* size */,
  152.     char *    /* file */,
  153.     int        /* line */
  154. #endif
  155. );
  156.  
  157. #define _XtHeapAlloc(heap,bytes) _XtHeapMalloc(heap, bytes, __FILE__, __LINE__)
  158.  
  159. #else /* XTTRACEMEMORY */
  160.  
  161. extern char* _XtHeapAlloc(
  162. #if NeedFunctionPrototypes
  163.     Heap*    /* heap */,
  164.     Cardinal    /* size */
  165. #endif
  166. );
  167.  
  168. #endif /* XTTRACEMEMORY */
  169.  
  170. extern void _XtSetDefaultErrorHandlers(
  171. #if NeedFunctionPrototypes
  172.     XtErrorMsgHandler*    /* errMsg */,
  173.     XtErrorMsgHandler*    /* warnMsg */,
  174.     XtErrorHandler*    /* err */,
  175.     XtErrorHandler*    /* warn */
  176. #endif
  177. );
  178.  
  179. extern void _XtSetDefaultSelectionTimeout(
  180. #if NeedFunctionPrototypes
  181.     unsigned long* /* timeout */
  182. #endif
  183. );
  184.  
  185. extern XtAppContext _XtDefaultAppContext(
  186. #if NeedFunctionPrototypes
  187.     void
  188. #endif
  189. );
  190.  
  191. extern ProcessContext _XtGetProcessContext(
  192. #if NeedFunctionPrototypes
  193.     void
  194. #endif
  195. );
  196.  
  197. Display *
  198. _XtAppInit(
  199. #if NeedFunctionPrototypes
  200.     XtAppContext*    /* app_context_return */,
  201.     String        /* application_class */,
  202.     XrmOptionDescRec*    /* options */,
  203.     Cardinal        /* num_options */,
  204.     int*        /* argc_in_out */,
  205.     String**        /* argv_in_out */,
  206.     String*        /* fallback_resources */
  207. #endif
  208. );
  209.  
  210. extern void _XtDestroyAppContexts(
  211. #if NeedFunctionPrototypes
  212.     void
  213. #endif
  214. );
  215.  
  216. extern void _XtCloseDisplays(
  217. #if NeedFunctionPrototypes
  218.     void
  219. #endif
  220. );
  221.  
  222. extern int _XtAppDestroyCount;
  223. extern int _XtDpyDestroyCount;
  224.  
  225. extern int _XtwaitForSomething(
  226. #if NeedFunctionPrototypes
  227.     _XtBoolean         /* ignoreTimers */,
  228.     _XtBoolean         /* ignoreInputs */,
  229.     _XtBoolean         /* ignoreEvents */,
  230.     _XtBoolean         /* block */,
  231.     unsigned long*    /* howlong */,
  232.     XtAppContext     /* app */
  233. #endif
  234. );
  235.  
  236. typedef struct _CaseConverterRec *CaseConverterPtr;
  237. typedef struct _CaseConverterRec {
  238.     KeySym        start;        /* first KeySym valid in converter */
  239.     KeySym        stop;        /* last KeySym valid in converter */
  240.     XtCaseProc        proc;        /* case converter function */
  241.     CaseConverterPtr    next;        /* next converter record */
  242. } CaseConverterRec;
  243.  
  244. typedef struct _XtPerDisplayStruct {
  245.     InternalCallbackList destroy_callbacks;
  246.     Region region;
  247.     CaseConverterPtr case_cvt;        /* user-registered case converters */
  248.     XtKeyProc defaultKeycodeTranslator;
  249.     XtAppContext appContext;
  250.     unsigned long keysyms_serial;      /* for tracking MappingNotify events */
  251.     KeySym *keysyms;                   /* keycode to keysym table */
  252.     int keysyms_per_keycode;           /* number of keysyms for each keycode*/
  253.     int min_keycode, max_keycode;      /* range of keycodes */
  254.     KeySym *modKeysyms;                /* keysym values for modToKeysysm */
  255.     ModToKeysymTable *modsToKeysyms;   /* modifiers to Keysysms index table*/
  256.     unsigned char isModifier[32];      /* key-is-modifier-p bit table */
  257.     KeySym lock_meaning;           /* Lock modifier meaning */
  258.     Modifiers mode_switch;           /* keyboard group modifiers */
  259.     Boolean being_destroyed;
  260.     Boolean rv;                   /* reverse_video resource */
  261.     XrmName name;               /* resolved app name */
  262.     XrmClass class;               /* application class */
  263.     Heap heap;
  264.     struct _GCrec *GClist;           /* support for XtGetGC */
  265.     Drawable **pixmap_tab;             /* ditto for XtGetGC */
  266.     String language;               /* XPG language string */
  267.     Time last_timestamp;           /* from last event dispatched */
  268.     int multi_click_time;           /* for XtSetMultiClickTime */
  269.     struct _TMKeyContextRec* tm_context;     /* for XtGetActionKeysym */
  270.     InternalCallbackList mapping_callbacks;  /* special case for TM */
  271.     XtPerDisplayInputRec pdi;           /* state for modal grabs & kbd focus */
  272.     struct _WWTable *WWtable;           /* window to widget table */
  273.     XrmDatabase *per_screen_db;        /* per screen resource databases */
  274.     XrmDatabase cmd_db;               /* db from command line, if needed */
  275.     XrmDatabase server_db;           /* resource property else .Xdefaults */
  276. } XtPerDisplayStruct, *XtPerDisplay;
  277.  
  278. typedef struct _PerDisplayTable {
  279.     Display *dpy;
  280.     XtPerDisplayStruct perDpy;
  281.     struct _PerDisplayTable *next;
  282. } PerDisplayTable, *PerDisplayTablePtr;
  283.  
  284. extern PerDisplayTablePtr _XtperDisplayList;
  285.  
  286. extern XtPerDisplay _XtSortPerDisplayList(
  287. #if NeedFunctionPrototypes
  288.     Display* /* dpy */
  289. #endif
  290. );
  291.  
  292. /*
  293. extern XtPerDisplay _XtGetPerDisplay( Display* );
  294. extern XtPerDisplayInputRec* _XtGetPerDisplayInput( Display* );
  295. */
  296.  
  297. #ifdef DEBUG
  298. #define _XtGetPerDisplay(display) \
  299.     ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
  300.      ? &_XtperDisplayList->perDpy \
  301.      : _XtSortPerDisplayList(display))
  302. #define _XtGetPerDisplayInput(display) \
  303.     ((_XtperDisplayList != NULL && (_XtperDisplayList->dpy == (display))) \
  304.      ? &_XtperDisplayList->perDpy.pdi \
  305.      : &_XtSortPerDisplayList(display)->pdi)
  306. #else
  307. #define _XtGetPerDisplay(display) \
  308.     ((_XtperDisplayList->dpy == (display)) \
  309.      ? &_XtperDisplayList->perDpy \
  310.      : _XtSortPerDisplayList(display))
  311. #define _XtGetPerDisplayInput(display) \
  312.     ((_XtperDisplayList->dpy == (display)) \
  313.      ? &_XtperDisplayList->perDpy.pdi \
  314.      : &_XtSortPerDisplayList(display)->pdi)
  315. #endif /*DEBUG*/
  316.  
  317. extern void _XtDisplayInitialize(
  318. #if NeedFunctionPrototypes
  319.     Display*        /* dpy */,
  320.     XtPerDisplay    /* pd */,
  321.     _Xconst char*    /* name */,
  322.     XrmOptionDescRec*    /* urlist */,
  323.     Cardinal         /* num_urs */,
  324.     int*        /* argc */,
  325.     char**         /* argv */
  326. #endif
  327. );
  328.  
  329. extern void _XtCacheFlushTag(
  330. #if NeedFunctionPrototypes
  331.     XtAppContext /* app */,
  332.     XtPointer     /* tag */
  333. #endif
  334. );
  335.  
  336. extern void _XtFreeActions(
  337. #if NeedFunctionPrototypes
  338.     struct _ActionListRec* /* action_table */
  339. #endif
  340. );
  341.  
  342. extern void _XtDoPhase2Destroy(
  343. #if NeedFunctionPrototypes
  344.     XtAppContext /* app */,
  345.     int         /* dispatch_level */
  346. #endif
  347. );
  348.  
  349. #define _XtSafeToDestroy(app) ((app)->dispatch_level == 0)
  350.