diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-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/xlib/ecore_x_error.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c | 111 |
1 files changed, 111 insertions, 0 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 new file mode 100644 index 0000000..837ff53 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c | |||
@@ -0,0 +1,111 @@ | |||
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 | |||
23 | /** | ||
24 | * Set the error handler. | ||
25 | * @param func The error handler function | ||
26 | * @param data The data to be passed to the handler function | ||
27 | * | ||
28 | * Set the X error handler function | ||
29 | */ | ||
30 | EAPI void | ||
31 | ecore_x_error_handler_set(void (*func)(void *data), | ||
32 | const void *data) | ||
33 | { | ||
34 | _error_func = func; | ||
35 | _error_data = (void *)data; | ||
36 | } /* ecore_x_error_handler_set */ | ||
37 | |||
38 | /** | ||
39 | * Set the I/O error handler. | ||
40 | * @param func The I/O error handler function | ||
41 | * @param data The data to be passed to the handler function | ||
42 | * | ||
43 | * Set the X I/O error handler function | ||
44 | */ | ||
45 | EAPI void | ||
46 | ecore_x_io_error_handler_set(void (*func)(void *data), | ||
47 | const void *data) | ||
48 | { | ||
49 | _io_error_func = func; | ||
50 | _io_error_data = (void *)data; | ||
51 | } /* ecore_x_io_error_handler_set */ | ||
52 | |||
53 | /** | ||
54 | * Get the request code that caused the error. | ||
55 | * @return The request code causing the X error | ||
56 | * | ||
57 | * Return the X request code that caused the last X error | ||
58 | */ | ||
59 | EAPI int | ||
60 | ecore_x_error_request_get(void) | ||
61 | { | ||
62 | return _error_request_code; | ||
63 | } /* ecore_x_error_request_get */ | ||
64 | |||
65 | /** | ||
66 | * Get the error code from the error. | ||
67 | * @return The error code from the X error | ||
68 | * | ||
69 | * Return the error code from the last X error | ||
70 | */ | ||
71 | EAPI int | ||
72 | ecore_x_error_code_get(void) | ||
73 | { | ||
74 | return _error_code; | ||
75 | } /* ecore_x_error_code_get */ | ||
76 | |||
77 | void | ||
78 | _ecore_x_error_handler_init(void) | ||
79 | { | ||
80 | XSetErrorHandler((XErrorHandler)_ecore_x_error_handle); | ||
81 | XSetIOErrorHandler((XIOErrorHandler)_ecore_x_io_error_handle); | ||
82 | } /* _ecore_x_error_handler_init */ | ||
83 | |||
84 | static int | ||
85 | _ecore_x_error_handle(Display *d, | ||
86 | XErrorEvent *ev) | ||
87 | { | ||
88 | if (d == _ecore_x_disp) | ||
89 | { | ||
90 | _error_request_code = ev->request_code; | ||
91 | _error_code = ev->error_code; | ||
92 | if (_error_func) | ||
93 | _error_func(_error_data); | ||
94 | } | ||
95 | return 0; | ||
96 | } /* _ecore_x_error_handle */ | ||
97 | |||
98 | static int | ||
99 | _ecore_x_io_error_handle(Display *d) | ||
100 | { | ||
101 | if (d == _ecore_x_disp) | ||
102 | { | ||
103 | if (_io_error_func) | ||
104 | _io_error_func(_io_error_data); | ||
105 | else | ||
106 | exit(-1); | ||
107 | } | ||
108 | |||
109 | return 0; | ||
110 | } /* _ecore_x_io_error_handle */ | ||
111 | |||