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:42 -0400
commit4c7c613e768febdec27324527ccd320c4aa090db (patch)
treecd33c8589ccd4ae19fe664e4d6f47eac97d04468 /src/lib/elput/elput_evdev.c
parent539c2169b57518fa361c87961c98014dfeba40ff (diff)
elput: add refcounting for seats/devices
ensure lifetimes persist through events @fix
Diffstat (limited to '')
-rw-r--r--src/lib/elput/elput_evdev.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index be7c5800fd..33c4772ec7 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -1,6 +1,12 @@
1#include "elput_private.h" 1#include "elput_private.h"
2 2
3static void 3static void
4_seat_event_free(void *d, void *ev EINA_UNUSED)
5{
6 _udev_seat_destroy(d);
7}
8
9static void
4_seat_caps_update(Elput_Seat *seat) 10_seat_caps_update(Elput_Seat *seat)
5{ 11{
6 Elput_Event_Seat_Caps *ev; 12 Elput_Event_Seat_Caps *ev;
@@ -12,8 +18,9 @@ _seat_caps_update(Elput_Seat *seat)
12 ev->keyboard_count = seat->count.kbd; 18 ev->keyboard_count = seat->count.kbd;
13 ev->touch_count = seat->count.touch; 19 ev->touch_count = seat->count.touch;
14 ev->seat = seat; 20 ev->seat = seat;
21 seat->refs++;
15 22
16 ecore_event_add(ELPUT_EVENT_SEAT_CAPS, ev, NULL, NULL); 23 ecore_event_add(ELPUT_EVENT_SEAT_CAPS, ev, _seat_event_free, seat);
17} 24}
18 25
19static void 26static void
@@ -25,7 +32,8 @@ _seat_frame_send(Elput_Seat *seat)
25 if (!ev) return; 32 if (!ev) return;
26 33
27 ev->seat = seat; 34 ev->seat = seat;
28 ecore_event_add(ELPUT_EVENT_SEAT_FRAME, ev, NULL, NULL); 35 seat->refs++;
36 ecore_event_add(ELPUT_EVENT_SEAT_FRAME, ev, _seat_event_free, seat);
29} 37}
30 38
31static void 39static void
@@ -1558,6 +1566,7 @@ _evdev_device_create(Elput_Seat *seat, struct libinput_device *device)
1558 edev = calloc(1, sizeof(Elput_Device)); 1566 edev = calloc(1, sizeof(Elput_Device));
1559 if (!edev) return NULL; 1567 if (!edev) return NULL;
1560 1568
1569 edev->refs = 1;
1561 edev->seat = seat; 1570 edev->seat = seat;
1562 edev->device = device; 1571 edev->device = device;
1563 edev->caps = 0; 1572 edev->caps = 0;
@@ -1621,6 +1630,8 @@ void
1621_evdev_device_destroy(Elput_Device *edev) 1630_evdev_device_destroy(Elput_Device *edev)
1622{ 1631{
1623 if (!edev) return; 1632 if (!edev) return;
1633 edev->refs--;
1634 if (edev->refs) return;
1624 1635
1625 if (edev->caps & ELPUT_DEVICE_CAPS_POINTER) 1636 if (edev->caps & ELPUT_DEVICE_CAPS_POINTER)
1626 _pointer_release(edev->seat); 1637 _pointer_release(edev->seat);