logind: delay wakeup until DRM-device is resumed
authorDavid Herrmann <dh.herrmann@gmail.com>
Sat, 30 Nov 2013 10:25:45 +0000 (11:25 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 3 Dec 2013 20:57:01 +0000 (12:57 -0800)
commitaedc7732ebd9bc7b4f51ee247ea857ffec6260a7
treeabc3b417b038f05296cbd0f659729999ae12918b
parentea997ac6967b7e9018797ae946d18420113ad176
logind: delay wakeup until DRM-device is resumed

The logind API was designed to allow any kind of devices and any number of
devices. It has no idea of "main DRM device" or similar. However, the
weston DRM backend was designed with a single DRM device as master.
Therefore, we wake it up unconditionally on session-wakeup. But this may
fail with logind as a session may be awake, but not all devices have been
resumed, yet.

Therefore, we change the weston-logind backend to deal with this case
correctly. Instead of waking up the compositor on session-wakeup, we wait
for the main DRM device to wake up. Once we get the event, we notify the
compositor.

For sleep, we reverse this logic. On *any* of the following events we
tell the compositor to go to sleep:
 - Session gets inactive
 - DRM device gets inactive
 - DRM device is removed
This guarantees, that weston is only active if *both*, the session and the
main DRM device are awake/active.

Note that we could actually rely solely on the DRM-device Pause/Resume
events from logind and drop all the Active-Prop-Changed handling. logind
guarantees proper ordering of both. However, in case we ever change weston
to support multiple GPUs, we need the per-device notification. Thus, keep
the code. This also makes weston more fail-safe in case logind fails to
send the PauseDevice event (for whatever reason..).
src/logind-util.c