| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "power_manager/powerd.h" | 5 #include "power_manager/powerd.h" |
| 6 | 6 |
| 7 #include <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <X11/extensions/dpms.h> | 9 #include <X11/extensions/dpms.h> |
| 10 #include <X11/keysym.h> | 10 #include <X11/keysym.h> |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 327 } |
| 328 GenerateMetricsOnIdleEvent(is_idle, idle_time_ms); | 328 GenerateMetricsOnIdleEvent(is_idle, idle_time_ms); |
| 329 SetIdleState(idle_time_ms); | 329 SetIdleState(idle_time_ms); |
| 330 if (!is_idle && offset_ms_ != 0) | 330 if (!is_idle && offset_ms_ != 0) |
| 331 SetIdleOffset(0, kIdleNormal); | 331 SetIdleOffset(0, kIdleNormal); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void Daemon::SetIdleState(int64 idle_time_ms) { | 334 void Daemon::SetIdleState(int64 idle_time_ms) { |
| 335 bool changed_brightness = false; | 335 bool changed_brightness = false; |
| 336 if (idle_time_ms >= suspend_ms_) { | 336 if (idle_time_ms >= suspend_ms_) { |
| 337 LOG(INFO) << "state = kIdleSuspend"; |
| 337 // Note: currently this state doesn't do anything. But it can be possibly | 338 // Note: currently this state doesn't do anything. But it can be possibly |
| 338 // useful in future development. For example, if we want to implement fade | 339 // useful in future development. For example, if we want to implement fade |
| 339 // from suspend, we would want to have this state to make sure the backlight | 340 // from suspend, we would want to have this state to make sure the backlight |
| 340 // is set to zero when suspended. | 341 // is set to zero when suspended. |
| 341 if (backlight_controller_->SetPowerState(BACKLIGHT_SUSPENDED)) { | 342 changed_brightness = |
| 342 idle_state_ = kIdleSuspend; | 343 backlight_controller_->SetPowerState(BACKLIGHT_SUSPENDED); |
| 343 LOG(INFO) << "state = kIdleSuspend"; | 344 idle_state_ = kIdleSuspend; |
| 344 changed_brightness = true; | 345 Suspend(); |
| 345 Suspend(); | |
| 346 } | |
| 347 } else if (idle_time_ms >= off_ms_) { | 346 } else if (idle_time_ms >= off_ms_) { |
| 348 if (backlight_controller_->SetPowerState(BACKLIGHT_IDLE_OFF)) { | 347 if (backlight_controller_->SetPowerState(BACKLIGHT_IDLE_OFF)) { |
| 349 idle_state_ = kIdleScreenOff; | 348 idle_state_ = kIdleScreenOff; |
| 350 LOG(INFO) << "state = kIdleScreenOff"; | 349 LOG(INFO) << "state = kIdleScreenOff"; |
| 351 changed_brightness = true; | 350 changed_brightness = true; |
| 352 } | 351 } |
| 353 } else if (idle_time_ms >= dim_ms_) { | 352 } else if (idle_time_ms >= dim_ms_) { |
| 354 if (backlight_controller_->SetPowerState(BACKLIGHT_DIM)) { | 353 if (backlight_controller_->SetPowerState(BACKLIGHT_DIM)) { |
| 355 idle_state_ = kIdleDim; | 354 idle_state_ = kIdleDim; |
| 356 LOG(INFO) << "state = kIdleDim"; | 355 LOG(INFO) << "state = kIdleDim"; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 dbus_g_proxy_send(proxy.gproxy(), signal, NULL); | 689 dbus_g_proxy_send(proxy.gproxy(), signal, NULL); |
| 691 dbus_message_unref(signal); | 690 dbus_message_unref(signal); |
| 692 } | 691 } |
| 693 | 692 |
| 694 void Daemon::HandleResume() { | 693 void Daemon::HandleResume() { |
| 695 file_tagger_.HandleResumeEvent(); | 694 file_tagger_.HandleResumeEvent(); |
| 696 backlight_controller_->SetPowerState(BACKLIGHT_ACTIVE_ON); | 695 backlight_controller_->SetPowerState(BACKLIGHT_ACTIVE_ON); |
| 697 } | 696 } |
| 698 | 697 |
| 699 } // namespace power_manager | 698 } // namespace power_manager |
| OLD | NEW |