Output: Correctly acquire/release DRM master
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 3 Dec 2011 15:39:06 +0000 (16:39 +0100)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 3 Dec 2011 15:39:06 +0000 (16:39 +0100)
If we switch VT, we must release DRM master to allow other applications to
access the DRM. When waking up the compositor we try to acquire the master again
to access the DRM.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/output.c

index 02bad14..857792f 100644 (file)
@@ -929,8 +929,11 @@ void kmscon_compositor_unref(struct kmscon_compositor *comp)
  */
 void kmscon_compositor_sleep(struct kmscon_compositor *comp)
 {
-       if (comp)
-               comp->state = COMPOSITOR_ASLEEP;
+       if (!comp)
+               return;
+
+       comp->state = COMPOSITOR_ASLEEP;
+       drmDropMaster(comp->drm_fd);
 }
 
 /*
@@ -946,10 +949,14 @@ int kmscon_compositor_wake_up(struct kmscon_compositor *comp)
 
        if (!comp)
                return -EINVAL;
-       
+
        if (comp->state == COMPOSITOR_AWAKE)
                return comp->count_outputs;
 
+       ret = drmSetMaster(comp->drm_fd);
+       if (ret)
+               return -EACCES;
+
        comp->state = COMPOSITOR_AWAKE;
        ret = kmscon_compositor_refresh(comp);
        if (ret >= 0)