Commit ee1999fc authored by Min Chen's avatar Min Chen Committed by Commit Bot

Disable the toggle overview shortcut if a window is being dragged.


Bug: 900959
Change-Id: Iae62ce77d2fd38105120d86799e52157d6313f3c
Reviewed-on: https://chromium-review.googlesource.com/c/1313738
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605840}
parent d941a839
...@@ -799,6 +799,16 @@ bool CanHandleToggleDockedMagnifier() { ...@@ -799,6 +799,16 @@ bool CanHandleToggleDockedMagnifier() {
return features::IsDockedMagnifierEnabled(); return features::IsDockedMagnifierEnabled();
} }
bool CanHandleToggleOverview() {
auto windows = Shell::Get()->mru_window_tracker()->BuildMruWindowList();
// Do not toggle overview if there is a window being dragged.
for (auto* window : windows) {
if (wm::GetWindowState(window)->is_dragged())
return false;
}
return true;
}
void CreateAndShowStickyNotification(const int title_id, void CreateAndShowStickyNotification(const int title_id,
const int message_id, const int message_id,
const std::string& notification_id) { const std::string& notification_id) {
...@@ -1314,6 +1324,8 @@ bool AcceleratorController::CanPerformAction( ...@@ -1314,6 +1324,8 @@ bool AcceleratorController::CanPerformAction(
return true; return true;
case TOGGLE_MIRROR_MODE: case TOGGLE_MIRROR_MODE:
return true; return true;
case TOGGLE_OVERVIEW:
return CanHandleToggleOverview();
case TOUCH_HUD_CLEAR: case TOUCH_HUD_CLEAR:
case TOUCH_HUD_MODE_CHANGE: case TOUCH_HUD_MODE_CHANGE:
return CanHandleTouchHud(); return CanHandleTouchHud();
...@@ -1369,7 +1381,6 @@ bool AcceleratorController::CanPerformAction( ...@@ -1369,7 +1381,6 @@ bool AcceleratorController::CanPerformAction(
case TOGGLE_FULLSCREEN: case TOGGLE_FULLSCREEN:
case TOGGLE_HIGH_CONTRAST: case TOGGLE_HIGH_CONTRAST:
case TOGGLE_MAXIMIZED: case TOGGLE_MAXIMIZED:
case TOGGLE_OVERVIEW:
case TOGGLE_SPOKEN_FEEDBACK: case TOGGLE_SPOKEN_FEEDBACK:
case TOGGLE_SYSTEM_TRAY_BUBBLE: case TOGGLE_SYSTEM_TRAY_BUBBLE:
case TOGGLE_WIFI: case TOGGLE_WIFI:
......
...@@ -7,18 +7,52 @@ ...@@ -7,18 +7,52 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h" #include "ash/wm/tablet_mode/tablet_mode_controller_test_api.h"
#include "ash/wm/window_resizer.h"
#include "services/ws/public/cpp/input_devices/input_device_client_test_api.h" #include "services/ws/public/cpp/input_devices/input_device_client_test_api.h"
#include "ui/base/hit_test.h"
#include "ui/events/devices/touchscreen_device.h" #include "ui/events/devices/touchscreen_device.h"
#include "ui/events/test/event_generator.h"
#include "ui/keyboard/keyboard_controller.h" #include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_util.h" #include "ui/keyboard/keyboard_util.h"
#include "ui/keyboard/test/keyboard_test_util.h" #include "ui/keyboard/test/keyboard_test_util.h"
namespace {
gfx::Point CalculateDragPoint(const ash::WindowResizer& resizer,
int delta_x,
int delta_y) {
gfx::Point location = resizer.GetInitialLocation();
location.set_x(location.x() + delta_x);
location.set_y(location.y() + delta_y);
return location;
}
} // namespace
namespace ash { namespace ash {
class WindowSelectorControllerTest : public AshTestBase { using WindowSelectorControllerTest = AshTestBase;
// Tests that press the overview key in keyboard when a window is being dragged
// in clamshell mode should not toggle overview.
TEST_F(WindowSelectorControllerTest,
PressOverviewKeyDuringWindowDragInClamshellMode) {
ASSERT_FALSE(TabletModeControllerTestApi().IsTabletModeStarted());
std::unique_ptr<aura::Window> dragged_window = CreateTestWindow();
std::unique_ptr<WindowResizer> resizer =
CreateWindowResizer(dragged_window.get(), gfx::Point(), HTCAPTION,
::wm::WINDOW_MOVE_SOURCE_MOUSE);
resizer->Drag(CalculateDragPoint(*resizer, 10, 0), 0);
EXPECT_TRUE(wm::GetWindowState(dragged_window.get())->is_dragged());
GetEventGenerator()->PressKey(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE);
EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
resizer->CompleteDrag();
}
class OverviewVirtualKeyboardTest : public WindowSelectorControllerTest {
protected: protected:
void SetUp() override { void SetUp() override {
AshTestBase::SetUp(); WindowSelectorControllerTest::SetUp();
ws::InputDeviceClientTestApi().SetKeyboardDevices({}); ws::InputDeviceClientTestApi().SetKeyboardDevices({});
ws::InputDeviceClientTestApi().SetTouchscreenDevices( ws::InputDeviceClientTestApi().SetTouchscreenDevices(
...@@ -42,7 +76,7 @@ class WindowSelectorControllerTest : public AshTestBase { ...@@ -42,7 +76,7 @@ class WindowSelectorControllerTest : public AshTestBase {
} }
}; };
TEST_F(WindowSelectorControllerTest, ToggleOverviewModeHidesVirtualKeyboard) { TEST_F(OverviewVirtualKeyboardTest, ToggleOverviewModeHidesVirtualKeyboard) {
keyboard_controller()->ShowKeyboard(false /* locked */); keyboard_controller()->ShowKeyboard(false /* locked */);
keyboard::WaitUntilShown(); keyboard::WaitUntilShown();
...@@ -52,7 +86,7 @@ TEST_F(WindowSelectorControllerTest, ToggleOverviewModeHidesVirtualKeyboard) { ...@@ -52,7 +86,7 @@ TEST_F(WindowSelectorControllerTest, ToggleOverviewModeHidesVirtualKeyboard) {
keyboard::WaitUntilHidden(); keyboard::WaitUntilHidden();
} }
TEST_F(WindowSelectorControllerTest, TEST_F(OverviewVirtualKeyboardTest,
ToggleOverviewModeDoesNotHideLockedVirtualKeyboard) { ToggleOverviewModeDoesNotHideLockedVirtualKeyboard) {
keyboard_controller()->ShowKeyboard(true /* locked */); keyboard_controller()->ShowKeyboard(true /* locked */);
keyboard::WaitUntilShown(); keyboard::WaitUntilShown();
......
...@@ -3329,6 +3329,28 @@ TEST_F(SplitViewTabDraggingTest, BoundsTest) { ...@@ -3329,6 +3329,28 @@ TEST_F(SplitViewTabDraggingTest, BoundsTest) {
EXPECT_EQ(window2->bounds(), snapped_bounds2); EXPECT_EQ(window2->bounds(), snapped_bounds2);
} }
// Tests that press overview key in keyboard during drag should not put the
// dragged window into overview.
TEST_F(SplitViewTabDraggingTest, PressOverviewKeyDuringDrag) {
const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> dragged_window(
CreateWindowWithType(bounds, AppType::BROWSER));
wm::GetWindowState(dragged_window.get())->Maximize();
std::unique_ptr<WindowResizer> resizer =
StartDrag(dragged_window.get(), dragged_window.get());
DragWindowTo(resizer.get(), gfx::Point(300, 300));
EXPECT_TRUE(wm::GetWindowState(dragged_window.get())->is_dragged());
EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
GetEventGenerator()->PressKey(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE);
EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
EXPECT_FALSE(Shell::Get()
->window_selector_controller()
->window_selector()
->IsWindowInOverview(dragged_window.get()));
EXPECT_TRUE(wm::GetWindowState(dragged_window.get())->is_dragged());
resizer->CompleteDrag();
}
class TestWindowDelegateWithWidget : public views::WidgetDelegate { class TestWindowDelegateWithWidget : public views::WidgetDelegate {
public: public:
TestWindowDelegateWithWidget(bool can_activate) TestWindowDelegateWithWidget(bool can_activate)
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
-MagnificationControllerTest.TextfieldFocusedWithKeyboard -MagnificationControllerTest.TextfieldFocusedWithKeyboard
# Crashes in ui::FakeContextFactory::GetLastCompositorFrame(). # Crashes in ui::FakeContextFactory::GetLastCompositorFrame().
-NonClientFrameControllerMashTest.ContentRegionNotDrawnForClient -NonClientFrameControllerMashTest.ContentRegionNotDrawnForClient
-OverviewVirtualKeyboardTest.ToggleOverviewModeHidesVirtualKeyboard
-OverviewVirtualKeyboardTest.ToggleOverviewModeDoesNotHideLockedVirtualKeyboard
-ShelfLayoutManagerKeyboardTest.ShelfIgnoreWorkAreaChangeInNonStickyMode -ShelfLayoutManagerKeyboardTest.ShelfIgnoreWorkAreaChangeInNonStickyMode
-ShelfLayoutManagerKeyboardTest.ShelfNotMoveOnKeyboardOpen -ShelfLayoutManagerKeyboardTest.ShelfNotMoveOnKeyboardOpen
-ShelfLayoutManagerKeyboardTest.ShelfShouldChangeWorkAreaInStickyMode -ShelfLayoutManagerKeyboardTest.ShelfShouldChangeWorkAreaInStickyMode
...@@ -58,6 +60,4 @@ ...@@ -58,6 +60,4 @@
-VirtualKeyboardTest.EventsAreHandledBasedOnHitTestBounds -VirtualKeyboardTest.EventsAreHandledBasedOnHitTestBounds
-VirtualKeyboardTest.HitTestBoundsAreResetWhenContainerTypeChanges -VirtualKeyboardTest.HitTestBoundsAreResetWhenContainerTypeChanges
-VirtualKeyboardTrayTest.PerformActionTogglesVirtualKeyboard -VirtualKeyboardTrayTest.PerformActionTogglesVirtualKeyboard
-WindowSelectorControllerTest.ToggleOverviewModeHidesVirtualKeyboard
-WindowSelectorControllerTest.ToggleOverviewModeDoesNotHideLockedVirtualKeyboard
-WorkspaceLayoutManagerKeyboardTest.IgnoreWorkAreaChangeinNonStickyMode -WorkspaceLayoutManagerKeyboardTest.IgnoreWorkAreaChangeinNonStickyMode
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