diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c new file mode 100644 index 0000000..bbd9c2a --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c | |||
@@ -0,0 +1,109 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <xcb/xcb_event.h> | ||
3 | |||
4 | /* local variables */ | ||
5 | static void (*_error_func)(void *data) = NULL; | ||
6 | static void *_error_data = NULL; | ||
7 | static void (*_io_error_func)(void *data) = NULL; | ||
8 | static void *_io_error_data = NULL; | ||
9 | static int _error_request_code = 0; | ||
10 | static int _error_code = 0; | ||
11 | |||
12 | /** | ||
13 | * Set the error handler. | ||
14 | * @param func The error handler function | ||
15 | * @param data The data to be passed to the handler function | ||
16 | * | ||
17 | * Set the X error handler function | ||
18 | */ | ||
19 | EAPI void | ||
20 | ecore_x_error_handler_set(void (*func)(void *data), | ||
21 | const void *data) | ||
22 | { | ||
23 | _error_func = func; | ||
24 | _error_data = (void *)data; | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * Set the I/O error handler. | ||
29 | * @param func The I/O error handler function | ||
30 | * @param data The data to be passed to the handler function | ||
31 | * | ||
32 | * Set the X I/O error handler function | ||
33 | */ | ||
34 | EAPI void | ||
35 | ecore_x_io_error_handler_set(void (*func)(void *data), | ||
36 | const void *data) | ||
37 | { | ||
38 | _io_error_func = func; | ||
39 | _io_error_data = (void *)data; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * Get the request code that caused the error. | ||
44 | * @return The request code causing the X error | ||
45 | * | ||
46 | * Return the X request code that caused the last X error | ||
47 | */ | ||
48 | EAPI int | ||
49 | ecore_x_error_request_get(void) | ||
50 | { | ||
51 | return _error_request_code; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Get the error code from the error. | ||
56 | * @return The error code from the X error | ||
57 | * | ||
58 | * Return the error code from the last X error | ||
59 | */ | ||
60 | EAPI int | ||
61 | ecore_x_error_code_get(void) | ||
62 | { | ||
63 | return _error_code; | ||
64 | } | ||
65 | |||
66 | int | ||
67 | _ecore_xcb_error_handle(xcb_generic_error_t *err) | ||
68 | { | ||
69 | WRN("Got Error:"); | ||
70 | WRN("\tEvent: %s", xcb_event_get_request_label(err->major_code)); | ||
71 | WRN("\tError: %s", xcb_event_get_error_label(err->error_code)); | ||
72 | |||
73 | #ifdef OLD_XCB_VERSION | ||
74 | if (err->error_code == XCB_EVENT_ERROR_BAD_VALUE) | ||
75 | WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value); | ||
76 | else if (err->error_code == XCB_EVENT_ERROR_BAD_WINDOW) | ||
77 | WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value); | ||
78 | #else | ||
79 | if (err->error_code == XCB_VALUE) | ||
80 | WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value); | ||
81 | else if (err->error_code == XCB_WINDOW) | ||
82 | WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value); | ||
83 | #endif | ||
84 | |||
85 | _error_request_code = err->sequence; | ||
86 | _error_code = err->error_code; | ||
87 | if (_error_func) | ||
88 | _error_func(_error_data); | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | int | ||
94 | _ecore_xcb_io_error_handle(xcb_generic_error_t *err) | ||
95 | { | ||
96 | CRIT("IO Error:"); | ||
97 | if (err) | ||
98 | { | ||
99 | CRIT("\tRequest: %d", err->sequence); | ||
100 | CRIT("\tCode: %d", err->error_code); | ||
101 | } | ||
102 | if (_io_error_func) | ||
103 | _io_error_func(_io_error_data); | ||
104 | else | ||
105 | exit(-1); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||