Merge "ui: Only set brightness when needed."
am: cf01f7dcbe
Change-Id: If9747c9fdb2822cacad87828ad627b72742e9aff
diff --git a/ui.cpp b/ui.cpp
index f1e30f5..14b5b09 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -454,8 +454,7 @@
return static_cast<int>(KeyError::INTERRUPTED);
}
- // Time out after UI_WAIT_KEY_TIMEOUT_SEC, unless a USB cable is
- // plugged in.
+ // Time out after UI_WAIT_KEY_TIMEOUT_SEC, unless a USB cable is plugged in.
do {
bool rc = key_queue_cond.wait_for(lk, std::chrono::seconds(UI_WAIT_KEY_TIMEOUT_SEC), [this] {
return this->key_queue_len != 0 || key_interrupted_;
@@ -466,13 +465,13 @@
}
if (screensaver_state_ != ScreensaverState::DISABLED) {
if (!rc) {
- // Lower the brightness level: NORMAL -> DIMMED; DIMMED -> OFF.
+ // Must be after a timeout. Lower the brightness level: NORMAL -> DIMMED; DIMMED -> OFF.
if (screensaver_state_ == ScreensaverState::NORMAL) {
SetScreensaverState(ScreensaverState::DIMMED);
} else if (screensaver_state_ == ScreensaverState::DIMMED) {
SetScreensaverState(ScreensaverState::OFF);
}
- } else {
+ } else if (screensaver_state_ != ScreensaverState::NORMAL) {
// Drop the first key if it's changing from OFF to NORMAL.
if (screensaver_state_ == ScreensaverState::OFF) {
if (key_queue_len > 0) {