logind: forward Active=true changes for non-DRM backends
authorDavid Herrmann <dh.herrmann@gmail.com>
Tue, 30 Dec 2014 13:33:22 +0000 (14:33 +0100)
committerBryce Harrington <bryce@osg.samsung.com>
Sat, 17 Jan 2015 02:34:10 +0000 (18:34 -0800)
Logind sends us a 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@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.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=86889
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Tested-by: nerdopolis <bluescreen_avenger@verizon.net>
src/compositor-drm.c
src/compositor-fbdev.c
src/compositor-rpi.c
src/launcher-util.c
src/launcher-util.h
src/logind-util.c
src/logind-util.h

index 9b4d4dcf0031742da67c5b66216ad65ba6917c37..44732549bd95197698fbbadeb51139fe89de992c 100644 (file)
@@ -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");
index 65bb03528cbdbb3a682dcea12d3b5b2e6476641a..805a195a51da7b1b1dfb2828ee448d01893ab2da 100644 (file)
@@ -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");
index 150e9e1d15f2f4eb4c1c6d8db51e1fcb823a9460..a064a86b790737c1a428b2d78b7d84b1062c39ca 100644 (file)
@@ -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;
index ad81aef72c7fee731c5574b5ae951ecbc7229b34..e89710bcc6289f67331ce4e441e3cdedce904d00 100644 (file)
@@ -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) {
index d5b2fc98aabae4eaf52581c74f1c9685c3272c77..a60f8a1a60842715da86347ee5af8511519f3b78 100644 (file)
@@ -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);
index 132a9a2dd7b865afeda4eea133000c3fdab9fce6..db23606fdf0ac262bd6e27642ce842a11869b12a 100644 (file)
@@ -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) {
index 552395e7f777ca0082bd8ba950bb242158d64714..0dd9f680b5aa0ee988a658580af05fc0aa09374d 100644 (file)
@@ -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;
 }