summaryrefslogtreecommitdiff
path: root/src/lib/elput/elput_evdev.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-06-02 18:23:45 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-06-02 18:23:43 -0400
commit36dcd5719a2a82d91a468d9a23e9f09b22713492 (patch)
treee769951a55f0ae5266893728f30cc1f29aca693c /src/lib/elput/elput_evdev.c
parent32bf71f19e82cf97419869d7d31fde955241927c (diff)
elput: ref evas devices in event structs
Diffstat (limited to 'src/lib/elput/elput_evdev.c')
-rw-r--r--src/lib/elput/elput_evdev.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 33c4772ec7..fb9d5a2bed 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -287,6 +287,13 @@ _keyboard_release(Elput_Seat *seat)
287} 287}
288 288
289static void 289static void
290_event_free(void *dev, void *ev)
291{
292 if (dev) efl_unref(dev);
293 free(ev);
294}
295
296static void
290_keyboard_key_send(Elput_Device *dev, enum libinput_key_state state, const char *keyname, const char *key, const char *compose, unsigned int code, unsigned int timestamp) 297_keyboard_key_send(Elput_Device *dev, enum libinput_key_state state, const char *keyname, const char *key, const char *compose, unsigned int code, unsigned int timestamp)
291{ 298{
292 Ecore_Event_Key *ev; 299 Ecore_Event_Key *ev;
@@ -309,15 +316,16 @@ _keyboard_key_send(Elput_Device *dev, enum libinput_key_state state, const char
309 ev->timestamp = timestamp; 316 ev->timestamp = timestamp;
310 ev->same_screen = 1; 317 ev->same_screen = 1;
311 ev->dev = dev->evas_device; 318 ev->dev = dev->evas_device;
319 if (ev->dev) efl_ref(ev->dev);
312 320
313 ev->window = dev->seat->manager->window; 321 ev->window = dev->seat->manager->window;
314 ev->event_window = dev->seat->manager->window; 322 ev->event_window = dev->seat->manager->window;
315 ev->root_window = dev->seat->manager->window; 323 ev->root_window = dev->seat->manager->window;
316 324
317 if (state == LIBINPUT_KEY_STATE_PRESSED) 325 if (state == LIBINPUT_KEY_STATE_PRESSED)
318 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); 326 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, _event_free, ev->dev);
319 else 327 else
320 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); 328 ecore_event_add(ECORE_EVENT_KEY_UP, ev, _event_free, ev->dev);
321} 329}
322 330
323static void 331static void
@@ -813,6 +821,7 @@ _pointer_motion_send(Elput_Device *edev)
813 ev->timestamp = ptr->timestamp; 821 ev->timestamp = ptr->timestamp;
814 ev->same_screen = 1; 822 ev->same_screen = 1;
815 ev->dev = edev->evas_device; 823 ev->dev = edev->evas_device;
824 if (ev->dev) efl_ref(ev->dev);
816 825
817 ev->x = ptr->x; 826 ev->x = ptr->x;
818 ev->y = ptr->y; 827 ev->y = ptr->y;
@@ -837,7 +846,7 @@ _pointer_motion_send(Elput_Device *edev)
837 ev->multi.root.x = ptr->x; 846 ev->multi.root.x = ptr->x;
838 ev->multi.root.y = ptr->y; 847 ev->multi.root.y = ptr->y;
839 848
840 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); 849 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _event_free, ev->dev);
841} 850}
842 851
843static void 852static void
@@ -923,6 +932,7 @@ _pointer_button_send(Elput_Device *edev, enum libinput_button_state state)
923 ev->timestamp = ptr->timestamp; 932 ev->timestamp = ptr->timestamp;
924 ev->same_screen = 1; 933 ev->same_screen = 1;
925 ev->dev = edev->evas_device; 934 ev->dev = edev->evas_device;
935 if (ev->dev) efl_ref(ev->dev);
926 936
927 ev->x = ptr->x; 937 ev->x = ptr->x;
928 ev->y = ptr->y; 938 ev->y = ptr->y;
@@ -952,9 +962,9 @@ _pointer_button_send(Elput_Device *edev, enum libinput_button_state state)
952 ev->modifiers = edev->seat->modifiers; 962 ev->modifiers = edev->seat->modifiers;
953 963
954 if (state) 964 if (state)
955 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); 965 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, _event_free, ev->dev);
956 else 966 else
957 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); 967 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, _event_free, ev->dev);
958} 968}
959 969
960static void 970static void
@@ -1045,6 +1055,7 @@ _pointer_axis_send(Elput_Device *dev, int direction, int value)
1045 ev->timestamp = ptr->timestamp; 1055 ev->timestamp = ptr->timestamp;
1046 ev->same_screen = 1; 1056 ev->same_screen = 1;
1047 ev->dev = dev->evas_device; 1057 ev->dev = dev->evas_device;
1058 if (ev->dev) efl_ref(ev->dev);
1048 1059
1049 ev->x = ptr->x; 1060 ev->x = ptr->x;
1050 ev->y = ptr->y; 1061 ev->y = ptr->y;
@@ -1059,7 +1070,7 @@ _pointer_axis_send(Elput_Device *dev, int direction, int value)
1059 1070
1060 ev->modifiers = dev->seat->modifiers; 1071 ev->modifiers = dev->seat->modifiers;
1061 1072
1062 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL); 1073 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _event_free, ev->dev);
1063} 1074}
1064 1075
1065static double 1076static double
@@ -1202,6 +1213,7 @@ _touch_motion_send(Elput_Device *dev)
1202 ev->timestamp = touch->timestamp; 1213 ev->timestamp = touch->timestamp;
1203 ev->same_screen = 1; 1214 ev->same_screen = 1;
1204 ev->dev = dev->evas_device; 1215 ev->dev = dev->evas_device;
1216 if (ev->dev) efl_ref(ev->dev);
1205 1217
1206 ev->x = lround(touch->x); 1218 ev->x = lround(touch->x);
1207 ev->y = lround(touch->y); 1219 ev->y = lround(touch->y);
@@ -1221,7 +1233,7 @@ _touch_motion_send(Elput_Device *dev)
1221 ev->multi.root.x = touch->x; 1233 ev->multi.root.x = touch->x;
1222 ev->multi.root.y = touch->y; 1234 ev->multi.root.y = touch->y;
1223 1235
1224 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); 1236 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _event_free, ev->dev);
1225} 1237}
1226 1238
1227static void 1239static void
@@ -1361,6 +1373,7 @@ _axis_event_free(void *d EINA_UNUSED, void *event)
1361{ 1373{
1362 Ecore_Event_Axis_Update *ev = event; 1374 Ecore_Event_Axis_Update *ev = event;
1363 1375
1376 if (ev->dev) efl_unref(ev->dev);
1364 free(ev->axis); 1377 free(ev->axis);
1365 free(ev); 1378 free(ev);
1366} 1379}
@@ -1461,6 +1474,7 @@ _tablet_tool_axis(struct libinput_device *idev, struct libinput_event_tablet_too
1461 ev->timestamp = ptr->timestamp; 1474 ev->timestamp = ptr->timestamp;
1462 ev->naxis = num; 1475 ev->naxis = num;
1463 ev->dev = dev->evas_device; 1476 ev->dev = dev->evas_device;
1477 if (ev->dev) efl_ref(ev->dev);
1464 ev->axis = axis = calloc(num, sizeof(Ecore_Axis)); 1478 ev->axis = axis = calloc(num, sizeof(Ecore_Axis));
1465 for (i = 0; i < num; i++) 1479 for (i = 0; i < num; i++)
1466 { 1480 {