diff options
author | 2018-02-14 14:42:06 -0500 | |
---|---|---|
committer | 2018-02-14 14:47:59 -0500 | |
commit | 06c71f115bb0632ef1e75d881d509665198e1eef (patch) | |
tree | df0862e92b6f510f70465514f0258893204b6e6c /sway | |
parent | Implement workspaces (diff) | |
download | sway-06c71f115bb0632ef1e75d881d509665198e1eef.tar.gz sway-06c71f115bb0632ef1e75d881d509665198e1eef.tar.zst sway-06c71f115bb0632ef1e75d881d509665198e1eef.zip |
input device destroy
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/input-manager.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index d789c7eb..f59daea3 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -160,7 +160,32 @@ static void sway_input_manager_libinput_config_pointer(struct sway_input_device | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | static void input_add_notify(struct wl_listener *listener, void *data) { | 163 | static void handle_device_destroy(struct wl_listener *listener, void *data) { |
164 | struct wlr_input_device *device = data; | ||
165 | |||
166 | struct sway_input_device *input_device = | ||
167 | input_sway_device_from_wlr(input_manager, device); | ||
168 | |||
169 | if (!sway_assert(input_device, "could not find sway device")) { | ||
170 | return; | ||
171 | } | ||
172 | |||
173 | wlr_log(L_DEBUG, "removing device: '%s'", | ||
174 | input_device->identifier); | ||
175 | |||
176 | struct sway_seat *seat = NULL; | ||
177 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
178 | sway_seat_remove_device(seat, input_device); | ||
179 | } | ||
180 | |||
181 | wl_list_remove(&input_device->link); | ||
182 | wl_list_remove(&input_device->device_destroy.link); | ||
183 | free_input_config(input_device->config); | ||
184 | free(input_device->identifier); | ||
185 | free(input_device); | ||
186 | } | ||
187 | |||
188 | static void handle_new_input(struct wl_listener *listener, void *data) { | ||
164 | struct sway_input_manager *input = | 189 | struct sway_input_manager *input = |
165 | wl_container_of(listener, input, input_add); | 190 | wl_container_of(listener, input, input_add); |
166 | struct wlr_input_device *device = data; | 191 | struct wlr_input_device *device = data; |
@@ -226,32 +251,9 @@ static void input_add_notify(struct wl_listener *listener, void *data) { | |||
226 | "device '%s' is not configured on any seats", | 251 | "device '%s' is not configured on any seats", |
227 | input_device->identifier); | 252 | input_device->identifier); |
228 | } | 253 | } |
229 | } | ||
230 | |||
231 | static void input_remove_notify(struct wl_listener *listener, void *data) { | ||
232 | struct sway_input_manager *input = | ||
233 | wl_container_of(listener, input, input_remove); | ||
234 | struct wlr_input_device *device = data; | ||
235 | |||
236 | struct sway_input_device *input_device = | ||
237 | input_sway_device_from_wlr(input, device); | ||
238 | |||
239 | if (!sway_assert(input_device, "could not find sway device")) { | ||
240 | return; | ||
241 | } | ||
242 | |||
243 | wlr_log(L_DEBUG, "removing device: '%s'", | ||
244 | input_device->identifier); | ||
245 | |||
246 | struct sway_seat *seat = NULL; | ||
247 | wl_list_for_each(seat, &input->seats, link) { | ||
248 | sway_seat_remove_device(seat, input_device); | ||
249 | } | ||
250 | 254 | ||
251 | wl_list_remove(&input_device->link); | 255 | wl_signal_add(&device->events.destroy, &input_device->device_destroy); |
252 | free_input_config(input_device->config); | 256 | input_device->device_destroy.notify = handle_device_destroy; |
253 | free(input_device->identifier); | ||
254 | free(input_device); | ||
255 | } | 257 | } |
256 | 258 | ||
257 | struct sway_input_manager *sway_input_manager_create( | 259 | struct sway_input_manager *sway_input_manager_create( |
@@ -269,11 +271,8 @@ struct sway_input_manager *sway_input_manager_create( | |||
269 | // create the default seat | 271 | // create the default seat |
270 | input_manager_get_seat(input, default_seat); | 272 | input_manager_get_seat(input, default_seat); |
271 | 273 | ||
272 | input->input_add.notify = input_add_notify; | 274 | input->input_add.notify = handle_new_input; |
273 | wl_signal_add(&server->backend->events.input_add, &input->input_add); | 275 | wl_signal_add(&server->backend->events.new_input, &input->input_add); |
274 | |||
275 | input->input_remove.notify = input_remove_notify; | ||
276 | wl_signal_add(&server->backend->events.input_remove, &input->input_remove); | ||
277 | 276 | ||
278 | return input; | 277 | return input; |
279 | } | 278 | } |