MsgP.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef _DT_MSG_P_H
  24. #define _DT_MSG_P_H
  25. /*
  26. * MsgP.h -- Private header file for DT messaging library
  27. *
  28. * $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
  29. * $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
  30. *
  31. * (C) Copyright 1993, Hewlett-Packard, all rights reserved.
  32. */
  33. #include <Dt/Msg.h>
  34. /*
  35. * Definitions
  36. */
  37. /* max property size (bytes) */
  38. #define DT_MSG_MAX_PROP_SIZE (32768)
  39. /* atom names */
  40. #define DT_MSG_XA_REQUEST "_DT_REQUEST"
  41. #define DT_MSG_XA_NOTIFY "_DT_NOTIFY"
  42. #define DT_MSG_XA_BROADCAST_REGISTRY "_DT_BROADCAST_REGISTRY"
  43. /*
  44. * _DtMessage handle
  45. */
  46. typedef struct _DtMsgHandle {
  47. char * pchName; /* handle "name" */
  48. Atom atom; /* Selection/Broadcast atom */
  49. Widget widget; /* Widget registering this handle */
  50. char * pchPropName; /* property name */
  51. Atom property; /* atomized property name */
  52. /* other data */
  53. struct _DtMsgServiceContext *
  54. service_data; /* service data assoc w/ handle */
  55. struct _DtMsgBroadcastData *
  56. broadcast_data; /* broadcast data assoc w/ handle */
  57. } DtMsgHandle;
  58. /*
  59. * _DtMessage handle accessor "functions"
  60. */
  61. #define DtMsgH_Name(h) ((h)->pchName)
  62. #define DtMsgH_Widget(h) ((h)->widget)
  63. #define DtMsgH_Atom(h) ((h)->atom)
  64. #define DtMsgH_SvcData(h) ((h)->service_data)
  65. #define DtMsgH_BcData(h) ((h)->broadcast_data)
  66. #define DtMsgH_PropertyName(h) ((h)->pchPropName)
  67. #define DtMsgH_PropertyAtom(h) ((h)->property)
  68. #define DtMsgH_Shandle(h) ((h)->service_data->handle)
  69. #define DtMsgH_RequestProc(h) ((h)->service_data->request_proc)
  70. #define DtMsgH_ReceiveCD(h) ((h)->service_data->receive_client_data)
  71. #define DtMsgH_LoseProc(h) ((h)->service_data->lose_proc)
  72. #define DtMsgH_LoseCD(h) ((h)->service_data->lose_client_data)
  73. #define DtMsgH_RegistryAtom(h) ((h)->broadcast_data->aRegistry)
  74. #define DtMsgH_SharedWindow(h) ((h)->broadcast_data->winShared)
  75. #define DtMsgH_SharedWidget(h) ((h)->broadcast_data->wShared)
  76. #define DtMsgH_Listener(h) ((h)->broadcast_data->wListener)
  77. #define DtMsgH_BreceiveProc(h) ((h)->broadcast_data->Breceive_proc)
  78. #define DtMsgH_BclientData(h) ((h)->broadcast_data->Bclient_data)
  79. #define DtMsgH_Bprops(h) ((h)->broadcast_data->props)
  80. #define DtMsgH_BnumProps(h) ((h)->broadcast_data->numProps)
  81. #define DtMsgH_BsizeProps(h) ((h)->broadcast_data->sizeProps)
  82. #define DtMsgH_Breceivers(h) ((h)->broadcast_data->pReceivers)
  83. #define DtMsgH_BnumReceivers(h) ((h)->broadcast_data->numReceivers)
  84. #define DtMsgH_BsizeReceivers(h) ((h)->broadcast_data->sizeReceivers)
  85. #define DtMsgH_BSenderInit(h) ((h)->broadcast_data->bSenderInitialized)
  86. /*
  87. * Service context data
  88. * (for client that offers a service)
  89. */
  90. typedef struct _DtMsgServiceContext {
  91. DtMsgHandle handle;
  92. DtMsgReceiveProc request_proc;
  93. DtMsgStatusProc lose_proc;
  94. Pointer receive_client_data;
  95. Pointer lose_client_data;
  96. } DtMsgServiceContext;
  97. /*
  98. * Request context data
  99. * (for client that makes a service request)
  100. */
  101. typedef struct _DtMsgRequestContext {
  102. DtMsgHandle handle;
  103. DtMsgReceiveProc reply_proc;
  104. Pointer client_data;
  105. } DtMsgRequestContext;
  106. /*
  107. * Reply message context data
  108. * (for client replying to a request)
  109. */
  110. typedef struct _DtMsgReplyMessageContext {
  111. DtMsgHandle handle;
  112. Window window;
  113. Atom target;
  114. Atom property;
  115. } DtMsgReplyMessageContext;
  116. /*
  117. * Broadcast sender data
  118. */
  119. /* number of props to allocate per memory request */
  120. #define DT_MSG_PROP_INC_AMT 10
  121. typedef struct _DtMsgBroadcastPerReceiverData {
  122. Widget widget; /* widget of receiver */
  123. Atom * propsUnread; /* list of props */
  124. int numPropsUnread; /* number of props */
  125. int sizePropsUnread; /* amt of space allocated */
  126. } DtMsgBroadcastPerReceiverData;
  127. typedef struct _DtMsgBroadcastData {
  128. Atom aRegistry; /* registry atom name */
  129. Window winShared; /* shared window */
  130. Widget wShared; /* shared widget */
  131. Widget wListener; /* child of shared window */
  132. DtMsgReceiveProc Breceive_proc; /* broadcast receive proc */
  133. Pointer Bclient_data; /* broadcast client data */
  134. Boolean bSenderInitialized; /* true if ready for send */
  135. Atom * props; /* props to use for messages */
  136. int numProps; /* number of message props */
  137. int sizeProps; /* number of props allocated */
  138. DtMsgBroadcastPerReceiverData * pReceivers; /* rcvr data */
  139. int numReceivers; /* number of receivers */
  140. int sizeReceivers; /* amt of rcvr space allocated */
  141. } DtMsgBroadcastData;
  142. /*
  143. * Broadcast _DtMessage Registry definitions
  144. */
  145. /* registry entry size, in words */
  146. #define DT_MSG_REGISTRY_ENTRY_SIZE 2
  147. /* offsets within each registry entry */
  148. #define DT_MSG_REGISTRY_NAME_OFFSET 0
  149. #define DT_MSG_REGISTRY_WINDOW_OFFSET 1
  150. /* Macros to compute offset */
  151. #define MSG_GROUP_NAME(R, i) \
  152. (R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_NAME_OFFSET])
  153. #define MSG_GROUP_WINDOW(R, i) \
  154. (R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_WINDOW_OFFSET])
  155. #endif /* not defined _DT_MSG_P_H */
  156. /***** END OF FILE ****/