backend/session: replace session_signal with events.active

This is more idiomatic wlroots API. The new name makes it clear that the
signal is emitted when wlr_session.active changes.
This commit is contained in:
Simon Ser 2020-11-06 11:34:55 +01:00
parent cd95d70df0
commit 0e76f92de7
8 changed files with 16 additions and 16 deletions

View file

@ -85,7 +85,7 @@ bool wlr_backend_is_drm(struct wlr_backend *b) {
static void session_signal(struct wl_listener *listener, void *data) {
struct wlr_drm_backend *drm =
wl_container_of(listener, drm, session_signal);
struct wlr_session *session = data;
struct wlr_session *session = drm->session;
if (session->active) {
wlr_log(WLR_INFO, "DRM fd resumed");
@ -170,7 +170,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
}
drm->session_signal.notify = session_signal;
wl_signal_add(&session->session_signal, &drm->session_signal);
wl_signal_add(&session->events.active, &drm->session_signal);
if (!check_drm_features(drm)) {
goto error_event;

View file

@ -175,7 +175,7 @@ bool wlr_backend_is_libinput(struct wlr_backend *b) {
static void session_signal(struct wl_listener *listener, void *data) {
struct wlr_libinput_backend *backend =
wl_container_of(listener, backend, session_signal);
struct wlr_session *session = data;
struct wlr_session *session = backend->session;
if (!backend->libinput_context) {
return;
@ -219,7 +219,7 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
backend->display = display;
backend->session_signal.notify = session_signal;
wl_signal_add(&session->session_signal, &backend->session_signal);
wl_signal_add(&session->events.active, &backend->session_signal);
backend->session_destroy.notify = handle_session_destroy;
wl_signal_add(&session->events.destroy, &backend->session_destroy);

View file

@ -115,7 +115,7 @@ static int vt_handler(int signo, void *data) {
if (session->base.active) {
session->base.active = false;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
wl_list_for_each(dev, &session->base.devices, link) {
if (ioctl(dev->fd, DRM_IOCTL_VERSION, &dv) == 0) {
@ -134,7 +134,7 @@ static int vt_handler(int signo, void *data) {
}
session->base.active = true;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
}
return 1;

View file

@ -126,7 +126,7 @@ static int vt_handler(int signo, void *data) {
if (session->base.active) {
session->base.active = false;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
struct wlr_device *dev;
wl_list_for_each(dev, &session->base.devices, link) {
@ -149,7 +149,7 @@ static int vt_handler(int signo, void *data) {
}
session->base.active = true;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
}
return 1;

View file

@ -35,13 +35,13 @@ struct libseat_session {
static void handle_enable_seat(struct libseat *seat, void *data) {
struct libseat_session *session = data;
session->base.active = true;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
}
static void handle_disable_seat(struct libseat *seat, void *data) {
struct libseat_session *session = data;
session->base.active = false;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
libseat_disable_seat(session->seat);
}

View file

@ -306,7 +306,7 @@ static int pause_device(sd_bus_message *msg, void *userdata,
if (major == DRM_MAJOR && strcmp(type, "gone") != 0) {
assert(session->has_drm);
session->base.active = false;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
}
if (strcmp(type, "pause") == 0) {
@ -348,7 +348,7 @@ static int resume_device(sd_bus_message *msg, void *userdata,
if (!session->base.active) {
session->base.active = true;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
}
}
@ -407,7 +407,7 @@ static int session_properties_changed(sd_bus_message *msg, void *userdata,
if (session->base.active != active) {
session->base.active = active;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
}
return 0;
} else {
@ -447,7 +447,7 @@ static int session_properties_changed(sd_bus_message *msg, void *userdata,
if (session->base.active != active) {
session->base.active = active;
wlr_signal_emit_safe(&session->base.session_signal, session);
wlr_signal_emit_safe(&session->base.events.active, NULL);
}
return 0;
}

View file

@ -101,7 +101,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
}
void session_init(struct wlr_session *session) {
wl_signal_init(&session->session_signal);
wl_signal_init(&session->events.active);
wl_signal_init(&session->events.add_drm_card);
wl_signal_init(&session->events.destroy);
wl_list_init(&session->devices);

View file

@ -24,7 +24,6 @@ struct wlr_session {
* Signal for when the session becomes active/inactive.
* It's called when we swap virtual terminal.
*/
struct wl_signal session_signal;
bool active;
/*
@ -44,6 +43,7 @@ struct wlr_session {
struct wl_listener display_destroy;
struct {
struct wl_signal active;
struct wl_signal add_drm_card; // struct wlr_session_add_event
struct wl_signal destroy;
} events;