Skip to content

Require system focus for gamepad user gesture#207

Open
nondebug wants to merge 5 commits intogh-pagesfrom
gesture-requires-focus
Open

Require system focus for gamepad user gesture#207
nondebug wants to merge 5 commits intogh-pagesfrom
gesture-requires-focus

Conversation

@nondebug
Copy link
Collaborator

@nondebug nondebug commented May 10, 2024

Closes #206

The following tasks have been completed:

  • Modified Web platform tests (link to pull request)

Implementation commitment:


Preview | Diff

@marcoscaceres
Copy link
Member

This seems reasonable. I need to check if WebKit already does this or not.

@nondebug
Copy link
Collaborator Author

This seems reasonable. I need to check if WebKit already does this or not.

I think WebKit on macOS already requires focus even for normal gamepad inputs because it uses Game Controller API which requires focus.

@marcoscaceres
Copy link
Member

marcoscaceres commented Aug 8, 2024

We might actually want this:
https://html.spec.whatwg.org/multipage/interaction.html#fully-active-descendant-of-a-top-level-traversable-with-user-attention

  • Fully active
  • visibly requirement
  • and system system focus!

Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok to me.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Gamepad spec’s “gamepad user gesture” handling to require the relevant document to have user attention (i.e., be focused/active) before the initial gesture unlocks exposure of gamepad data, addressing issue #206’s cross-tab gesture concerns.

Changes:

  • Gate setting Navigator/[[hasGamepadGesture]] on the associated document being a fully active descendant of a top-level traversable with user attention.
  • Hoist the associated Document lookup earlier in the “update gamepad state” algorithm (so it can be used for the new focus/user-attention check).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +808 to +810
|document| is a [=Document/fully active descendant of a top-level
traversable with user attention=] and |gamepad| [=contains a gamepad
user gesture=]:
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition uses “|document| is a Document/fully active descendant …” but |document| is defined as Document? and can be null. Add an explicit |document| is not null (or change the condition to handle null) before applying the HTML definition, to avoid a type-mismatched check and make the focus requirement unambiguous.

Suggested change
|document| is a [=Document/fully active descendant of a top-level
traversable with user attention=] and |gamepad| [=contains a gamepad
user gesture=]:
|document| is not `null` and is a [=Document/fully active descendant
of a top-level traversable with user attention=] and |gamepad|
[=contains a gamepad user gesture=]:

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, yeah... maybe this check should also happen earlier. If you don't have a document anyway, then none of the above really matters, right?

Comment on lines +2116 to +2117
<li>Let |gamepads:sequence&lt;Gamepad?&gt;| be an empty [=list=].
</li>
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This algorithm step is duplicated: Let |gamepads:sequence<Gamepad?>| be an empty list appears twice in a row. Remove the extra step to avoid confusion about variable re-declaration and keep the algorithm consistent.

Suggested change
<li>Let |gamepads:sequence&lt;Gamepad?&gt;| be an empty [=list=].
</li>

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Require focus for initial gamepad user gesture

3 participants