aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c')
-rw-r--r--libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c109
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 */
5static void (*_error_func)(void *data) = NULL;
6static void *_error_data = NULL;
7static void (*_io_error_func)(void *data) = NULL;
8static void *_io_error_data = NULL;
9static int _error_request_code = 0;
10static 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 */
19EAPI void
20ecore_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 */
34EAPI void
35ecore_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 */
48EAPI int
49ecore_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 */
60EAPI int
61ecore_x_error_code_get(void)
62{
63 return _error_code;
64}
65
66int
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
93int
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