[PATCH weston 3/4] logind: forward Active=true changes for non-DRM backends
David Herrmann
dh.herrmann at gmail.com
Tue Dec 30 05:33:22 PST 2014
Logind sends us notification whenever the Active attribute of our session
changes. However, due to the way compositor-drm.c relies on the master DRM
device to be synced with the session, we used to delay Active=true
handling until the DRM device was up, too. See:
commit aedc7732ebd9bc7b4f51ee247ea857ffec6260a7
Author: David Herrmann <dh.herrmann at gmail.com>
Date: Sat Nov 30 11:25:45 2013 +0100
logind: delay wakeup until DRM-device is resumed
However, the other compositor backends do not use DRM, so logind-util will
never get notified about any DRM device. Therefore, we have to forward the
Active=true change immediately.
This commit fixes logind-util to take sync_drm as argument. If it is true,
we do DRM-device synchronisation, otherwise we don't.
Signed-off-by: David Herrmann <dh.herrmann at gmail.com>
---
src/compositor-drm.c | 2 +-
src/compositor-fbdev.c | 5 +++--
src/compositor-rpi.c | 5 +++--
src/launcher-util.c | 4 ++--
src/launcher-util.h | 2 +-
src/logind-util.c | 16 +++++++++++-----
src/logind-util.h | 4 ++--
7 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 9b4d4dc..4473254 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2774,7 +2774,7 @@ drm_compositor_create(struct wl_display *display,
/* Check if we run drm-backend using weston-launch */
ec->base.launcher = weston_launcher_connect(&ec->base, param->tty,
- param->seat_id);
+ param->seat_id, true);
if (ec->base.launcher == NULL) {
weston_log("fatal: drm backend should be run "
"using weston-launch binary or as root\n");
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 65bb035..805a195 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -891,8 +891,9 @@ fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],
compositor->session_listener.notify = session_notify;
wl_signal_add(&compositor->base.session_signal,
&compositor->session_listener);
- compositor->base.launcher =
- weston_launcher_connect(&compositor->base, param->tty, "seat0");
+ compositor->base.launcher = weston_launcher_connect(&compositor->base,
+ param->tty, "seat0",
+ false);
if (!compositor->base.launcher) {
weston_log("fatal: fbdev backend should be run "
"using weston-launch binary or as root\n");
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 150e9e1..a064a86 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -480,8 +480,9 @@ rpi_compositor_create(struct wl_display *display, int *argc, char *argv[],
compositor->session_listener.notify = session_notify;
wl_signal_add(&compositor->base.session_signal,
&compositor ->session_listener);
- compositor->base.launcher =
- weston_launcher_connect(&compositor->base, param->tty, "seat0");
+ compositor->base.launcher = weston_launcher_connect(&compositor->base,
+ param->tty, "seat0",
+ false);
if (!compositor->base.launcher) {
weston_log("Failed to initialize tty.\n");
goto out_udev;
diff --git a/src/launcher-util.c b/src/launcher-util.c
index ad81aef..e89710b 100644
--- a/src/launcher-util.c
+++ b/src/launcher-util.c
@@ -386,7 +386,7 @@ weston_launcher_activate_vt(struct weston_launcher *launcher, int vt)
struct weston_launcher *
weston_launcher_connect(struct weston_compositor *compositor, int tty,
- const char *seat_id)
+ const char *seat_id, bool sync_drm)
{
struct weston_launcher *launcher;
struct wl_event_loop *loop;
@@ -418,7 +418,7 @@ weston_launcher_connect(struct weston_compositor *compositor, int tty,
}
} else {
r = weston_logind_connect(&launcher->logind, compositor,
- seat_id, tty);
+ seat_id, tty, sync_drm);
if (r < 0) {
launcher->logind = NULL;
if (geteuid() == 0) {
diff --git a/src/launcher-util.h b/src/launcher-util.h
index d5b2fc9..a60f8a1 100644
--- a/src/launcher-util.h
+++ b/src/launcher-util.h
@@ -31,7 +31,7 @@ struct weston_launcher;
struct weston_launcher *
weston_launcher_connect(struct weston_compositor *compositor, int tty,
- const char *seat_id);
+ const char *seat_id, bool sync_drm);
void
weston_launcher_destroy(struct weston_launcher *launcher);
diff --git a/src/logind-util.c b/src/logind-util.c
index 132a9a2..db23606 100644
--- a/src/logind-util.c
+++ b/src/logind-util.c
@@ -51,6 +51,7 @@
struct weston_logind {
struct weston_compositor *compositor;
+ bool sync_drm;
char *seat;
char *sid;
unsigned int vtnr;
@@ -315,8 +316,12 @@ get_active_cb(DBusPendingCall *pending, void *data)
goto err_unref;
dbus_message_iter_get_basic(&sub, &b);
- if (!b)
- weston_logind_set_active(wl, false);
+
+ /* If the backend requested DRM master-device synchronization, we only
+ * wake-up the compositor once the master-device is up and running. For
+ * other backends, we immediately forward the Active-change event. */
+ if (!wl->sync_drm || !b)
+ weston_logind_set_active(wl, b);
err_unref:
dbus_message_unref(m);
@@ -490,7 +495,7 @@ device_paused(struct weston_logind *wl, DBusMessage *m)
if (!strcmp(type, "pause"))
weston_logind_pause_device_complete(wl, major, minor);
- if (major == DRM_MAJOR)
+ if (wl->sync_drm && major == DRM_MAJOR)
weston_logind_set_active(wl, false);
}
@@ -516,7 +521,7 @@ device_resumed(struct weston_logind *wl, DBusMessage *m)
* there is no need for us to handle this event for evdev. For DRM, we
* notify the compositor to wake up. */
- if (major == DRM_MAJOR)
+ if (wl->sync_drm && major == DRM_MAJOR)
weston_logind_set_active(wl, true);
}
@@ -835,7 +840,7 @@ weston_logind_destroy_vt(struct weston_logind *wl)
WL_EXPORT int
weston_logind_connect(struct weston_logind **out,
struct weston_compositor *compositor,
- const char *seat_id, int tty)
+ const char *seat_id, int tty, bool sync_drm)
{
struct weston_logind *wl;
struct wl_event_loop *loop;
@@ -849,6 +854,7 @@ weston_logind_connect(struct weston_logind **out,
}
wl->compositor = compositor;
+ wl->sync_drm = sync_drm;
wl->seat = strdup(seat_id);
if (!wl->seat) {
diff --git a/src/logind-util.h b/src/logind-util.h
index 552395e..0dd9f68 100644
--- a/src/logind-util.h
+++ b/src/logind-util.h
@@ -51,7 +51,7 @@ weston_logind_activate_vt(struct weston_logind *wl, int vt);
int
weston_logind_connect(struct weston_logind **out,
struct weston_compositor *compositor,
- const char *seat_id, int tty);
+ const char *seat_id, int tty, bool sync_drm);
void
weston_logind_destroy(struct weston_logind *wl);
@@ -107,7 +107,7 @@ weston_logind_activate_vt(struct weston_logind *wl, int vt)
static inline int
weston_logind_connect(struct weston_logind **out,
struct weston_compositor *compositor,
- const char *seat_id, int tty)
+ const char *seat_id, int tty, bool sync_drm)
{
return -ENOSYS;
}
--
2.2.1
More information about the wayland-devel
mailing list