2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
12 #include "ecore_private.h"
13 #include "ecore_x_private.h"
16 static void _ecore_x_error_handle(Display * d, XErrorEvent * ev);
17 static int _ecore_x_io_error_handle(Display *d);
19 static void (*_error_func) (void *data) = NULL;
20 static void *_error_data = NULL;
21 static void (*_io_error_func) (void *data) = NULL;
22 static void *_io_error_data = NULL;
23 static int _error_request_code = 0;
24 static int _error_code = 0;
27 * Set the error handler.
28 * @param func The error handler function
29 * @param data The data to be passed to the handler function
31 * Set the X error handler function
34 ecore_x_error_handler_set(void (*func) (void *data), const void *data)
37 _error_data = (void *)data;
41 * Set the I/O error handler.
42 * @param func The I/O error handler function
43 * @param data The data to be passed to the handler function
45 * Set the X I/O error handler function
48 ecore_x_io_error_handler_set(void (*func) (void *data), const void *data)
50 _io_error_func = func;
51 _io_error_data = (void *)data;
55 * Get the request code that caused the error.
56 * @return The request code causing the X error
58 * Return the X request code that caused the last X error
61 ecore_x_error_request_get(void)
63 return _error_request_code;
67 * Get the error code from the error.
68 * @return The error code from the X error
70 * Return the error code from the last X error
73 ecore_x_error_code_get(void)
79 _ecore_x_error_handler_init(void)
81 XSetErrorHandler((XErrorHandler)_ecore_x_error_handle);
82 XSetIOErrorHandler((XIOErrorHandler)_ecore_x_io_error_handle);
86 _ecore_x_error_handle(Display *d, XErrorEvent *ev)
88 if (d == _ecore_x_disp)
90 _error_request_code = ev->request_code;
91 _error_code = ev->error_code;
92 if (_error_func) _error_func(_error_data);
97 _ecore_x_io_error_handle(Display *d)
99 if (d == _ecore_x_disp)
101 if (_io_error_func) _io_error_func(_io_error_data);