backend/session: simplify udev event action matching

This avoids extra strcmp() calls and is easier to read.
This commit is contained in:
Kirill Primak 2025-01-08 20:31:47 +03:00
parent d5d650f9f6
commit 89000b7df0

View file

@ -206,25 +206,25 @@ static int handle_udev_event(int fd, uint32_t mask, void *data) {
.path = devnode,
};
wl_signal_emit_mutable(&session->events.add_drm_card, &event);
} else if (strcmp(action, "change") == 0 || strcmp(action, "remove") == 0) {
} else if (strcmp(action, "change") == 0) {
struct wlr_device *dev;
wl_list_for_each(dev, &session->devices, link) {
if (dev->dev != devnum) {
continue;
}
if (strcmp(action, "change") == 0) {
if (dev->dev == devnum) {
wlr_log(WLR_DEBUG, "DRM device %s changed", sysname);
struct wlr_device_change_event event = {0};
read_udev_change_event(&event, udev_dev);
wl_signal_emit_mutable(&dev->events.change, &event);
} else if (strcmp(action, "remove") == 0) {
break;
}
}
} else if (strcmp(action, "remove") == 0) {
struct wlr_device *dev;
wl_list_for_each(dev, &session->devices, link) {
if (dev->dev == devnum) {
wlr_log(WLR_DEBUG, "DRM device %s removed", sysname);
wl_signal_emit_mutable(&dev->events.remove, NULL);
} else {
assert(0);
break;
}
break;
}
}