Commit 561b1956 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Fix regression that dev-shortcut to enable tablet mode doesn't show overview button

This was a rgression caused by a previous CL of mine https://crrev.com/c/1865543.
Using the developer keyboard shortcut to enable tablet mode should
force the overview tray button visible even though the internal
input events are not being blocked.

BUG=1016594, 925087
TEST=Manually, added a new test.

Change-Id: Ic9046c07dcce9de03c5fc5acd10a2077d599c711
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872468Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708222}
parent 0182397a
......@@ -425,4 +425,17 @@ TEST_F(OverviewButtonTrayTest, LeaveTabletModeBecauseExternalMouse) {
EXPECT_TRUE(GetTray()->GetVisible());
}
// Using the developers keyboard shortcut to enable tablet mode should force the
// overview tray button visible, even though the events are not blocked.
TEST_F(OverviewButtonTrayTest, ForDevTabletModeForcesTheButtonShown) {
Shell::Get()->tablet_mode_controller()->SetEnabledForDev(true);
EXPECT_TRUE(TabletModeControllerTestApi().IsTabletModeStarted());
EXPECT_FALSE(TabletModeControllerTestApi().AreEventsBlocked());
EXPECT_TRUE(GetTray()->GetVisible());
Shell::Get()->tablet_mode_controller()->SetEnabledForDev(false);
EXPECT_FALSE(TabletModeControllerTestApi().IsTabletModeStarted());
EXPECT_TRUE(GetTray()->GetVisible());
}
} // namespace ash
......@@ -184,9 +184,9 @@ constexpr TabletModeController::TabletModeBehavior kOnBySensor{
/*force_physical_tablet_state=*/false,
};
// Defines the behavior that sticks to the current mode. Used to
// implement --force-tablet-mode flag.
constexpr TabletModeController::TabletModeBehavior kLockInCurrentMode{
// Defines the behavior that sticks to tablet mode. Used to implement the
// --force-tablet-mode=touch_view flag.
constexpr TabletModeController::TabletModeBehavior kLockInTabletMode{
/*use_sensor=*/false,
/*observe_display_events=*/false,
/*observe_external_pointer_device_events=*/false,
......@@ -195,6 +195,17 @@ constexpr TabletModeController::TabletModeBehavior kLockInCurrentMode{
/*force_physical_tablet_state=*/false,
};
// Defines the behavior that sticks to tablet mode. Used to implement the
// --force-tablet-mode=clamshell flag.
constexpr TabletModeController::TabletModeBehavior kLockInClamshellMode{
/*use_sensor=*/false,
/*observe_display_events=*/false,
/*observe_external_pointer_device_events=*/false,
/*block_internal_input_device=*/false,
/*always_show_overview_button=*/false,
/*force_physical_tablet_state=*/false,
};
// Defines the behavior used for testing. It prevents the device from
// switching the mode due to sensor events during the test.
constexpr TabletModeController::TabletModeBehavior kOnForTest{
......@@ -434,8 +445,12 @@ void TabletModeController::OnShellInitialized() {
forced_ui_mode_ = GetUiMode();
switch (forced_ui_mode_) {
case UiMode::kTabletMode:
tablet_mode_behavior_ = kLockInTabletMode;
UpdateUiTabletState();
break;
case UiMode::kClamshell:
tablet_mode_behavior_ = kLockInCurrentMode;
tablet_mode_behavior_ = kLockInClamshellMode;
UpdateUiTabletState();
break;
......@@ -906,8 +921,17 @@ void TabletModeController::UpdateInternalInputDevicesEventBlocker() {
tablet_mode_behavior_.block_internal_input_device &&
(InTabletMode() || is_in_tablet_physical_state_);
if (should_block_internal_events == AreInternalInputDeviceEventsBlocked())
if (should_block_internal_events == AreInternalInputDeviceEventsBlocked()) {
if (tablet_mode_behavior_.always_show_overview_button) {
// The overview button visibility gets updated based on the
// OnTabletModeEventsBlockingChanged() notification. Broadcast this event
// if we need to force it visible.
for (auto& observer : tablet_mode_observers_)
observer.OnTabletModeEventsBlockingChanged();
}
return;
}
event_blocker_->UpdateInternalInputDevices(should_block_internal_events);
for (auto& observer : tablet_mode_observers_)
......
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