Commit 27555892 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

tablet: Make the functionality of CL 1497477 work again

1. Snap the active window in clamshell mode
2. Switch to another user session
3. Switch to tablet mode
4. Switch back to the first user session

The snapped window should be carried over to tablet split view.

Test: manual
Change-Id: I830114212b595dc44c6513e9072141cd8282dadc
Fixed: 936610
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2021187
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735485}
parent 7b366de8
...@@ -470,10 +470,7 @@ void SplitViewController::SnapWindow(aura::Window* window, ...@@ -470,10 +470,7 @@ void SplitViewController::SnapWindow(aura::Window* window,
->OnSelectorItemDragEnded(/*snap=*/true); ->OnSelectorItemDragEnded(/*snap=*/true);
} }
// Update the divider position and window bounds before snapping a new if (split_view_type_ == SplitViewType::kTabletType) {
// window. Since the minimum size of |window| maybe larger than currently
// bounds in |snap_position|.
if (InTabletSplitViewMode()) {
divider_position_ = GetClosestFixedDividerPosition(); divider_position_ = GetClosestFixedDividerPosition();
UpdateSnappedWindowsAndDividerBounds(); UpdateSnappedWindowsAndDividerBounds();
} }
...@@ -1389,8 +1386,6 @@ void SplitViewController::UpdateBlackScrim( ...@@ -1389,8 +1386,6 @@ void SplitViewController::UpdateBlackScrim(
} }
void SplitViewController::UpdateSnappedWindowsAndDividerBounds() { void SplitViewController::UpdateSnappedWindowsAndDividerBounds() {
DCHECK(InSplitViewMode());
// Update the snapped windows' bounds. // Update the snapped windows' bounds.
if (IsSnapped(left_window_)) { if (IsSnapped(left_window_)) {
const WMEvent left_window_event(WM_EVENT_SNAP_LEFT); const WMEvent left_window_event(WM_EVENT_SNAP_LEFT);
...@@ -1468,8 +1463,6 @@ void SplitViewController::UpdateDividerPosition( ...@@ -1468,8 +1463,6 @@ void SplitViewController::UpdateDividerPosition(
} }
int SplitViewController::GetClosestFixedDividerPosition() { int SplitViewController::GetClosestFixedDividerPosition() {
DCHECK(InSplitViewMode());
// The values in |kFixedPositionRatios| represent the fixed position of the // The values in |kFixedPositionRatios| represent the fixed position of the
// center of the divider while |divider_position_| represent the origin of the // center of the divider while |divider_position_| represent the origin of the
// divider rectangle. So, before calling FindClosestFixedPositionRatio, // divider rectangle. So, before calling FindClosestFixedPositionRatio,
......
...@@ -113,9 +113,25 @@ class ASH_EXPORT TabletModeWindowManager : public aura::WindowObserver, ...@@ -113,9 +113,25 @@ class ASH_EXPORT TabletModeWindowManager : public aura::WindowObserver,
private: private:
using WindowToState = std::map<aura::Window*, TabletModeWindowState*>; using WindowToState = std::map<aura::Window*, TabletModeWindowState*>;
// Returns the state type that |window| had before tablet mode started. If // If |from_clamshell| is true, returns the bounds or state type that |window|
// |window| is not yet tracked, returns the current state type of |window|. // had before tablet mode started. If |from_clamshell| is false, returns the
WindowStateType GetDesktopWindowStateType(aura::Window* window) const; // current bounds or state type of |window|.
gfx::Rect GetWindowBoundsInScreen(aura::Window* window,
bool from_clamshell) const;
WindowStateType GetWindowStateType(aura::Window* window,
bool from_clamshell) const;
// Returns the windows that are going to be carried over to split view during
// clamshell <-> tablet transition or multi-user switch transition.
base::flat_map<aura::Window*, WindowStateType> GetCarryOverWindowsInSplitView(
bool clamshell_to_tablet) const;
// Calculates the split view divider position that will best preserve the
// bounds of the windows.
int CalculateCarryOverDividerPosition(
const base::flat_map<aura::Window*, WindowStateType>&
windows_in_splitview,
bool clamshell_to_tablet) const;
// Maximizes all windows, except that snapped windows shall carry over to // Maximizes all windows, except that snapped windows shall carry over to
// split view as determined by GetCarryOverWindowsInSplitView(). // split view as determined by GetCarryOverWindowsInSplitView().
......
...@@ -196,6 +196,7 @@ TabletModeWindowState::TabletModeWindowState(aura::Window* window, ...@@ -196,6 +196,7 @@ TabletModeWindowState::TabletModeWindowState(aura::Window* window,
window, entering_tablet_mode && !IsTopWindow(window) window, entering_tablet_mode && !IsTopWindow(window)
? WindowState::BoundsChangeAnimationType::STEP_END ? WindowState::BoundsChangeAnimationType::STEP_END
: WindowState::BoundsChangeAnimationType::DEFAULT); : WindowState::BoundsChangeAnimationType::DEFAULT);
old_window_bounds_in_screen_ = window->GetBoundsInScreen();
old_state_.reset( old_state_.reset(
state->SetStateObject(std::unique_ptr<State>(this)).release()); state->SetStateObject(std::unique_ptr<State>(this)).release());
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "base/macros.h" #include "base/macros.h"
#include "ui/gfx/geometry/rect.h"
namespace ash { namespace ash {
class TabletModeWindowManager; class TabletModeWindowManager;
...@@ -51,6 +52,9 @@ class TabletModeWindowState : public WindowState::State { ...@@ -51,6 +52,9 @@ class TabletModeWindowState : public WindowState::State {
WindowState::State* previous_state) override; WindowState::State* previous_state) override;
void DetachState(WindowState* window_state) override; void DetachState(WindowState* window_state) override;
gfx::Rect old_window_bounds_in_screen() const {
return old_window_bounds_in_screen_;
}
WindowState::State* old_state() { return old_state_.get(); } WindowState::State* old_state() { return old_state_.get(); }
private: private:
...@@ -77,7 +81,8 @@ class TabletModeWindowState : public WindowState::State { ...@@ -77,7 +81,8 @@ class TabletModeWindowState : public WindowState::State {
// window state. If |animated| is set we animate the change. // window state. If |animated| is set we animate the change.
void UpdateBounds(WindowState* window_state, bool animated); void UpdateBounds(WindowState* window_state, bool animated);
// The original state object of the window. // The original bounds and state object of the window.
gfx::Rect old_window_bounds_in_screen_;
std::unique_ptr<WindowState::State> old_state_; std::unique_ptr<WindowState::State> old_state_;
// The window whose WindowState owns this instance. // The window whose WindowState owns this instance.
......
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