Turn off backlight when locking screen, unless backlight is needed
authorEnrico Zini <enrico@enricozini.org>
Sat, 22 Aug 2009 21:42:08 +0000 (22:42 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sat, 22 Aug 2009 21:42:08 +0000 (22:42 +0100)
src/app_power.vala

index b91b93791d23b12ea1fb91697789720e1fb564a7..1f34c80fae7cf4d86dce62f6a51024fe1d7ac992 100644 (file)
@@ -121,6 +121,8 @@ public class Power : zavai.Resource, Object
                                Posix.close(screen_lock_fd);
                                return;
                        }
+
+                       backlight.turn_off_unless_needed();
                } else {
                        Posix.close(screen_lock_fd);
                }
@@ -335,6 +337,7 @@ public class RebootButton : Gtk.Button
 public class Backlight: zavai.Service
 {
        public dynamic DBus.Object usage;
+       public dynamic DBus.Object display;
 
        public Backlight()
        {
@@ -344,6 +347,11 @@ public class Backlight: zavai.Service
                        "org.freesmartphone.ousaged",
                        "/org/freesmartphone/Usage",
                        "org.freesmartphone.Usage");
+
+               display = zavai.registry.sbus.get_object(
+                       "org.freesmartphone.odeviced",
+                       "/org/freesmartphone/Device/Display/0",
+                       "org.freesmartphone.Device.Display");
        }
 
        // Turn the backlight and then let it fade off
@@ -358,6 +366,18 @@ public class Backlight: zavai.Service
                }
        }
 
+       public void turn_off_unless_needed()
+       {
+               if (!started)
+               {
+                       try {
+                               display.SetBacklightPower(false);
+                       } catch (GLib.Error e) {
+                               zavai.log.error(e.message);
+                       }
+               }
+       }
+
        /// Request GPS resource
        public override void start()
        {