summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/elput/Elput.h14
-rw-r--r--src/lib/elput/elput.c3
-rw-r--r--src/lib/elput/elput_input.c50
3 files changed, 61 insertions, 6 deletions
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h
index f8808ceee8..385ea4eb24 100644
--- a/src/lib/elput/Elput.h
+++ b/src/lib/elput/Elput.h
@@ -74,10 +74,24 @@ typedef struct _Elput_Event_Modifiers_Send
74 unsigned int group; 74 unsigned int group;
75} Elput_Event_Modifiers_Send; 75} Elput_Event_Modifiers_Send;
76 76
77typedef enum _Elput_Device_Change_Type
78{
79 ELPUT_DEVICE_ADDED,
80 ELPUT_DEVICE_REMOVED,
81} Elput_Device_Change_Type;
82
83/* structure to represent event for device being added or removed */
84typedef struct _Elput_Event_Device_Change
85{
86 Elput_Device *device;
87 Elput_Device_Change_Type type;
88} Elput_Event_Device_Change;
89
77EAPI extern int ELPUT_EVENT_SEAT_CAPS; 90EAPI extern int ELPUT_EVENT_SEAT_CAPS;
78EAPI extern int ELPUT_EVENT_SEAT_FRAME; 91EAPI extern int ELPUT_EVENT_SEAT_FRAME;
79EAPI extern int ELPUT_EVENT_KEYMAP_SEND; 92EAPI extern int ELPUT_EVENT_KEYMAP_SEND;
80EAPI extern int ELPUT_EVENT_MODIFIERS_SEND; 93EAPI extern int ELPUT_EVENT_MODIFIERS_SEND;
94EAPI extern int ELPUT_EVENT_DEVICE_CHANGE;
81 95
82/** 96/**
83 * @file 97 * @file
diff --git a/src/lib/elput/elput.c b/src/lib/elput/elput.c
index f65da98946..2e54b3ec28 100644
--- a/src/lib/elput/elput.c
+++ b/src/lib/elput/elput.c
@@ -10,6 +10,7 @@ EAPI int ELPUT_EVENT_SEAT_CAPS = -1;
10EAPI int ELPUT_EVENT_SEAT_FRAME = -1; 10EAPI int ELPUT_EVENT_SEAT_FRAME = -1;
11EAPI int ELPUT_EVENT_KEYMAP_SEND = -1; 11EAPI int ELPUT_EVENT_KEYMAP_SEND = -1;
12EAPI int ELPUT_EVENT_MODIFIERS_SEND = -1; 12EAPI int ELPUT_EVENT_MODIFIERS_SEND = -1;
13EAPI int ELPUT_EVENT_DEVICE_CHANGE = -1;
13 14
14EAPI int 15EAPI int
15elput_init(void) 16elput_init(void)
@@ -32,6 +33,7 @@ elput_init(void)
32 ELPUT_EVENT_SEAT_FRAME = ecore_event_type_new(); 33 ELPUT_EVENT_SEAT_FRAME = ecore_event_type_new();
33 ELPUT_EVENT_KEYMAP_SEND = ecore_event_type_new(); 34 ELPUT_EVENT_KEYMAP_SEND = ecore_event_type_new();
34 ELPUT_EVENT_MODIFIERS_SEND = ecore_event_type_new(); 35 ELPUT_EVENT_MODIFIERS_SEND = ecore_event_type_new();
36 ELPUT_EVENT_DEVICE_CHANGE = ecore_event_type_new();
35 37
36 return _elput_init_count; 38 return _elput_init_count;
37 39
@@ -57,6 +59,7 @@ elput_shutdown(void)
57 ELPUT_EVENT_SEAT_FRAME = -1; 59 ELPUT_EVENT_SEAT_FRAME = -1;
58 ELPUT_EVENT_KEYMAP_SEND = -1; 60 ELPUT_EVENT_KEYMAP_SEND = -1;
59 ELPUT_EVENT_MODIFIERS_SEND = -1; 61 ELPUT_EVENT_MODIFIERS_SEND = -1;
62 ELPUT_EVENT_DEVICE_CHANGE = -1;
60 63
61 eina_log_domain_unregister(_elput_log_dom); 64 eina_log_domain_unregister(_elput_log_dom);
62 _elput_log_dom = -1; 65 _elput_log_dom = -1;
diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c
index 499efcf48b..6c43f2f03d 100644
--- a/src/lib/elput/elput_input.c
+++ b/src/lib/elput/elput_input.c
@@ -79,6 +79,41 @@ _udev_seat_get(Elput_Manager *em, struct libinput_device *device)
79} 79}
80 80
81static void 81static void
82_device_event_cb_free(void *data EINA_UNUSED, void *event)
83{
84 Elput_Event_Device_Change *ev;
85
86 ev = event;
87
88 if (ev->type == ELPUT_DEVICE_REMOVED)
89 {
90 Elput_Seat *seat;
91
92 seat = ev->device->seat;
93 if (seat)
94 seat->devices = eina_list_remove(seat->devices, ev->device);
95
96 _evdev_device_destroy(ev->device);
97 }
98
99 free(ev);
100}
101
102static void
103_device_event_send(Elput_Device *edev, Elput_Device_Change_Type type)
104{
105 Elput_Event_Device_Change *ev;
106
107 ev = calloc(1, sizeof(Elput_Event_Device_Change));
108 if (!ev) return;
109
110 ev->device = edev;
111 ev->type = type;
112
113 ecore_event_add(ELPUT_EVENT_DEVICE_CHANGE, ev, _device_event_cb_free, NULL);
114}
115
116static void
82_device_add(Elput_Manager *em, struct libinput_device *dev) 117_device_add(Elput_Manager *em, struct libinput_device *dev)
83{ 118{
84 Elput_Seat *eseat; 119 Elput_Seat *eseat;
@@ -95,22 +130,25 @@ _device_add(Elput_Manager *em, struct libinput_device *dev)
95 eina_stringshare_replace(&edev->output_name, oname); 130 eina_stringshare_replace(&edev->output_name, oname);
96 131
97 eseat->devices = eina_list_append(eseat->devices, edev); 132 eseat->devices = eina_list_append(eseat->devices, edev);
133
134 _device_event_send(edev, ELPUT_DEVICE_ADDED);
98} 135}
99 136
100static void 137static void
101_device_remove(Elput_Manager *em, struct libinput_device *device) 138_device_remove(Elput_Manager *em EINA_UNUSED, struct libinput_device *device)
102{ 139{
103 Elput_Seat *eseat; 140 /* Elput_Seat *eseat; */
104 Elput_Device *edev; 141 Elput_Device *edev;
105 142
106 edev = libinput_device_get_user_data(device); 143 edev = libinput_device_get_user_data(device);
107 if (!edev) return; 144 if (!edev) return;
108 145
109 eseat = _udev_seat_get(em, device); 146 /* eseat = _udev_seat_get(em, device); */
110 if (eseat) 147 /* if (eseat) */
111 eseat->devices = eina_list_remove(eseat->devices, edev); 148 /* eseat->devices = eina_list_remove(eseat->devices, edev); */
112 149
113 _evdev_device_destroy(edev); 150 _device_event_send(edev, ELPUT_DEVICE_REMOVED);
151 /* _evdev_device_destroy(edev); */
114} 152}
115 153
116static int 154static int