Commit d25bdaaa authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

TabletModeController: Refactor and Cleanup.

- Remove Attempt Enter/Leave TabletMode() which was scattered
  and used all over the place.
- Make a clear distinction between a device physical tablet
  state (which is affected by device events such as lid angle
  changes, tablet EC switches, ... etc.) and a UI tablet state
  (which is whether the UI is currently in tablet or clamshell
   modes).
- Gather all the inconsistent and scattered logic that affects
  the device and UI states into consolidated, and clear functions
  that get invoked whenever the state needs to be updated.

This CL is a prerequisite work for the auto-rotation work
coming up soon.

BUG=925087
TEST=No behavior change, all tests must pass.

Change-Id: If4c2777f434a09f3c70b32bb60367cfb118102b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1851286
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704975}
parent d0e95b00
......@@ -204,10 +204,6 @@ class ASH_EXPORT TabletModeController
kExitingTabletMode,
};
// TODO(jonross): Merge this with AttemptEnterTabletMode. Currently these are
// separate for several reasons: there is no internal display when running
// unittests; the event blocker prevents keyboard input when running ChromeOS
// on linux. http://crbug.com/362881
// Turn the always tablet mode window manager on or off.
void SetTabletModeEnabledInternal(bool should_enable);
......@@ -230,14 +226,6 @@ class ASH_EXPORT TabletModeController
// tablet mode becomes enabled.
bool CanEnterTabletMode();
// Attempts to enter tablet mode and updates the internal keyboard and
// touchpad.
void AttemptEnterTabletMode();
// Attempts to exit tablet mode and updates the internal keyboard and
// touchpad.
void AttemptLeaveTabletMode();
// Record UMA stats tracking TabletMode usage. If |type| is
// TABLET_MODE_INTERVAL_INACTIVE, then record that TabletMode has been
// inactive from |tablet_mode_usage_interval_start_time_| until now.
......@@ -269,11 +257,6 @@ class ASH_EXPORT TabletModeController
// because of an external attached mouse).
void UpdateInternalInputDevicesEventBlocker();
// Returns true if the current lid angle can be detected and is in tablet mode
// angle range. If EC can handle lid angle calc, lid angle is unavailable to
// browser.
bool LidAngleInTabletModeRange();
// Suspends |occlusion_tracker_pauser_| for the duration of
// kOcclusionTrackTimeout.
void SuspendOcclusionTracker();
......@@ -299,6 +282,23 @@ class ASH_EXPORT TabletModeController
void OnScreenshotTaken(base::OnceClosure on_screenshot_taken,
std::unique_ptr<viz::CopyOutputResult> copy_result);
// Calculates whether the device is currently in a physical tablet state,
// using the most recent seen device events such as lid angle changes.
bool CalculateIsInTabletPhysicalState() const;
// Returns whether the UI should be in tablet mode based on the current
// physical tablet state, the availability of external input devices, and
// whether the UI is forced in a particular mode via command-line flags.
bool ShouldUiBeInTabletMode() const;
// Sets |is_in_tablet_physical_state_| to |new_state| and potentially updating
// the UI tablet mode state if needed.
void SetIsInTabletPhysicalState(bool new_state);
// Updates the UI by either entering or exiting UI tablet mode if necessary
// based on the current state.
void UpdateUiTabletState();
// The tablet window manager (if enabled).
std::unique_ptr<TabletModeWindowManager> tablet_mode_window_manager_;
......@@ -335,12 +335,25 @@ class ASH_EXPORT TabletModeController
// Source for the current time in base::TimeTicks.
const base::TickClock* tick_clock_;
// The state in which the UI mode is forced in via command-line flags, such as
// `--force-tablet-mode=touch_view` or `--force-tablet-mode=clamshell`.
UiMode forced_ui_mode_ = UiMode::kNone;
// True if the device is physically in a tablet state regardless of the UI
// tablet mode state. The physical tablet state only changes based on device
// events such as lid angle changes, or device getting detached from its base.
bool is_in_tablet_physical_state_ = false;
// Set when tablet mode switch is on. This is used to force tablet mode.
bool tablet_mode_switch_is_on_ = false;
// Tracks when the lid is closed. Used to prevent entering tablet mode.
bool lid_is_closed_ = false;
// True if |lid_angle_| is in the stable range of angle values.
// (See kMinStableAngle and kMaxStableAngle).
bool lid_angle_is_stable_ = false;
// Last computed lid angle.
double lid_angle_ = 0.0f;
......
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