feat: Screen Wake Lock API on Page#24324
Open
Artur- wants to merge 2 commits into
Open
Conversation
Add a per-UI WakeLock facade reached through Page#getWakeLock(). It exposes request(), release(), and an active-state Signal<Boolean>, matching the conventions used for PageVisibility and Geolocation: - Dedicated facade class under com.vaadin.flow.component.page with a package-private constructor. - Client logic lives in flow-client/src/main/frontend/WakeLock.ts and is side-effect-imported from Flow.ts; nothing inlined into Java. - State travels back as a vaadin-wake-lock-change CustomEvent on document.body with an ACTIVE / RELEASED detail; the facade listens on the UI element and writes to a private ValueSignal. - Client transparently re-acquires the lock on visibilitychange so a single request() covers the lifetime of a view; release() clears the "want lock" flag and drops the current sentinel. - Failures (insecure context, unsupported browser, denied) log at DEBUG and leave the active signal in its false state.
|
mcollovati
reviewed
May 18, 2026
| * | ||
| * @return the wake lock facade, never {@code null} | ||
| */ | ||
| public WakeLock getWakeLock() { |
Collaborator
There was a problem hiding this comment.
Other browser feature APIs have their own static methods instead of being accessed throug Page.
Should we make this consistent?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Add a per-UI WakeLock facade reached through Page#getWakeLock(). It exposes request(), release(), and an active-state Signal, matching the conventions used for PageVisibility and Geolocation: