uterm: add WAKEUP and SLEEP signals
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 23 Jun 2012 23:01:47 +0000 (01:01 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sat, 23 Jun 2012 23:01:47 +0000 (01:01 +0200)
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>
src/uterm.h
src/uterm_video.c

index 413d600..c65689b 100644 (file)
@@ -146,6 +146,8 @@ enum uterm_video_type {
 };
 
 enum uterm_video_action {
+       UTERM_WAKE_UP,
+       UTERM_SLEEP,
        UTERM_NEW,
        UTERM_GONE,
 };
index 02f3a79..5b74eee 100644 (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)