source: trunk/third/mwm/WmError.c @ 9757

Revision 9757, 5.4 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r9756, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC.
3 * ALL RIGHTS RESERVED
4*/
5/*
6 * Motif Release 1.2.2
7*/
8#ifdef REV_INFO
9#ifndef lint
10static char rcsid[] = "$RCSfile: WmError.c,v $ $Revision: 1.1.1.1 $ $Date: 1997-03-25 09:12:17 $"
11#endif
12#endif
13/*
14 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
15
16/*
17 * Included Files:
18 */
19
20#include "WmGlobal.h"
21#include <stdio.h>
22
23
24/*
25 * Function Declarations:
26 */
27
28#ifdef _NO_PROTO
29void WmInitErrorHandler ();
30int WmXErrorHandler ();
31int WmXIOErrorHandler ();
32void WmXtErrorHandler ();
33void WmXtWarningHandler ();
34void Warning ();
35#else /* _NO_PROTO */
36void WmInitErrorHandler (Display *display);
37int WmXErrorHandler (Display *display, XErrorEvent *errorEvent);
38int WmXIOErrorHandler (Display *display);
39void WmXtErrorHandler (char *message);
40void WmXtWarningHandler (char *message);
41void Warning (char *message);
42#endif /* _NO_PROTO */
43
44
45
46
47
48/*************************************<->*************************************
49 *
50 *  WmInitErrorHandler (display)
51 *
52 *
53 *  Description:
54 *  -----------
55 *  This function initializes the window manager error handler.
56 *
57 *
58 *  Inputs:
59 *  ------
60 *  display = display we're talking about
61 *  -------
62 *
63 *************************************<->***********************************/
64
65#ifdef _NO_PROTO
66void
67WmInitErrorHandler (display)
68    Display *display;
69
70#else /* _NO_PROTO */
71void
72WmInitErrorHandler (Display *display)
73#endif /* _NO_PROTO */
74{
75
76    XSetErrorHandler (WmXErrorHandler);
77    XSetIOErrorHandler (WmXIOErrorHandler);
78
79    XtSetWarningHandler (WmXtWarningHandler);
80    XtSetErrorHandler (WmXtErrorHandler);
81
82} /* END OF FUNCTION WmInitErrorHandler */
83
84
85/*************************************<->*************************************
86 *
87 *  WmXErrorHandler (display, errorEvent)
88 *
89 *
90 *  Description:
91 *  -----------
92 *  This function is the X error handler that is registered with X to
93 *  handle X errors resulting from window management activities.
94 *
95 *
96 *  Inputs:
97 *  ------
98 *  display = display on which X error occurred
99 *
100 *  errorEvent = pointer to a block of information describing the error
101 *
102 *
103 *  Outputs:
104 *  -------
105 *  wmGD.errorFlag = set to True
106 *
107 *  Return = 0
108 *
109 *************************************<->***********************************/
110
111#ifdef _NO_PROTO
112int
113WmXErrorHandler (display, errorEvent)
114    Display *display;
115    XErrorEvent *errorEvent;
116
117#else /* _NO_PROTO */
118int
119WmXErrorHandler (Display *display, XErrorEvent *errorEvent)
120#endif /* _NO_PROTO */
121{
122    ClientData *pCD;
123
124
125    /*
126     * Check for a BadWindow error for a managed window.  If this error
127     * is detected indicate in the client data that the window no longer
128     * exists.
129     */
130
131    if ((errorEvent->error_code == BadWindow) &&
132        !XFindContext (DISPLAY, errorEvent->resourceid, wmGD.windowContextType,
133             (caddr_t *)&pCD))
134    {
135        if (errorEvent->resourceid == pCD->client)
136        {
137            pCD->clientFlags |= CLIENT_DESTROYED;
138        }
139    }
140
141    wmGD.errorFlag = True;
142
143    return (0);
144
145} /* END OF FUNCTION WmXErrorHandler */
146
147
148
149/*************************************<->*************************************
150 *
151 *  WmXIOErrorHandler (display)
152 *
153 *
154 *  Description:
155 *  -----------
156 *  This function is the X IO error handler that is registered with X to
157 *  handle X IO errors.  This function exits the window manager.
158 *
159 *
160 *  Inputs:
161 *  ------
162 *  display = X display on which the X IO error occurred
163 *
164 *************************************<->***********************************/
165
166#ifdef _NO_PROTO
167int
168WmXIOErrorHandler (display)
169    Display *display;
170
171#else /* _NO_PROTO */
172int
173WmXIOErrorHandler (Display *display)
174#endif /* _NO_PROTO */
175{
176
177    exit (WM_ERROR_EXIT_VALUE);
178
179} /* END OF FUNCTIONS WmXIOErrorHandler */
180
181
182
183/*************************************<->*************************************
184 *
185 *  WmXtErrorHandler (message)
186 *
187 *
188 *  Description:
189 *  -----------
190 *  This function is registered as the X Toolkit error handler.
191 *
192 *
193 *  Inputs:
194 *  ------
195 *  message = pointer to an error message
196 *
197 *************************************<->***********************************/
198
199#ifdef _NO_PROTO
200void
201WmXtErrorHandler (message)
202    char * message;
203
204#else /* _NO_PROTO */
205void
206WmXtErrorHandler (char *message)
207#endif /* _NO_PROTO */
208{
209    exit (WM_ERROR_EXIT_VALUE);
210
211} /* END OF FUNCTION WmXtErrorHandler */
212
213
214
215/*************************************<->*************************************
216 *
217 *  WmXtWarningHandler (message)
218 *
219 *
220 *  Description:
221 *  -----------
222 *  This function is registered as an X Toolkit warning handler.
223 *
224 *
225 *  Inputs:
226 *  ------
227 *  message = pointer to a warning message
228 *
229 *************************************<->***********************************/
230
231#ifdef _NO_PROTO
232void
233WmXtWarningHandler (message)
234    char * message;
235
236#else /* _NO_PROTO */
237void
238WmXtWarningHandler (char *message)
239#endif /* _NO_PROTO */
240{
241
242
243} /* END OF FUNCTIONS WmXtWarningHandler */
244
245
246/*************************************<->*************************************
247 *
248 *  Warning (message)
249 *
250 *
251 *  Description:
252 *  -----------
253 *  This function lists a message to stderr.
254 *
255 *
256 *  Inputs:
257 *  ------
258 *  message = pointer to a message string
259 *
260 *************************************<->***********************************/
261
262#ifdef _NO_PROTO
263void
264Warning (message)
265    char * message;
266
267#else /* _NO_PROTO */
268void
269Warning (char *message)
270#endif /* _NO_PROTO */
271{
272    fprintf (stderr, "%s: %s\n", wmGD.mwmName, message);
273    fflush (stderr);
274
275} /* END OF FUNCTION Warning */
276
Note: See TracBrowser for help on using the repository browser.