Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 1a3b5b10 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Add focusTransferTarget in WindowInfo

A transfer focus request was originally added on FocusRequest object.
This meant when a host wanted to provide focus to an embedded window, it
would request to transfer focus, but provide its own token as the
focusedToken in the request. In FocusResolver, it would ensure that the
focusedToken was current focus before allow the request to proceed. This
worked in some cases, but created races where clients had to understand
timing in order to properly transfer focus.

Instead, use a persistent focusTransferTarget value set on the host to
transfer focus to the embedded when the host would have gained focus.

This solves a few issues with embedded windows.
1. Apps can request focus to the embedded by requesting focus to the SV
that hosts the embedded. However, if they request focus too early, it
will drop the request since the host has not yet gained focus. With
the current code, it will transfer focus to the embedded once the
host could have gained focus. If the host wants to revoke, the
focusTransferTarget can be set to null, which will give the host focus
again.

2. This fixes the issue if another window becomes focus. When WM gives
focus back to the host window, it should automatically give focus to
the embedded if it was last requested. The app shouldn't be required
to maintain the last state of the embedded focus to see if it needs
to transfer it again. It's actually not even possible once focus can
be given to embedded via touch since only WM and Input know about
this.

Additionally, ensure that tapping on the embedded window gives it focus.
This was added only for overlay layers, but is also needed for all
embedded windows. There's no way for the host to transfer focus when the
embedded is tapped since the events will go directly to the embedded
window and not to the host. If the embedded window is tapped, but the
host is not focused, we need to ensure WMS will bring that window to the
top and request focus to inputflinger. When the host focus request is
processed by FocusResolver, it will then give focus directly to the
embedded because of the focusTransferTarget set on the host WindowInfo.

Test: SurfaceControlViewHostTests
Bug: 230340812
Change-Id: If610d50e903fe8c437436e6efcb750a809274726
parent b5d7e0ed
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment