tkMacOSXPort.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * tkMacOSXPort.h --
  3. *
  4. * This file is included by all of the Tk C files. It contains
  5. * information that may be configuration-dependent, such as
  6. * #includes for system include files and a few other things.
  7. *
  8. * Copyright (c) 1994-1996 Sun Microsystems, Inc.
  9. * Copyright 2001-2009, Apple Inc.
  10. * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
  11. *
  12. * See the file "license.terms" for information on usage and redistribution
  13. * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  14. */
  15. #ifndef _TKMACPORT
  16. #define _TKMACPORT
  17. #include <stdio.h>
  18. #include <pwd.h>
  19. #include <assert.h>
  20. #include <errno.h>
  21. #include <fcntl.h>
  22. #include <ctype.h>
  23. #include <math.h>
  24. #include <string.h>
  25. #include <limits.h>
  26. #include <stdlib.h>
  27. #include <sys/types.h>
  28. #include <sys/file.h>
  29. #ifdef HAVE_SYS_SELECT_H
  30. # include <sys/select.h>
  31. #endif
  32. #include <sys/stat.h>
  33. #ifndef _TCL
  34. # include <tcl.h>
  35. #endif
  36. #if TIME_WITH_SYS_TIME
  37. # include <sys/time.h>
  38. # include <time.h>
  39. #else
  40. # if HAVE_SYS_TIME_H
  41. # include <sys/time.h>
  42. # else
  43. # include <time.h>
  44. # endif
  45. #endif
  46. #if HAVE_INTTYPES_H
  47. # include <inttypes.h>
  48. #endif
  49. #include <unistd.h>
  50. #if defined(__GNUC__) && !defined(__cplusplus)
  51. # pragma GCC diagnostic ignored "-Wc++-compat"
  52. #endif
  53. #include <X11/Xlib.h>
  54. #include <X11/cursorfont.h>
  55. #include <X11/keysym.h>
  56. #include <X11/Xatom.h>
  57. #include <X11/Xfuncproto.h>
  58. #include <X11/Xutil.h>
  59. /*
  60. * The following macro defines the type of the mask arguments to
  61. * select:
  62. */
  63. #ifndef NO_FD_SET
  64. # define SELECT_MASK fd_set
  65. #else
  66. # ifndef _AIX
  67. typedef long fd_mask;
  68. # endif
  69. # if defined(_IBMR2)
  70. # define SELECT_MASK void
  71. # else
  72. # define SELECT_MASK int
  73. # endif
  74. #endif
  75. /*
  76. * Used to tag functions that are only to be visible within the module being
  77. * built and not outside it (where this is supported by the linker).
  78. */
  79. #ifndef MODULE_SCOPE
  80. # ifdef __cplusplus
  81. # define MODULE_SCOPE extern "C"
  82. # else
  83. # define MODULE_SCOPE extern
  84. # endif
  85. #endif
  86. /*
  87. * The following macro defines the number of fd_masks in an fd_set:
  88. */
  89. #ifndef FD_SETSIZE
  90. # ifdef OPEN_MAX
  91. # define FD_SETSIZE OPEN_MAX
  92. # else
  93. # define FD_SETSIZE 256
  94. # endif
  95. #endif
  96. #if !defined(howmany)
  97. # define howmany(x, y) (((x)+((y)-1))/(y))
  98. #endif
  99. #ifndef NFDBITS
  100. # define NFDBITS NBBY*sizeof(fd_mask)
  101. #endif
  102. #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
  103. /*
  104. * Define "NBBY" (number of bits per byte) if it's not already defined.
  105. */
  106. #ifndef NBBY
  107. # define NBBY 8
  108. #endif
  109. /*
  110. * The following define causes Tk to use its internal keysym hash table
  111. */
  112. #define REDO_KEYSYM_LOOKUP
  113. /*
  114. * Defines for X functions that are used by Tk but are treated as
  115. * no-op functions on the Macintosh.
  116. */
  117. #undef XFlush
  118. #define XFlush(display) (0)
  119. #undef XFree
  120. #define XFree(data) (((data) != NULL) ? (ckfree(data),0) : 0)
  121. #undef XGrabServer
  122. #define XGrabServer(display) (0)
  123. #undef XNoOp
  124. #define XNoOp(display) (display->request++,0)
  125. #undef XUngrabServer
  126. #define XUngrabServer(display) (0)
  127. #undef XSynchronize
  128. #define XSynchronize(display, onoff) (display->request++,NULL)
  129. #undef XVisualIDFromVisual
  130. #define XVisualIDFromVisual(visual) (visual->visualid)
  131. /*
  132. * The following functions are not used on the Mac, so we stub them out.
  133. */
  134. #define TkpCmapStressed(tkwin,colormap) (0)
  135. #define TkpFreeColor(tkColPtr)
  136. #define TkSetPixmapColormap(p,c) {}
  137. #define TkpSync(display)
  138. /*
  139. * TkMacOSXGetCapture is a legacy function used on the Mac. When fixing
  140. * [943d5ebe51], TkpGetCapture was added to the Windows port. Both
  141. * are actually the same feature and should bear the same name. However,
  142. * in order to avoid potential backwards incompatibilities, renaming
  143. * TkMacOSXGetCapture into TkpGetCapture in *PlatDecls.h shall not be
  144. * done in a patch release, therefore use a define here.
  145. */
  146. #define TkpGetCapture TkMacOSXGetCapture
  147. /*
  148. * This macro stores a representation of the window handle in a string.
  149. */
  150. #define TkpPrintWindowId(buf,w) \
  151. sprintf((buf), "0x%lx", (unsigned long) (w))
  152. /*
  153. * Turn off Tk double-buffering as Aqua windows are already double-buffered.
  154. */
  155. #define TK_NO_DOUBLE_BUFFERING 1
  156. #define TK_HAS_DYNAMIC_COLORS 1
  157. #define TK_DYNAMIC_COLORMAP 0x0fffffff
  158. /*
  159. * Inform tkImgPhInstance.c that we implement TkpPutRGBAImage to render RGBA
  160. * images directly into a window.
  161. */
  162. #define TK_CAN_RENDER_RGBA
  163. MODULE_SCOPE int TkpPutRGBAImage(
  164. Display* display, Drawable drawable, GC gc,XImage* image,
  165. int src_x, int src_y, int dest_x, int dest_y,
  166. unsigned int width, unsigned int height);
  167. /*
  168. * Used by xcolor.c
  169. */
  170. MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green,
  171. unsigned long blue);
  172. #define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8))
  173. /*
  174. * Used by tkWindow.c
  175. */
  176. MODULE_SCOPE void TkMacOSXHandleMapOrUnmap(Tk_Window tkwin, XEvent *event);
  177. #define TkpHandleMapOrUnmap(tkwin, event) TkMacOSXHandleMapOrUnmap(tkwin, event)
  178. /*
  179. * Used by tkAppInit
  180. */
  181. #define USE_CUSTOM_EXIT_PROC
  182. EXTERN int TkpWantsExitProc(void);
  183. EXTERN TCL_NORETURN void TkpExitProc(void *);
  184. #endif /* _TKMACPORT */