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/xcb/ecore_xcb_xtest.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/xcb/ecore_xcb_xtest.c')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xtest.c | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xtest.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xtest.c new file mode 100644 index 0000000..b664dc9 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xtest.c | |||
@@ -0,0 +1,215 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_XTEST | ||
3 | # include <xcb/xtest.h> | ||
4 | # include <X11/keysym.h> | ||
5 | #endif | ||
6 | |||
7 | /* local variables */ | ||
8 | static Eina_Bool _test_avail = EINA_FALSE; | ||
9 | |||
10 | void | ||
11 | _ecore_xcb_xtest_init(void) | ||
12 | { | ||
13 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
14 | |||
15 | #ifdef ECORE_XCB_XTEST | ||
16 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_test_id); | ||
17 | #endif | ||
18 | } | ||
19 | |||
20 | void | ||
21 | _ecore_xcb_xtest_finalize(void) | ||
22 | { | ||
23 | #ifdef ECORE_XCB_XTEST | ||
24 | const xcb_query_extension_reply_t *ext_reply; | ||
25 | #endif | ||
26 | |||
27 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
28 | |||
29 | #ifdef ECORE_XCB_XTEST | ||
30 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_test_id); | ||
31 | if ((ext_reply) && (ext_reply->present)) | ||
32 | _test_avail = EINA_TRUE; | ||
33 | #endif | ||
34 | } | ||
35 | |||
36 | EAPI Eina_Bool | ||
37 | #ifdef ECORE_XCB_XTEST | ||
38 | ecore_x_test_fake_key_down(const char *key) | ||
39 | #else | ||
40 | ecore_x_test_fake_key_down(const char *key __UNUSED__) | ||
41 | #endif | ||
42 | { | ||
43 | #ifdef ECORE_XCB_XTEST | ||
44 | xcb_keycode_t keycode = 0; | ||
45 | xcb_void_cookie_t cookie; | ||
46 | xcb_generic_error_t *err; | ||
47 | #endif | ||
48 | |||
49 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
50 | CHECK_XCB_CONN; | ||
51 | |||
52 | if (!_test_avail) return EINA_FALSE; | ||
53 | |||
54 | #ifdef ECORE_XCB_XTEST | ||
55 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
56 | if (keycode == XCB_NO_SYMBOL) return EINA_FALSE; | ||
57 | |||
58 | cookie = | ||
59 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS, | ||
60 | keycode, XCB_CURRENT_TIME, | ||
61 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
62 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
63 | if (err) | ||
64 | { | ||
65 | free(err); | ||
66 | return EINA_FALSE; | ||
67 | } | ||
68 | return EINA_TRUE; | ||
69 | #endif | ||
70 | |||
71 | return EINA_FALSE; | ||
72 | } | ||
73 | |||
74 | EAPI Eina_Bool | ||
75 | #ifdef ECORE_XCB_XTEST | ||
76 | ecore_x_test_fake_key_up(const char *key) | ||
77 | #else | ||
78 | ecore_x_test_fake_key_up(const char *key __UNUSED__) | ||
79 | #endif | ||
80 | { | ||
81 | #ifdef ECORE_XCB_XTEST | ||
82 | xcb_keycode_t keycode = 0; | ||
83 | xcb_void_cookie_t cookie; | ||
84 | xcb_generic_error_t *err; | ||
85 | #endif | ||
86 | |||
87 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
88 | CHECK_XCB_CONN; | ||
89 | |||
90 | if (!_test_avail) return EINA_FALSE; | ||
91 | |||
92 | #ifdef ECORE_XCB_XTEST | ||
93 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
94 | if (keycode == XCB_NO_SYMBOL) return EINA_FALSE; | ||
95 | |||
96 | cookie = | ||
97 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE, | ||
98 | keycode, XCB_CURRENT_TIME, | ||
99 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
100 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
101 | if (err) | ||
102 | { | ||
103 | free(err); | ||
104 | return EINA_FALSE; | ||
105 | } | ||
106 | return EINA_TRUE; | ||
107 | #endif | ||
108 | |||
109 | return EINA_FALSE; | ||
110 | } | ||
111 | |||
112 | EAPI Eina_Bool | ||
113 | #ifdef ECORE_XCB_XTEST | ||
114 | ecore_x_test_fake_key_press(const char *key) | ||
115 | #else | ||
116 | ecore_x_test_fake_key_press(const char *key __UNUSED__) | ||
117 | #endif | ||
118 | { | ||
119 | #ifdef ECORE_XCB_XTEST | ||
120 | xcb_keycode_t keycode = 0; | ||
121 | xcb_keysym_t keysym = 0; | ||
122 | xcb_keycode_t shift_code = 0; | ||
123 | xcb_void_cookie_t cookie; | ||
124 | xcb_generic_error_t *err; | ||
125 | Eina_Bool shift = EINA_FALSE; | ||
126 | #endif | ||
127 | |||
128 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
129 | CHECK_XCB_CONN; | ||
130 | |||
131 | if (!_test_avail) return EINA_FALSE; | ||
132 | |||
133 | #ifdef ECORE_XCB_XTEST | ||
134 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
135 | keysym = _ecore_xcb_keymap_keycode_to_keysym(keycode, 0); | ||
136 | if (keysym == XCB_NO_SYMBOL) | ||
137 | { | ||
138 | keysym = _ecore_xcb_keymap_keycode_to_keysym(keycode, 1); | ||
139 | if (keysym != XCB_NO_SYMBOL) | ||
140 | shift = EINA_TRUE; | ||
141 | } | ||
142 | |||
143 | if (shift) | ||
144 | { | ||
145 | xcb_keycode_t *keycodes; | ||
146 | int i = 0; | ||
147 | |||
148 | keycodes = _ecore_xcb_keymap_keysym_to_keycode(XK_Shift_L); | ||
149 | while (keycodes[i] != XCB_NO_SYMBOL) | ||
150 | { | ||
151 | if (keycodes[i] != 0) | ||
152 | { | ||
153 | shift_code = keycodes[i]; | ||
154 | break; | ||
155 | } | ||
156 | i++; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | if (shift) | ||
161 | { | ||
162 | cookie = | ||
163 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS, | ||
164 | shift_code, XCB_CURRENT_TIME, | ||
165 | ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
166 | 0, 0, 0); | ||
167 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
168 | if (err) | ||
169 | { | ||
170 | free(err); | ||
171 | return EINA_FALSE; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | cookie = | ||
176 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS, | ||
177 | keycode, XCB_CURRENT_TIME, | ||
178 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
179 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
180 | if (err) | ||
181 | { | ||
182 | free(err); | ||
183 | return EINA_FALSE; | ||
184 | } | ||
185 | cookie = | ||
186 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE, | ||
187 | keycode, XCB_CURRENT_TIME, | ||
188 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
189 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
190 | if (err) | ||
191 | { | ||
192 | free(err); | ||
193 | return EINA_FALSE; | ||
194 | } | ||
195 | |||
196 | if (shift) | ||
197 | { | ||
198 | cookie = | ||
199 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE, | ||
200 | shift_code, XCB_CURRENT_TIME, | ||
201 | ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
202 | 0, 0, 0); | ||
203 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
204 | if (err) | ||
205 | { | ||
206 | free(err); | ||
207 | return EINA_FALSE; | ||
208 | } | ||
209 | } | ||
210 | |||
211 | return EINA_TRUE; | ||
212 | #endif | ||
213 | |||
214 | return EINA_FALSE; | ||
215 | } | ||