Public Access
Light the screen (dimmed) while a Notification's Toast shows
An Off screen turns on dimmed for the Toast's duration so the user can see what beeped. It isn't user activity: the timeouts aren't restarted, and a key pressed meanwhile reaches the App. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -12,6 +12,12 @@ bool PowerPolicy::activity(uint32_t nowMs) {
|
||||
ScreenState PowerPolicy::update(uint32_t nowMs) {
|
||||
uint32_t idle = nowMs - lastActivityMs_;
|
||||
state_ = idle >= offMs_ ? ScreenState::Off : idle >= dimMs_ ? ScreenState::Dimmed : ScreenState::On;
|
||||
if (notifying_) {
|
||||
if (static_cast<int32_t>(nowMs - notifyUntilMs_) >= 0)
|
||||
notifying_ = false;
|
||||
else if (state_ == ScreenState::Off)
|
||||
state_ = ScreenState::Dimmed;
|
||||
}
|
||||
return state_;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,14 @@ class PowerPolicy {
|
||||
// Records a key press. Returns true if the key only woke an Off screen and must not reach the App.
|
||||
bool activity(uint32_t nowMs);
|
||||
|
||||
// A Notification is showing until untilMs: an Off screen lights up Dimmed meanwhile. It's not
|
||||
// user activity, so it doesn't restart the timeouts.
|
||||
void notify(uint32_t nowMs, uint32_t untilMs) {
|
||||
(void)nowMs;
|
||||
notifyUntilMs_ = untilMs;
|
||||
notifying_ = true;
|
||||
}
|
||||
|
||||
ScreenState update(uint32_t nowMs);
|
||||
ScreenState state() const { return state_; }
|
||||
|
||||
@@ -26,6 +34,8 @@ class PowerPolicy {
|
||||
uint32_t dimMs_;
|
||||
uint32_t offMs_;
|
||||
uint32_t lastActivityMs_ = 0;
|
||||
uint32_t notifyUntilMs_ = 0;
|
||||
bool notifying_ = false;
|
||||
ScreenState state_ = ScreenState::On;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user