flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
163.12k stars 26.83k forks source link

[Flutter] Make the framework aware of which view has focus and publish changes through the platform dispatcher. #148890

Open tugorez opened 1 month ago

tugorez commented 1 month ago

Use case

https://github.com/flutter/flutter/pull/143259 introduced handlers for Apps to respond to platform focus changes. We now need a mechanism to track which view currently has focus and notify the engine when focus shifts so the platform focus can be adjusted accordingly.

Proposal

My initial suggestion is to implement a simple view focus tracker utility. This would keep track of the currently focused view and inform the engine whenever focus changes through PlatformDispatcher.requestViewFocusChange calls.

A naive POC that works when there is only a single view in the app: https://github.com/tugorez/flutter/commit/5d302b86f1f9e85721db186e6868737aa60cc9d5

tugorez commented 1 month ago

cc @ditman

ditman commented 1 month ago

Yes! Also cc @goderbauer, I'm sure the desktop version would have needed something similar to this!