Commit 9b660319 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

back gesture: close VK first if VK is visible when performing back.

Bug: 1056939
Change-Id: I70acfadf7ad2468e8055f8150759861b892812b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083756Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746156}
parent 7f6eed59
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/home_screen/home_screen_controller.h" #include "ash/home_screen/home_screen_controller.h"
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
#include "ash/shelf/contextual_tooltip.h" #include "ash/shelf/contextual_tooltip.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -258,6 +259,9 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event, ...@@ -258,6 +259,9 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event,
if (back_gesture_affordance_->IsActivated() || if (back_gesture_affordance_->IsActivated() ||
(event->type() == ui::ET_SCROLL_FLING_START && (event->type() == ui::ET_SCROLL_FLING_START &&
event->details().velocity_x() >= kFlingVelocityForGoingBack)) { event->details().velocity_x() >= kFlingVelocityForGoingBack)) {
if (KeyboardController::Get()->IsKeyboardVisible()) {
KeyboardController::Get()->HideKeyboard(HideReason::kUser);
} else {
ActivateUnderneathWindowInSplitViewMode( ActivateUnderneathWindowInSplitViewMode(
back_start_location_, dragged_from_splitview_divider_); back_start_location_, dragged_from_splitview_divider_);
auto* top_window_state = auto* top_window_state =
...@@ -267,8 +271,8 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event, ...@@ -267,8 +271,8 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event,
// For fullscreen ARC apps, show the hotseat and shelf on the first // For fullscreen ARC apps, show the hotseat and shelf on the first
// back swipe, and send a back event on the second back swipe. For // back swipe, and send a back event on the second back swipe. For
// other fullscreen apps, exit fullscreen. // other fullscreen apps, exit fullscreen.
const bool arc_app = const bool arc_app = top_window_state->window()->GetProperty(
top_window_state->window()->GetProperty(aura::client::kAppType) == aura::client::kAppType) ==
static_cast<int>(AppType::ARC_APP); static_cast<int>(AppType::ARC_APP);
if (arc_app) { if (arc_app) {
// Go back to the previous page if the shelf was already shown, // Go back to the previous page if the shelf was already shown,
...@@ -287,7 +291,8 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event, ...@@ -287,7 +291,8 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event,
// window. // window.
const WMEvent event(WM_EVENT_TOGGLE_FULLSCREEN); const WMEvent event(WM_EVENT_TOGGLE_FULLSCREEN);
top_window_state->OnWMEvent(&event); top_window_state->OnWMEvent(&event);
RecordEndScenarioType(BackGestureEndScenarioType::kExitFullscreen); RecordEndScenarioType(
BackGestureEndScenarioType::kExitFullscreen);
} }
} else if (TabletModeWindowManager::ShouldMinimizeTopWindowOnBack()) { } else if (TabletModeWindowManager::ShouldMinimizeTopWindowOnBack()) {
// Complete as minimizing the underneath window. // Complete as minimizing the underneath window.
...@@ -300,6 +305,7 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event, ...@@ -300,6 +305,7 @@ bool BackGestureEventHandler::MaybeHandleBackGesture(ui::GestureEvent* event,
// window. // window.
SendBackEvent(screen_location); SendBackEvent(screen_location);
} }
}
back_gesture_affordance_->Complete(); back_gesture_affordance_->Complete();
if (features::AreContextualNudgesEnabled()) { if (features::AreContextualNudgesEnabled()) {
contextual_tooltip::HandleGesturePerformed( contextual_tooltip::HandleGesturePerformed(
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/display/screen_orientation_controller_test_api.h" #include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/home_screen/home_screen_controller.h" #include "ash/home_screen/home_screen_controller.h"
#include "ash/keyboard/ui/test/keyboard_test_util.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/keyboard/keyboard_controller.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/session/session_controller_impl.h" #include "ash/session/session_controller_impl.h"
#include "ash/shelf/hotseat_widget.h" #include "ash/shelf/hotseat_widget.h"
...@@ -539,4 +541,29 @@ TEST_F(BackGestureEventHandlerTest, ARCFullscreenedWindow) { ...@@ -539,4 +541,29 @@ TEST_F(BackGestureEventHandlerTest, ARCFullscreenedWindow) {
EXPECT_EQ(1, target_back_release.accelerator_count()); EXPECT_EQ(1, target_back_release.accelerator_count());
} }
// Tests the back gesture behavior when a virtual keyboard is visible.
TEST_F(BackGestureEventHandlerTest, BackGestureWithVKTest) {
ui::TestAcceleratorTarget target_back_press, target_back_release;
RegisterBackPressAndRelease(&target_back_press, &target_back_release);
KeyboardController* keyboard_controller = KeyboardController::Get();
keyboard_controller->SetEnableFlag(
keyboard::KeyboardEnableFlag::kExtensionEnabled);
// The keyboard needs to be in a loaded state before being shown.
ASSERT_TRUE(keyboard::test::WaitUntilLoaded());
keyboard_controller->ShowKeyboard();
EXPECT_TRUE(keyboard_controller->IsKeyboardVisible());
GenerateBackSequence();
// First back gesture should hide the virtual keyboard.
EXPECT_FALSE(keyboard_controller->IsKeyboardVisible());
EXPECT_EQ(0, target_back_press.accelerator_count());
EXPECT_EQ(0, target_back_release.accelerator_count());
GenerateBackSequence();
// Second back gesture should trigger go back.
EXPECT_EQ(1, target_back_press.accelerator_count());
EXPECT_EQ(1, target_back_release.accelerator_count());
}
} // namespace ash } // namespace ash
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