1 #include "ecore_xcb_private.h"
2 #include <xcb/xcb_event.h>
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 static Ecore_X_ID _error_resource_id = 0;
14 * Set the error handler.
15 * @param func The error handler function
16 * @param data The data to be passed to the handler function
18 * Set the X error handler function
21 ecore_x_error_handler_set(void (*func)(void *data),
25 _error_data = (void *)data;
29 * Set the I/O error handler.
30 * @param func The I/O error handler function
31 * @param data The data to be passed to the handler function
33 * Set the X I/O error handler function
36 ecore_x_io_error_handler_set(void (*func)(void *data),
39 _io_error_func = func;
40 _io_error_data = (void *)data;
44 * Get the request code that caused the error.
45 * @return The request code causing the X error
47 * Return the X request code that caused the last X error
50 ecore_x_error_request_get(void)
52 return _error_request_code;
56 * Get the error code from the error.
57 * @return The error code from the X error
59 * Return the error code from the last X error
62 ecore_x_error_code_get(void)
68 * Get the resource id that caused the error.
69 * @return The resource id causing the X error
71 * Return the X resource id that caused the last X error
74 ecore_x_error_resource_id_get(void)
76 return _error_resource_id;
80 _ecore_xcb_error_handle(xcb_generic_error_t *err)
83 WRN("\tEvent: %s", xcb_event_get_request_label(err->major_code));
84 WRN("\tError: %s", xcb_event_get_error_label(err->error_code));
86 #ifdef OLD_XCB_VERSION
87 if (err->error_code == XCB_EVENT_ERROR_BAD_VALUE)
88 WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value);
89 else if (err->error_code == XCB_EVENT_ERROR_BAD_WINDOW)
90 WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value);
92 if (err->error_code == XCB_VALUE)
93 WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value);
94 else if (err->error_code == XCB_WINDOW)
95 WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value);
98 _error_request_code = err->sequence;
99 _error_code = err->error_code;
100 _error_resource_id = err->resource_id;
102 _error_func(_error_data);
108 _ecore_xcb_io_error_handle(xcb_generic_error_t *err)
113 CRIT("\tRequest: %d", err->sequence);
114 CRIT("\tCode: %d", err->error_code);
117 _io_error_func(_io_error_data);