uterm: add WAKEUP and SLEEP signals

Notify all listeners when going to sleep or waking up. This allows saving
energy in the listeners by not redrawing the screen while being asleep.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-06-24 01:01:47 +02:00
parent c8fbc14425
commit eec3f2ad85
2 changed files with 11 additions and 1 deletions

View File

@ -146,6 +146,8 @@ enum uterm_video_type {
};
enum uterm_video_action {
UTERM_WAKE_UP,
UTERM_SLEEP,
UTERM_NEW,
UTERM_GONE,
};

View File

@ -488,17 +488,25 @@ void uterm_video_sleep(struct uterm_video *video)
if (!video || !video_is_awake(video))
return;
VIDEO_CB(video, NULL, UTERM_SLEEP);
VIDEO_CALL(video->ops->sleep, 0, video);
}
int uterm_video_wake_up(struct uterm_video *video)
{
int ret;
if (!video)
return -EINVAL;
if (video_is_awake(video))
return 0;
return VIDEO_CALL(video->ops->wake_up, 0, video);
ret = VIDEO_CALL(video->ops->wake_up, 0, video);
if (ret)
return ret;
VIDEO_CB(video, NULL, UTERM_WAKE_UP);
return 0;
}
bool uterm_video_is_awake(struct uterm_video *video)