Commit 35f8008f authored by Danila Kuzmin's avatar Danila Kuzmin Committed by Commit Bot

oobe: Fix focus traversal for screens with invisible status area

Sometimes there is no status area shown on the screen and we need to
check it during tab traversal.

Bug: 1008817
Change-Id: If6099f8c020818de62a3bc2bccbe07f077817d52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2551120Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Danila Kuzmin <dkuzmin@google.com>
Cr-Commit-Position: refs/heads/master@{#830962}
parent 33c4600f
......@@ -289,16 +289,22 @@ void LoginScreenController::FocusLoginShelf(bool reverse) {
Shelf* shelf = Shelf::ForWindow(Shell::Get()->GetPrimaryRootWindow());
// Tell the focus direction to the status area or the shelf so they can focus
// the correct child view.
if (reverse || !shelf->shelf_widget()->login_shelf_view()->IsFocusable()) {
if (!Shell::GetPrimaryRootWindowController()->IsSystemTrayVisible())
return;
if (Shell::GetPrimaryRootWindowController()->IsSystemTrayVisible() &&
(reverse || !shelf->shelf_widget()->login_shelf_view()->IsFocusable())) {
// Focus goes to system tray (status area) if one of the following is true:
// - system tray is visible and tab is in reverse order;
// - system tray is visible and there is no visible shelf buttons before.
shelf->GetStatusAreaWidget()
->status_area_widget_delegate()
->set_default_last_focusable_child(reverse);
Shell::Get()->focus_cycler()->FocusWidget(shelf->GetStatusAreaWidget());
} else {
} else if (shelf->shelf_widget()->login_shelf_view()->IsFocusable()) {
// Otherwise focus goes to shelf buttons when there is any.
shelf->shelf_widget()->set_default_last_focusable_child(reverse);
Shell::Get()->focus_cycler()->FocusWidget(shelf->shelf_widget());
} else {
// No elements to focus on the shelf.
NOTREACHED();
}
}
......
......@@ -579,12 +579,16 @@ void LoginShelfView::AboutToRequestFocusFromTabTraversal(bool reverse) {
// Focus should leave the system tray.
Shell::Get()->system_tray_notifier()->NotifyFocusOut(reverse);
} else {
// Focus goes to status area.
StatusAreaWidget* status_area_widget =
Shelf::ForWindow(GetWidget()->GetNativeWindow())->GetStatusAreaWidget();
status_area_widget->status_area_widget_delegate()
->set_default_last_focusable_child(reverse);
Shell::Get()->focus_cycler()->FocusWidget(status_area_widget);
// Focus goes to status area if it is visible.
if (status_area_widget->IsVisible()) {
status_area_widget->status_area_widget_delegate()
->set_default_last_focusable_child(reverse);
Shell::Get()->focus_cycler()->FocusWidget(status_area_widget);
} else {
Shell::Get()->system_tray_notifier()->NotifyFocusOut(reverse);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment