Show clock on double power short press
authorEnrico Zini <enrico@enricozini.org>
Sat, 22 Aug 2009 22:43:33 +0000 (23:43 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sat, 22 Aug 2009 22:43:33 +0000 (23:43 +0100)
src/app_power.vala

index a4227a6be82bbe2c55d51113a43c243d9ebaf7f5..5dc5f8d1ef55d8ebc5715425f50e2733e67ebcd8 100644 (file)
@@ -38,6 +38,7 @@ public class Power : zavai.Resource, Object
        // Timestamp of the past power button pressed even (0 if the button has
        // been released)
        private Posix.timeval last_down;
+       private Posix.timeval last_short_press;
 
        private bool hide_after_closing_power_menu;
 
@@ -54,6 +55,8 @@ public class Power : zavai.Resource, Object
                hide_after_closing_power_menu = false;
                last_down.tv_sec = 0;
                last_down.tv_usec = 0;
+               last_short_press.tv_sec = 0;
+               last_short_press.tv_usec = 0;
                button_press_timeout = 0;
 
                usage = zavai.registry.sbus.get_object(
@@ -190,9 +193,20 @@ public class Power : zavai.Resource, Object
 
        private void on_power_short_press(Posix.timeval* t)
        {
+               long diff = timediff(t, &last_short_press);
+               bool combo = diff <= 1000000;
+               last_short_press = *t;
+
                if (screen_locked)
+               {
                        // Short press: turn on backlight for a bit
                        backlight.wiggle();
+                       if (combo)
+                       {
+                               app.back_to_main();
+                               app.toggle_visibility();
+                       }
+               }
                else
                        // Short press: toggle power menu
                        power_menu.toggle();