Alternate way to blank screen on lock
authorEnrico Zini <enrico@enricozini.org>
Sat, 22 Aug 2009 22:00:35 +0000 (23:00 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sat, 22 Aug 2009 22:00:35 +0000 (23:00 +0100)
src/app_power.vala

index 68dfc0f3b2c934f41c344cdc8c8931637b6ac9db..bdff61af361a59d5b4d488d8808de8825eccff3b 100644 (file)
@@ -124,9 +124,10 @@ public class Power : zavai.Resource, Object
                                return;
                        }
 
-                       backlight.turn_off_unless_needed();
+                       backlight.lock_screen();
                } else {
                        Posix.close(screen_lock_fd);
+                       backlight.unlock_screen();
                }
                screen_locked = locked;
                if (!locked)
@@ -363,6 +364,7 @@ public class Backlight: zavai.Service
        {
                // There must be a better method
                try {
+                       usage.SetResourcePolicy("Display", "auto");
                        usage.RequestResource("Display");
                        usage.ReleaseResource("Display");
                } catch (Error e) {
@@ -370,7 +372,7 @@ public class Backlight: zavai.Service
                }
        }
 
-       public void turn_off_unless_needed()
+       public void lock_screen()
        {
                if (!started)
                {
@@ -380,7 +382,6 @@ public class Backlight: zavai.Service
                                if (policy == "auto")
                                {
                                        usage.SetResourcePolicy("Display", "disabled");
-                                       usage.SetResourcePolicy("Display", "auto");
                                }
                        } catch (GLib.Error e) {
                                zavai.log.error(e.message);
@@ -388,6 +389,16 @@ public class Backlight: zavai.Service
                }
        }
 
+       public void unlock_screen()
+       {
+               try {
+                       usage.SetResourcePolicy("Display", "auto");
+               } catch (GLib.Error e) {
+                       zavai.log.error(e.message);
+               }
+       }
+
+
        /// Request GPS resource
        public override void start()
        {