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,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue