Focus and Activation in Views and Aura
Focus and Activation are closely related.
Definitions
Focused window - this is the window that receives keyboard input. The focused window is always or is always contained by the Active window.
Active window - this is the window that is rendered as key - i.e. the one that contains the focused element. Different platforms will render this differently and may show additional affordances e.g. a different treatment in the window switcher.
Notes
A "top level" window is a window that has no parent other than window manager constructs. Think of a Chrome window.
An "activatable" window is a top level window that can be activated. Not all top
level windows can be activated at any given time. For instance in Ash, if the
screen is locked calling GetActivatableWindow() for a window behind the lock
screen may return a window in front of the lock screen, whereas
GetTopLevelWindow() will return the non-activatable toplevel behind the lock
screen. For this reason GetActivatableWindow is a method most useful to the
focus/
In Aura, the CoreWM library provided by Views handles focus and activation
changes in the class FocusController. The FocusController implements two
interfaces - aura::client::FocusClient and aura::client::ActivationClient. Every
RootWindow must have an associated Focus/
The FocusController tracks the current active and focused windows, and sends notifications when either of these change to registered implementations of aura::client::FocusChangeObserver and aura::client::ActivationChangeObserver.
Views also tracks focus, for views::View subclasses within a views::Widget.
Think of it this way. In the Aura world, an aura::Window can have focus, and can
have an embedded View hierarchy via NativeWidgetAura/
When a views::Widget is deactivated, its FocusManager stores the focused view in
ViewStorage for restoration later. The history behind this is somewhat vestigial
but the storage/
As far as what can be focused or activated in Aura, FocusController delegates to an implementation of the FocusRules interface to determine what can be focused or activated. There are different implementations for Ash (AshFocusRules) and Desktop-Aura (DesktopFocusRules). These rules enforce specifics like not activating windows behind the lock screen, etc.