home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / tcl / tk3.3b1 / doc / CrtErrHdlr.3 < prev    next >
Encoding:
Text File  |  1993-04-01  |  6.9 KB  |  163 lines

  1. '\"
  2. '\" Copyright (c) 1990 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/wish/man/RCS/CrtErrHdlr.3,v 1.6 93/04/01 09:41:13 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tk_CreateErrorHandler tkc
  25. .BS
  26. .SH NAME
  27. Tk_CreateErrorHandler, Tk_DeleteErrorHandler \- handle X protocol errors
  28. .SH SYNOPSIS
  29. .nf
  30. \fB#include <tk.h>\fR
  31. .sp
  32. Tk_ErrorHandler
  33. \fBTk_CreateErrorHandler\fR(\fIdisplay, error, request, minor, proc, clientData\fR)
  34. .sp
  35. \fBTk_DeleteErrorHandler\fR(\fIhandler\fR)
  36. .SH ARGUMENTS
  37. .AS "Tk_ErrorHandler" clientData
  38. .AP Display *display in
  39. Display whose errors are to be handled.
  40. .AP int error in
  41. Match only error events with this value in the \fIerror_code\fR
  42. field.  If -1, then match any \fIerror_code\fR value.
  43. .AP int request in
  44. Match only error events with this value in the \fIrequest_code\fR
  45. field.  If -1, then match any \fIrequest_code\fR value.
  46. .AP int minor in
  47. Match only error events with this value in the \fIminor_code\fR
  48. field.  If -1, then match any \fIminor_code\fR value.
  49. .AP Tk_ErrorProc *proc in
  50. Procedure to invoke whenever an error event is received for
  51. \fIdisplay\fR and matches \fIerror\fR, \fIrequest\fR, and \fIminor\fR.
  52. NULL means ignore any matching errors.
  53. .AP ClientData clientData in
  54. Arbitrary one-word value to pass to \fIproc\fR.
  55. .AP Tk_ErrorHandler handler in
  56. Token for error handler to delete (return value from a previous
  57. call to \fBTk_CreateErrorHandler\fR).
  58. .BE
  59.  
  60. .SH DESCRIPTION
  61. .PP
  62. \fBTk_CreateErrorHandler\fR arranges for a particular procedure
  63. (\fIproc\fR) to be called whenever certain protocol errors occur on a
  64. particular display (\fIdisplay\fR).  Protocol errors occur when
  65. the X protocol is used incorrectly, such as attempting to map a window
  66. that doesn't exist.  See the Xlib documentation for \fBXSetErrorHandler\fR
  67. for more information on the kinds of errors that can occur.
  68. For \fIproc\fR to be invoked
  69. to handle a particular error, five things must occur:
  70. .IP [1]
  71. The error must pertain to \fIdisplay\fR.
  72. .IP [2]
  73. Either the \fIerror\fR argument to \fBTk_CreateErrorHandler\fR
  74. must have been -1, or the \fIerror\fR argument must match
  75. the \fIerror_code\fR field from the error event.
  76. .IP [3]
  77. Either the \fIrequest\fR argument to \fBTk_CreateErrorHandler\fR
  78. must have been -1, or the \fIrequest\fR argument must match
  79. the \fIrequest_code\fR field from the error event.
  80. .IP [4]
  81. Either the \fIminor\fR argument to \fBTk_CreateErrorHandler\fR
  82. must have been -1, or the \fIminor\fR argument must match
  83. the \fIminor_code\fR field from the error event.
  84. .IP [5]
  85. The protocol request to which the error pertains must have been
  86. made when the handler was active (see below for more information).
  87. .PP
  88. \fIProc\fP should have arguments and result that match the
  89. following type:
  90. .nf
  91. .RS
  92. typedef int Tk_ErrorProc(
  93. .RS
  94. ClientData \fIclientData\fR,
  95. XErrorEvent *\fIerrEventPtr\fR);
  96. .RE
  97. .RE
  98. .fi
  99. The \fIclientData\fP parameter to \fIproc\fR is a copy of the \fIclientData\fP
  100. argument given to \fBTcl_CreateErrorHandler\fR when the callback
  101. was created.  Typically, \fIclientData\fR points to a data
  102. structure containing application-specific information that is
  103. needed to deal with the error.  \fIErrEventPtr\fR is
  104. a pointer to the X error event.
  105. The procedure \fIproc\fR should return an integer value.  If it
  106. returns 0 it means that \fIproc\fR handled the error completely and there
  107. is no need to take any other action for the error.  If it returns
  108. non-zero it means \fIproc\fR was unable to handle the error.
  109. .PP
  110. If a value of NULL is specified for \fIproc\fR, all matching errors
  111. will be ignored:  this will produce the same result as if a procedure
  112. had been specified that always returns 0.
  113. .PP
  114. If more than more than one handler matches a particular error, then
  115. they are invoked in turn.  The handlers will be invoked in reverse
  116. order of creation:  most recently declared handler first.
  117. If any handler returns 0, then subsequent (older) handlers will
  118. not be invoked.  If no handler returns 0, then Tk invokes X'es
  119. default error handler, which prints an error message and aborts the
  120. program.  If you wish to have a default handler that deals with errors
  121. that no other handler can deal with, then declare it first.
  122. .PP
  123. The X documentation states that ``the error handler should not call
  124. any functions (directly or indirectly) on the display that will
  125. generate protocol requests or that will look for input events.''
  126. This restriction applies to handlers declared by \fBTk_CreateErrorHandler\fR;
  127. disobey it at your own risk.
  128. .PP
  129. \fBTk_DeleteErrorHandler\fR may be called to delete a
  130. previously-created error handler.  The \fIhandler\fR argument
  131. identifies the error handler, and should be a value returned by
  132. a previous call to \fBTk_CreateEventHandler\fR.
  133. .PP
  134. A particular error handler applies to errors resulting
  135. from protocol requests generated between
  136. the call to \fBTk_CreateErrorHandler\fR and the call to
  137. \fBTk_DeleteErrorHandler\fR.  However, the actual callback
  138. to \fIproc\fR may not occur until after the \fBTk_DeleteErrorHandler\fR
  139. call, due to buffering in the client and server.
  140. If an error event pertains to
  141. a protocol request made just before calling \fBTk_DeleteErrorHandler\fR,
  142. then the error event may not have been processed
  143. before the \fBTk_DeleteErrorHandler\fR
  144. call.  When this situation arises, Tk will save information about
  145. the handler and
  146. invoke the handler's \fIproc\fR later when the error event
  147. finally arrives.
  148. If an application wishes to delete an error handler and know
  149. for certain that all relevant errors have been processed,
  150. it should first call \fBTk_DeleteErrorHandler\fR and then
  151. call \fBXSync\fR;  this will flush out any buffered requests and errors,
  152. but will result in a performance penalty because
  153. it requires communication to and from the X server.  After the
  154. \fBXSync\fR call Tk is guaranteed not to call any error
  155. handlers deleted before the \fBXSync\fR call.
  156. .PP
  157. For the Tk error handling mechanism to work properly, it is essential
  158. that application code never calls \fBXSetErrorHandler\fR directly;
  159. applications should use only \fBTk_CreateErrorHandler\fR.
  160.  
  161. .SH KEYWORDS
  162. callback, error, event, handler
  163.