diff options
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c deleted file mode 100644 index 11e9f20..0000000 --- a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif /* ifdef HAVE_CONFIG_H */ | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | |||
7 | #include "Ecore.h" | ||
8 | #include "ecore_private.h" | ||
9 | #include "ecore_x_private.h" | ||
10 | #include "Ecore_X.h" | ||
11 | |||
12 | static int _ecore_x_error_handle(Display *d, | ||
13 | XErrorEvent *ev); | ||
14 | static int _ecore_x_io_error_handle(Display *d); | ||
15 | |||
16 | static void (*_error_func)(void *data) = NULL; | ||
17 | static void *_error_data = NULL; | ||
18 | static void (*_io_error_func)(void *data) = NULL; | ||
19 | static void *_io_error_data = NULL; | ||
20 | static int _error_request_code = 0; | ||
21 | static int _error_code = 0; | ||
22 | static Ecore_X_ID _error_resource_id = 0; | ||
23 | |||
24 | /** | ||
25 | * Set the error handler. | ||
26 | * @param func The error handler function | ||
27 | * @param data The data to be passed to the handler function | ||
28 | * | ||
29 | * Set the X error handler function | ||
30 | */ | ||
31 | EAPI void | ||
32 | ecore_x_error_handler_set(void (*func)(void *data), | ||
33 | const void *data) | ||
34 | { | ||
35 | _error_func = func; | ||
36 | _error_data = (void *)data; | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * Set the I/O error handler. | ||
41 | * @param func The I/O error handler function | ||
42 | * @param data The data to be passed to the handler function | ||
43 | * | ||
44 | * Set the X I/O error handler function | ||
45 | */ | ||
46 | EAPI void | ||
47 | ecore_x_io_error_handler_set(void (*func)(void *data), | ||
48 | const void *data) | ||
49 | { | ||
50 | _io_error_func = func; | ||
51 | _io_error_data = (void *)data; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Get the request code that caused the error. | ||
56 | * @return The request code causing the X error | ||
57 | * | ||
58 | * Return the X request code that caused the last X error | ||
59 | */ | ||
60 | EAPI int | ||
61 | ecore_x_error_request_get(void) | ||
62 | { | ||
63 | return _error_request_code; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Get the error code from the error. | ||
68 | * @return The error code from the X error | ||
69 | * | ||
70 | * Return the error code from the last X error | ||
71 | */ | ||
72 | EAPI int | ||
73 | ecore_x_error_code_get(void) | ||
74 | { | ||
75 | return _error_code; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * Get the resource id that caused the error. | ||
80 | * @return The resource id causing the X error | ||
81 | * | ||
82 | * Return the X resource id that caused the last X error | ||
83 | */ | ||
84 | EAPI Ecore_X_ID | ||
85 | ecore_x_error_resource_id_get(void) | ||
86 | { | ||
87 | return _error_resource_id; | ||
88 | } | ||
89 | |||
90 | void | ||
91 | _ecore_x_error_handler_init(void) | ||
92 | { | ||
93 | XSetErrorHandler((XErrorHandler)_ecore_x_error_handle); | ||
94 | XSetIOErrorHandler((XIOErrorHandler)_ecore_x_io_error_handle); | ||
95 | } | ||
96 | |||
97 | static int | ||
98 | _ecore_x_error_handle(Display *d, | ||
99 | XErrorEvent *ev) | ||
100 | { | ||
101 | if (d == _ecore_x_disp) | ||
102 | { | ||
103 | _error_request_code = ev->request_code; | ||
104 | _error_code = ev->error_code; | ||
105 | _error_resource_id = ev->resourceid; | ||
106 | if (_error_func) | ||
107 | _error_func(_error_data); | ||
108 | } | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | static int | ||
113 | _ecore_x_io_error_handle(Display *d) | ||
114 | { | ||
115 | if (d == _ecore_x_disp) | ||
116 | { | ||
117 | if (_io_error_func) | ||
118 | _io_error_func(_io_error_data); | ||
119 | else | ||
120 | exit(-1); | ||
121 | } | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||