backend/session: introduce wlr_session.events.add_drm_card
This is triggered when a new DRM card is added. An easy way to test this patch is `modprobe vkms`.
This commit is contained in:
parent
768fbaad54
commit
76bcddf071
|
@ -55,19 +55,37 @@ static int udev_event(int fd, uint32_t mask, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sysname = udev_device_get_sysname(udev_dev);
|
const char *sysname = udev_device_get_sysname(udev_dev);
|
||||||
|
const char *devnode = udev_device_get_devnode(udev_dev);
|
||||||
const char *action = udev_device_get_action(udev_dev);
|
const char *action = udev_device_get_action(udev_dev);
|
||||||
wlr_log(WLR_DEBUG, "udev event for %s (%s)", sysname, action);
|
wlr_log(WLR_DEBUG, "udev event for %s (%s)", sysname, action);
|
||||||
|
|
||||||
if (!is_drm_card(sysname) || !action || strcmp(action, "change") != 0) {
|
if (!is_drm_card(sysname) || !action || !devnode) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_t devnum = udev_device_get_devnum(udev_dev);
|
const char *seat = udev_device_get_property_value(udev_dev, "ID_SEAT");
|
||||||
struct wlr_device *dev;
|
if (!seat) {
|
||||||
wl_list_for_each(dev, &session->devices, link) {
|
seat = "seat0";
|
||||||
if (dev->dev == devnum) {
|
}
|
||||||
wlr_signal_emit_safe(&dev->events.change, NULL);
|
if (session->seat[0] != '\0' && strcmp(session->seat, seat) != 0) {
|
||||||
break;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(action, "add") == 0) {
|
||||||
|
wlr_log(WLR_DEBUG, "DRM device %s added", sysname);
|
||||||
|
struct wlr_session_add_event event = {
|
||||||
|
.path = devnode,
|
||||||
|
};
|
||||||
|
wlr_signal_emit_safe(&session->events.add_drm_card, &event);
|
||||||
|
} else if (strcmp(action, "change") == 0) {
|
||||||
|
dev_t devnum = udev_device_get_devnum(udev_dev);
|
||||||
|
struct wlr_device *dev;
|
||||||
|
wl_list_for_each(dev, &session->devices, link) {
|
||||||
|
if (dev->dev == devnum) {
|
||||||
|
wlr_log(WLR_DEBUG, "DRM device %s changed", sysname);
|
||||||
|
wlr_signal_emit_safe(&dev->events.change, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +102,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
void session_init(struct wlr_session *session) {
|
void session_init(struct wlr_session *session) {
|
||||||
wl_signal_init(&session->session_signal);
|
wl_signal_init(&session->session_signal);
|
||||||
|
wl_signal_init(&session->events.add_drm_card);
|
||||||
wl_signal_init(&session->events.destroy);
|
wl_signal_init(&session->events.destroy);
|
||||||
wl_list_init(&session->devices);
|
wl_list_init(&session->devices);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,15 @@ struct wlr_session {
|
||||||
struct wl_listener display_destroy;
|
struct wl_listener display_destroy;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
struct wl_signal add_drm_card; // struct wlr_session_add_event
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wlr_session_add_event {
|
||||||
|
const char *path;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Opens a session, taking control of the current virtual terminal.
|
* Opens a session, taking control of the current virtual terminal.
|
||||||
* This should not be called if another program is already in control
|
* This should not be called if another program is already in control
|
||||||
|
|
Loading…
Reference in New Issue