Turn on backlight on short click
authorEnrico Zini <enrico@enricozini.org>
Sun, 16 Aug 2009 14:58:13 +0000 (15:58 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sun, 16 Aug 2009 14:58:13 +0000 (15:58 +0100)
src/app_power.vala

index 98d351ab4937471e4935d856ad74d346c198dcf2..ccf36d8a909715480ac0b1a4ab2501920c44d830 100644 (file)
@@ -85,15 +85,21 @@ public class Power : zavai.Resource, Object
                screen_locked = locked;
        }
 
-       private void on_power_button(Posix.timeval* time, bool pressed)
+       private void on_power_button(Posix.timeval* t, bool pressed)
        {
                if (!pressed)
                {
                        if (screen_locked)
                        {
-                               // TODO: short press: turn on backlight for a bit
-                               // TODO: long press: unlock
-                               set_screen_lock(false);
+                               time_t now = new time_t();
+                               if (now < t->tv_sec + 2)
+                               {
+                                       // Short press: turn on backlight for a bit
+                                       backlight.wiggle();
+                               } else {
+                                       // Long press: unlock
+                                       set_screen_lock(false);
+                               }
                        }
                        else
                        {
@@ -245,6 +251,14 @@ public class Backlight: zavai.Service
                        "org.freesmartphone.Usage");
        }
 
+       // Turn the backlight and then let it fade off
+       public void wiggle()
+       {
+               // There must be a better method
+               usage.RequestResource("Display");
+               usage.ReleaseResource("Display");
+       }
+
        /// Request GPS resource
        public override void start()
        {