diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/ecore/src/lib/ecore_wayland/ecore_wl_input.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_wayland/ecore_wl_input.c | 658 |
1 files changed, 0 insertions, 658 deletions
diff --git a/libraries/ecore/src/lib/ecore_wayland/ecore_wl_input.c b/libraries/ecore/src/lib/ecore_wayland/ecore_wl_input.c deleted file mode 100644 index d44daa7..0000000 --- a/libraries/ecore/src/lib/ecore_wayland/ecore_wl_input.c +++ /dev/null | |||
@@ -1,658 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include "Ecore.h" | ||
6 | #include "ecore_private.h" | ||
7 | #include "Ecore_Input.h" | ||
8 | #include "ecore_wl_private.h" | ||
9 | #include "Ecore_Wayland.h" | ||
10 | |||
11 | /* FIXME: This gives BTN_LEFT/RIGHT/MIDDLE for linux systems ... | ||
12 | * What about other OSs ?? */ | ||
13 | #ifdef __linux__ | ||
14 | # include <linux/input.h> | ||
15 | #else | ||
16 | # define BTN_LEFT 0x110 | ||
17 | # define BTN_RIGHT 0x111 | ||
18 | # define BTN_MIDDLE 0x112 | ||
19 | # define BTN_SIDE 0x113 | ||
20 | # define BTN_EXTRA 0x114 | ||
21 | # define BTN_FORWARD 0x115 | ||
22 | # define BTN_BACK 0x116 | ||
23 | #endif | ||
24 | |||
25 | /* local function prototypes */ | ||
26 | static void _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int sx, int sy); | ||
27 | static void _ecore_wl_input_cb_button(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, unsigned int button, unsigned int state); | ||
28 | static void _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp __UNUSED__, unsigned int key, unsigned int state); | ||
29 | static void _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface, int sx, int sy); | ||
30 | static void _ecore_wl_input_cb_pointer_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface __UNUSED__); | ||
31 | static void _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface, struct wl_array *keys); | ||
32 | static void _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface __UNUSED__); | ||
33 | static void _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, int x, int y); | ||
34 | static void _ecore_wl_input_cb_touch_up(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__); | ||
35 | static void _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, int x, int y); | ||
36 | static void _ecore_wl_input_cb_touch_frame(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__); | ||
37 | static void _ecore_wl_input_cb_touch_cancel(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__); | ||
38 | static void _ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, unsigned int id); | ||
39 | static void _ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer); | ||
40 | static void _ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device); | ||
41 | static void _ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, int x, int y); | ||
42 | static void _ecore_wl_input_cb_data_drop(void *data, struct wl_data_device *data_device); | ||
43 | static void _ecore_wl_input_cb_data_selection(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer); | ||
44 | |||
45 | static void _ecore_wl_input_keyboard_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp); | ||
46 | static void _ecore_wl_input_pointer_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp); | ||
47 | static void _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, unsigned int timestamp); | ||
48 | static void _ecore_wl_input_cb_mouse_move_free(void *data __UNUSED__, void *event); | ||
49 | static void _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, unsigned int timestamp); | ||
50 | static void _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, unsigned int timestamp); | ||
51 | static void _ecore_wl_input_focus_in_send(Ecore_Wl_Input *input, unsigned int timestamp); | ||
52 | static void _ecore_wl_input_focus_out_send(Ecore_Wl_Input *input, unsigned int timestamp); | ||
53 | static void _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, unsigned int timestamp); | ||
54 | static void _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, unsigned int timestamp); | ||
55 | |||
56 | /* wayland interfaces */ | ||
57 | static const struct wl_input_device_listener _ecore_wl_input_listener = | ||
58 | { | ||
59 | _ecore_wl_input_cb_motion, | ||
60 | _ecore_wl_input_cb_button, | ||
61 | _ecore_wl_input_cb_key, | ||
62 | _ecore_wl_input_cb_pointer_enter, | ||
63 | _ecore_wl_input_cb_pointer_leave, | ||
64 | _ecore_wl_input_cb_keyboard_enter, | ||
65 | _ecore_wl_input_cb_keyboard_leave, | ||
66 | _ecore_wl_input_cb_touch_down, | ||
67 | _ecore_wl_input_cb_touch_up, | ||
68 | _ecore_wl_input_cb_touch_motion, | ||
69 | _ecore_wl_input_cb_touch_frame, | ||
70 | _ecore_wl_input_cb_touch_cancel | ||
71 | }; | ||
72 | |||
73 | static const struct wl_data_device_listener _ecore_wl_data_listener = | ||
74 | { | ||
75 | _ecore_wl_input_cb_data_offer, | ||
76 | _ecore_wl_input_cb_data_enter, | ||
77 | _ecore_wl_input_cb_data_leave, | ||
78 | _ecore_wl_input_cb_data_motion, | ||
79 | _ecore_wl_input_cb_data_drop, | ||
80 | _ecore_wl_input_cb_data_selection | ||
81 | }; | ||
82 | |||
83 | /* local variables */ | ||
84 | static int _pointer_x, _pointer_y; | ||
85 | |||
86 | void | ||
87 | _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id) | ||
88 | { | ||
89 | Ecore_Wl_Input *input; | ||
90 | |||
91 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
92 | |||
93 | if (!(input = malloc(sizeof(Ecore_Wl_Input)))) return; | ||
94 | |||
95 | memset(input, 0, sizeof(Ecore_Wl_Input)); | ||
96 | |||
97 | input->display = ewd; | ||
98 | input->pointer_focus = NULL; | ||
99 | input->keyboard_focus = NULL; | ||
100 | |||
101 | input->input_device = | ||
102 | wl_display_bind(ewd->wl.display, id, &wl_input_device_interface); | ||
103 | wl_list_insert(ewd->inputs.prev, &input->link); | ||
104 | wl_input_device_add_listener(input->input_device, | ||
105 | &_ecore_wl_input_listener, input); | ||
106 | wl_input_device_set_user_data(input->input_device, input); | ||
107 | |||
108 | input->data_device = | ||
109 | wl_data_device_manager_get_data_device(ewd->wl.data_device_manager, | ||
110 | input->input_device); | ||
111 | wl_data_device_add_listener(input->data_device, | ||
112 | &_ecore_wl_data_listener, input); | ||
113 | } | ||
114 | |||
115 | void | ||
116 | _ecore_wl_input_del(Ecore_Wl_Input *input) | ||
117 | { | ||
118 | if (!input) return; | ||
119 | |||
120 | _ecore_wl_input_keyboard_focus_remove(input, 0); | ||
121 | _ecore_wl_input_pointer_focus_remove(input, 0); | ||
122 | |||
123 | if (input->drag_source) _ecore_wl_dnd_del(input->drag_source); | ||
124 | input->drag_source = NULL; | ||
125 | |||
126 | if (input->selection_source) _ecore_wl_dnd_del(input->selection_source); | ||
127 | input->selection_source = NULL; | ||
128 | |||
129 | if (input->data_device) wl_data_device_destroy(input->data_device); | ||
130 | if (input->input_device) wl_input_device_destroy(input->input_device); | ||
131 | wl_list_remove(&input->link); | ||
132 | free(input); | ||
133 | } | ||
134 | |||
135 | void | ||
136 | _ecore_wl_input_pointer_xy_get(int *x, int *y) | ||
137 | { | ||
138 | if (x) *x = _pointer_x; | ||
139 | if (y) *y = _pointer_y; | ||
140 | } | ||
141 | |||
142 | /* local functions */ | ||
143 | static void | ||
144 | _ecore_wl_input_cb_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int sx, int sy) | ||
145 | { | ||
146 | Ecore_Wl_Input *input; | ||
147 | |||
148 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
149 | |||
150 | if (!(input = data)) return; | ||
151 | |||
152 | _pointer_x = sx; | ||
153 | _pointer_y = sy; | ||
154 | |||
155 | input->sx = sx; | ||
156 | input->sy = sy; | ||
157 | |||
158 | /* TODO: FIXME: NB: Weston window code has set pointer image here also */ | ||
159 | _ecore_wl_input_mouse_move_send(input, timestamp); | ||
160 | } | ||
161 | |||
162 | static void | ||
163 | _ecore_wl_input_cb_button(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, unsigned int button, unsigned int state) | ||
164 | { | ||
165 | Ecore_Wl_Input *input; | ||
166 | |||
167 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
168 | |||
169 | if (!(input = data)) return; | ||
170 | |||
171 | input->timestamp = timestamp; | ||
172 | |||
173 | _ecore_wl_input_mouse_move_send(input, timestamp); | ||
174 | |||
175 | if ((button >= BTN_SIDE) && (button <= BTN_BACK)) | ||
176 | { | ||
177 | /* TODO: raise mouse wheel */ | ||
178 | printf("Raise Mouse Wheel Event\n"); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | if (state) | ||
183 | { | ||
184 | input->button = button; | ||
185 | _ecore_wl_input_mouse_down_send(input, timestamp); | ||
186 | } | ||
187 | else | ||
188 | { | ||
189 | _ecore_wl_input_mouse_up_send(input, timestamp); | ||
190 | input->button = 0; | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | static void | ||
196 | _ecore_wl_input_cb_key(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp __UNUSED__, unsigned int key, unsigned int state) | ||
197 | { | ||
198 | Ecore_Wl_Input *input; | ||
199 | Ecore_Wl_Window *win; | ||
200 | unsigned int keycode = 0; | ||
201 | |||
202 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
203 | |||
204 | if (!(input = data)) return; | ||
205 | |||
206 | win = input->keyboard_focus; | ||
207 | if ((!win) || (win->keyboard_device != input)) return; | ||
208 | |||
209 | /* FIXME: NB: I believe this should be min_key_code rather than 8, | ||
210 | * but weston code has it like this */ | ||
211 | keycode = key + 8; | ||
212 | |||
213 | /* if ((input->modifiers & XKB_COMMON_SHIFT_MASK) && */ | ||
214 | /* (XkbKeyGroupWidth(_ecore_wl_disp->xkb, keycode, 0) > 1)) */ | ||
215 | /* level = 1; */ | ||
216 | /* keysym = XkbKeySymEntry(_ecore_wl_disp->xkb, keycode, level, 0); */ | ||
217 | |||
218 | if (state) | ||
219 | input->modifiers |= _ecore_wl_disp->xkb->map->modmap[keycode]; | ||
220 | else | ||
221 | input->modifiers &= ~_ecore_wl_disp->xkb->map->modmap[keycode]; | ||
222 | } | ||
223 | |||
224 | static void | ||
225 | _ecore_wl_input_cb_pointer_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface, int sx, int sy) | ||
226 | { | ||
227 | Ecore_Wl_Input *input; | ||
228 | Ecore_Wl_Window *win = NULL; | ||
229 | |||
230 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
231 | |||
232 | if (!(input = data)) return; | ||
233 | |||
234 | input->sx = sx; | ||
235 | input->sy = sy; | ||
236 | |||
237 | _ecore_wl_input_mouse_move_send(input, timestamp); | ||
238 | |||
239 | win = input->pointer_focus; | ||
240 | if ((win) && (win->surface != surface)) | ||
241 | { | ||
242 | if (!input->button) | ||
243 | _ecore_wl_input_pointer_focus_remove(input, timestamp); | ||
244 | } | ||
245 | |||
246 | if (surface) | ||
247 | { | ||
248 | if ((win = wl_surface_get_user_data(surface))) | ||
249 | { | ||
250 | input->pointer_focus = win; | ||
251 | win->pointer_device = input; | ||
252 | } | ||
253 | if (input->button) | ||
254 | { | ||
255 | _ecore_wl_input_mouse_up_send(input, timestamp); | ||
256 | input->button = 0; | ||
257 | } | ||
258 | else | ||
259 | _ecore_wl_input_mouse_in_send(input, timestamp); | ||
260 | } | ||
261 | } | ||
262 | |||
263 | static void | ||
264 | _ecore_wl_input_cb_pointer_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface __UNUSED__) | ||
265 | { | ||
266 | Ecore_Wl_Input *input; | ||
267 | |||
268 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
269 | |||
270 | if (!(input = data)) return; | ||
271 | _ecore_wl_input_pointer_focus_remove(input, timestamp); | ||
272 | } | ||
273 | |||
274 | static void | ||
275 | _ecore_wl_input_cb_keyboard_enter(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface, struct wl_array *keys) | ||
276 | { | ||
277 | Ecore_Wl_Input *input; | ||
278 | Ecore_Wl_Window *win = NULL; | ||
279 | unsigned int *k, *end; | ||
280 | |||
281 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
282 | |||
283 | if (!(input = data)) return; | ||
284 | |||
285 | end = keys->data + keys->size; | ||
286 | input->modifiers = 0; | ||
287 | for (k = keys->data; k < end; k++) | ||
288 | input->modifiers |= _ecore_wl_disp->xkb->map->modmap[*k]; | ||
289 | |||
290 | if (surface) | ||
291 | { | ||
292 | if ((win = wl_surface_get_user_data(surface))) | ||
293 | { | ||
294 | input->keyboard_focus = win; | ||
295 | win->keyboard_device = input; | ||
296 | } | ||
297 | else | ||
298 | input->keyboard_focus = NULL; | ||
299 | _ecore_wl_input_focus_in_send(input, timestamp); | ||
300 | } | ||
301 | } | ||
302 | |||
303 | static void | ||
304 | _ecore_wl_input_cb_keyboard_leave(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface __UNUSED__) | ||
305 | { | ||
306 | Ecore_Wl_Input *input; | ||
307 | |||
308 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
309 | |||
310 | if (!(input = data)) return; | ||
311 | _ecore_wl_input_keyboard_focus_remove(input, timestamp); | ||
312 | } | ||
313 | |||
314 | static void | ||
315 | _ecore_wl_input_cb_touch_down(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, struct wl_surface *surface __UNUSED__, int id __UNUSED__, int x, int y) | ||
316 | { | ||
317 | Ecore_Wl_Input *input; | ||
318 | |||
319 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
320 | |||
321 | if (!(input = data)) return; | ||
322 | |||
323 | /* FIXME: NB: Not sure yet if input->timestamp should be set here. | ||
324 | * This needs to be tested with an actual touch device */ | ||
325 | /* input->timestamp = timestamp; */ | ||
326 | input->button = 0; | ||
327 | input->sx = x; | ||
328 | input->sy = y; | ||
329 | _ecore_wl_input_mouse_down_send(input, timestamp); | ||
330 | } | ||
331 | |||
332 | static void | ||
333 | _ecore_wl_input_cb_touch_up(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__) | ||
334 | { | ||
335 | Ecore_Wl_Input *input; | ||
336 | |||
337 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
338 | |||
339 | if (!(input = data)) return; | ||
340 | |||
341 | /* FIXME: NB: Not sure yet if input->timestamp should be set here. | ||
342 | * This needs to be tested with an actual touch device */ | ||
343 | /* input->timestamp = timestamp; */ | ||
344 | input->button = 0; | ||
345 | _ecore_wl_input_mouse_up_send(input, timestamp); | ||
346 | } | ||
347 | |||
348 | static void | ||
349 | _ecore_wl_input_cb_touch_motion(void *data, struct wl_input_device *input_device __UNUSED__, unsigned int timestamp, int id __UNUSED__, int x, int y) | ||
350 | { | ||
351 | Ecore_Wl_Input *input; | ||
352 | |||
353 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
354 | |||
355 | if (!(input = data)) return; | ||
356 | |||
357 | /* FIXME: NB: Not sure yet if input->timestamp should be set here. | ||
358 | * This needs to be tested with an actual touch device */ | ||
359 | /* input->timestamp = timestamp; */ | ||
360 | input->sx = x; | ||
361 | input->sy = y; | ||
362 | |||
363 | _ecore_wl_input_mouse_move_send(input, timestamp); | ||
364 | } | ||
365 | |||
366 | static void | ||
367 | _ecore_wl_input_cb_touch_frame(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__) | ||
368 | { | ||
369 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
370 | } | ||
371 | |||
372 | static void | ||
373 | _ecore_wl_input_cb_touch_cancel(void *data __UNUSED__, struct wl_input_device *input_device __UNUSED__) | ||
374 | { | ||
375 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
376 | } | ||
377 | |||
378 | static void | ||
379 | _ecore_wl_input_cb_data_offer(void *data, struct wl_data_device *data_device, unsigned int id) | ||
380 | { | ||
381 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
382 | |||
383 | _ecore_wl_dnd_add(data, data_device, id); | ||
384 | } | ||
385 | |||
386 | static void | ||
387 | _ecore_wl_input_cb_data_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer) | ||
388 | { | ||
389 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
390 | |||
391 | _ecore_wl_dnd_enter(data, data_device, timestamp, surface, x, y, offer); | ||
392 | } | ||
393 | |||
394 | static void | ||
395 | _ecore_wl_input_cb_data_leave(void *data, struct wl_data_device *data_device) | ||
396 | { | ||
397 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
398 | |||
399 | _ecore_wl_dnd_leave(data, data_device); | ||
400 | } | ||
401 | |||
402 | static void | ||
403 | _ecore_wl_input_cb_data_motion(void *data, struct wl_data_device *data_device, unsigned int timestamp, int x, int y) | ||
404 | { | ||
405 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
406 | |||
407 | _ecore_wl_dnd_motion(data, data_device, timestamp, x, y); | ||
408 | } | ||
409 | |||
410 | static void | ||
411 | _ecore_wl_input_cb_data_drop(void *data, struct wl_data_device *data_device) | ||
412 | { | ||
413 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
414 | |||
415 | _ecore_wl_dnd_drop(data, data_device); | ||
416 | } | ||
417 | |||
418 | static void | ||
419 | _ecore_wl_input_cb_data_selection(void *data, struct wl_data_device *data_device, struct wl_data_offer *offer) | ||
420 | { | ||
421 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
422 | |||
423 | _ecore_wl_dnd_selection(data, data_device, offer); | ||
424 | } | ||
425 | |||
426 | static void | ||
427 | _ecore_wl_input_keyboard_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp) | ||
428 | { | ||
429 | Ecore_Wl_Window *win; | ||
430 | |||
431 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
432 | |||
433 | _ecore_wl_input_focus_out_send(input, timestamp); | ||
434 | if ((win = input->keyboard_focus)) | ||
435 | win->keyboard_device = NULL; | ||
436 | input->keyboard_focus = NULL; | ||
437 | } | ||
438 | |||
439 | static void | ||
440 | _ecore_wl_input_pointer_focus_remove(Ecore_Wl_Input *input, unsigned int timestamp) | ||
441 | { | ||
442 | Ecore_Wl_Window *win; | ||
443 | |||
444 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
445 | |||
446 | if (!input->button) | ||
447 | _ecore_wl_input_mouse_out_send(input, timestamp); | ||
448 | |||
449 | if ((win = input->pointer_focus)) | ||
450 | win->pointer_device = NULL; | ||
451 | input->pointer_focus = NULL; | ||
452 | } | ||
453 | |||
454 | static void | ||
455 | _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, unsigned int timestamp) | ||
456 | { | ||
457 | Ecore_Event_Mouse_Move *ev; | ||
458 | Ecore_Event *event; | ||
459 | |||
460 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
461 | |||
462 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Move)))) return; | ||
463 | |||
464 | ev->timestamp = timestamp; | ||
465 | ev->x = input->sx; | ||
466 | ev->y = input->sy; | ||
467 | ev->modifiers = input->modifiers; | ||
468 | ev->multi.device = 0; | ||
469 | ev->multi.radius = 1; | ||
470 | ev->multi.radius_x = 1; | ||
471 | ev->multi.radius_y = 1; | ||
472 | ev->multi.pressure = 1.0; | ||
473 | ev->multi.angle = 0.0; | ||
474 | ev->multi.x = input->sx; | ||
475 | ev->multi.y = input->sy; | ||
476 | |||
477 | if (input->pointer_focus) | ||
478 | { | ||
479 | ev->window = input->pointer_focus->id; | ||
480 | ev->event_window = input->pointer_focus->id; | ||
481 | } | ||
482 | |||
483 | event = ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, | ||
484 | _ecore_wl_input_cb_mouse_move_free, NULL); | ||
485 | } | ||
486 | |||
487 | static void | ||
488 | _ecore_wl_input_cb_mouse_move_free(void *data __UNUSED__, void *event) | ||
489 | { | ||
490 | Ecore_Event_Mouse_Move *ev; | ||
491 | |||
492 | if ((ev = event)) free(ev); | ||
493 | } | ||
494 | |||
495 | static void | ||
496 | _ecore_wl_input_mouse_in_send(Ecore_Wl_Input *input, unsigned int timestamp) | ||
497 | { | ||
498 | Ecore_Wl_Event_Mouse_In *ev; | ||
499 | Ecore_Event *event; | ||
500 | |||
501 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
502 | |||
503 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_In)))) return; | ||
504 | |||
505 | ev->x = input->sx; | ||
506 | ev->y = input->sy; | ||
507 | ev->modifiers = input->modifiers; | ||
508 | ev->timestamp = timestamp; | ||
509 | |||
510 | if (input->pointer_focus) | ||
511 | { | ||
512 | ev->win = input->pointer_focus->id; | ||
513 | ev->event_win = input->pointer_focus->id; | ||
514 | } | ||
515 | |||
516 | event = ecore_event_add(ECORE_WL_EVENT_MOUSE_IN, ev, NULL, NULL); | ||
517 | } | ||
518 | |||
519 | static void | ||
520 | _ecore_wl_input_mouse_out_send(Ecore_Wl_Input *input, unsigned int timestamp) | ||
521 | { | ||
522 | Ecore_Wl_Event_Mouse_Out *ev; | ||
523 | |||
524 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
525 | |||
526 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_Out)))) return; | ||
527 | |||
528 | ev->x = input->sx; | ||
529 | ev->y = input->sy; | ||
530 | ev->modifiers = input->modifiers; | ||
531 | ev->timestamp = timestamp; | ||
532 | |||
533 | if (input->pointer_focus) | ||
534 | { | ||
535 | ev->win = input->pointer_focus->id; | ||
536 | ev->event_win = input->pointer_focus->id; | ||
537 | } | ||
538 | |||
539 | ecore_event_add(ECORE_WL_EVENT_MOUSE_OUT, ev, NULL, NULL); | ||
540 | } | ||
541 | |||
542 | static void | ||
543 | _ecore_wl_input_focus_in_send(Ecore_Wl_Input *input, unsigned int timestamp) | ||
544 | { | ||
545 | Ecore_Wl_Event_Focus_In *ev; | ||
546 | |||
547 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
548 | |||
549 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Focus_In)))) return; | ||
550 | ev->timestamp = timestamp; | ||
551 | if (input->keyboard_focus) | ||
552 | ev->win = input->keyboard_focus->id; | ||
553 | ecore_event_add(ECORE_WL_EVENT_FOCUS_IN, ev, NULL, NULL); | ||
554 | } | ||
555 | |||
556 | static void | ||
557 | _ecore_wl_input_focus_out_send(Ecore_Wl_Input *input, unsigned int timestamp) | ||
558 | { | ||
559 | Ecore_Wl_Event_Focus_Out *ev; | ||
560 | |||
561 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
562 | |||
563 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Focus_Out)))) return; | ||
564 | ev->timestamp = timestamp; | ||
565 | if (input->keyboard_focus) | ||
566 | ev->win = input->keyboard_focus->id; | ||
567 | ecore_event_add(ECORE_WL_EVENT_FOCUS_OUT, ev, NULL, NULL); | ||
568 | } | ||
569 | |||
570 | static void | ||
571 | _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, unsigned int timestamp) | ||
572 | { | ||
573 | Ecore_Event_Mouse_Button *ev; | ||
574 | |||
575 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
576 | |||
577 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return; | ||
578 | |||
579 | if (input->button == BTN_LEFT) | ||
580 | ev->buttons = 1; | ||
581 | else if (input->button == BTN_MIDDLE) | ||
582 | ev->buttons = 2; | ||
583 | else if (input->button == BTN_RIGHT) | ||
584 | ev->buttons = 3; | ||
585 | else | ||
586 | ev->buttons = input->button; | ||
587 | |||
588 | ev->timestamp = timestamp; | ||
589 | ev->x = input->sx; | ||
590 | ev->y = input->sy; | ||
591 | ev->modifiers = input->modifiers; | ||
592 | |||
593 | /* FIXME: Need to get these from wayland somehow */ | ||
594 | ev->double_click = 0; | ||
595 | ev->triple_click = 0; | ||
596 | |||
597 | ev->multi.device = 0; | ||
598 | ev->multi.radius = 1; | ||
599 | ev->multi.radius_x = 1; | ||
600 | ev->multi.radius_y = 1; | ||
601 | ev->multi.pressure = 1.0; | ||
602 | ev->multi.angle = 0.0; | ||
603 | ev->multi.x = input->sx; | ||
604 | ev->multi.y = input->sy; | ||
605 | |||
606 | if (input->pointer_focus) | ||
607 | { | ||
608 | ev->window = input->pointer_focus->id; | ||
609 | ev->event_window = input->pointer_focus->id; | ||
610 | } | ||
611 | |||
612 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); | ||
613 | } | ||
614 | |||
615 | static void | ||
616 | _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, unsigned int timestamp) | ||
617 | { | ||
618 | Ecore_Event_Mouse_Button *ev; | ||
619 | |||
620 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
621 | |||
622 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return; | ||
623 | |||
624 | if (input->button == BTN_LEFT) | ||
625 | ev->buttons = 1; | ||
626 | else if (input->button == BTN_MIDDLE) | ||
627 | ev->buttons = 2; | ||
628 | else if (input->button == BTN_RIGHT) | ||
629 | ev->buttons = 3; | ||
630 | else | ||
631 | ev->buttons = input->button; | ||
632 | |||
633 | ev->timestamp = timestamp; | ||
634 | ev->x = input->sx; | ||
635 | ev->y = input->sy; | ||
636 | ev->modifiers = input->modifiers; | ||
637 | |||
638 | /* FIXME: Need to get these from wayland somehow */ | ||
639 | ev->double_click = 0; | ||
640 | ev->triple_click = 0; | ||
641 | |||
642 | ev->multi.device = 0; | ||
643 | ev->multi.radius = 1; | ||
644 | ev->multi.radius_x = 1; | ||
645 | ev->multi.radius_y = 1; | ||
646 | ev->multi.pressure = 1.0; | ||
647 | ev->multi.angle = 0.0; | ||
648 | ev->multi.x = input->sx; | ||
649 | ev->multi.y = input->sy; | ||
650 | |||
651 | if (input->pointer_focus) | ||
652 | { | ||
653 | ev->window = input->pointer_focus->id; | ||
654 | ev->event_window = input->pointer_focus->id; | ||
655 | } | ||
656 | |||
657 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); | ||
658 | } | ||