commit b8c441e

Michael Forney  ·  2014-01-22 23:51:53 +0000 UTC
parent ab2d2db
seat: Remove device if reopening failed
2 files changed,  +12, -4
+2, -1
 1@@ -286,7 +286,8 @@ bool swc_evdev_device_reopen(struct swc_evdev_device * device)
 2 
 3     if (device->fd == -1)
 4     {
 5-        ERROR("Failed to open input device at %s\n", device->path);
 6+        WARNING("Failed to reopen input device at %s: %s\n",
 7+                device->path, strerror(errno));
 8         goto error0;
 9     }
10 
+10, -3
 1@@ -141,14 +141,21 @@ static struct wl_listener data_device_listener = {
 2 static void handle_launch_event(struct wl_listener * listener, void * data)
 3 {
 4     struct swc_event * event = data;
 5-    struct swc_evdev_device * device;
 6+    struct swc_evdev_device * device, * next;
 7 
 8     switch (event->type)
 9     {
10         case SWC_LAUNCH_EVENT_ACTIVATED:
11             /* Re-open all input devices */
12-            wl_list_for_each(device, &seat.devices, link)
13-                swc_evdev_device_reopen(device);
14+            wl_list_for_each_safe(device, next, &seat.devices, link)
15+            {
16+                if (!swc_evdev_device_reopen(device))
17+                {
18+                    wl_list_remove(&device->link);
19+                    swc_evdev_device_destroy(device);
20+                }
21+            }
22+
23             break;
24     }
25 }