mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
backend/session: simplify udev event action matching
This avoids extra strcmp() calls and is easier to read.
This commit is contained in:
parent
d5d650f9f6
commit
89000b7df0
1 changed files with 10 additions and 10 deletions
|
|
@ -206,27 +206,27 @@ static int handle_udev_event(int fd, uint32_t mask, void *data) {
|
||||||
.path = devnode,
|
.path = devnode,
|
||||||
};
|
};
|
||||||
wl_signal_emit_mutable(&session->events.add_drm_card, &event);
|
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;
|
struct wlr_device *dev;
|
||||||
wl_list_for_each(dev, &session->devices, link) {
|
wl_list_for_each(dev, &session->devices, link) {
|
||||||
if (dev->dev != devnum) {
|
if (dev->dev == devnum) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(action, "change") == 0) {
|
|
||||||
wlr_log(WLR_DEBUG, "DRM device %s changed", sysname);
|
wlr_log(WLR_DEBUG, "DRM device %s changed", sysname);
|
||||||
struct wlr_device_change_event event = {0};
|
struct wlr_device_change_event event = {0};
|
||||||
read_udev_change_event(&event, udev_dev);
|
read_udev_change_event(&event, udev_dev);
|
||||||
wl_signal_emit_mutable(&dev->events.change, &event);
|
wl_signal_emit_mutable(&dev->events.change, &event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (strcmp(action, "remove") == 0) {
|
} 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);
|
wlr_log(WLR_DEBUG, "DRM device %s removed", sysname);
|
||||||
wl_signal_emit_mutable(&dev->events.remove, NULL);
|
wl_signal_emit_mutable(&dev->events.remove, NULL);
|
||||||
} else {
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
udev_device_unref(udev_dev);
|
udev_device_unref(udev_dev);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue