Skip to content

Commit

Permalink
Removes most of aura dependencies from DefaultState
Browse files Browse the repository at this point in the history
The last remaining bit is for docking, which will come later.

BUG=603369
TEST=none
R=oshima@chromium.org

Review URL: https://codereview.chromium.org/1901773002

Cr-Commit-Position: refs/heads/master@{#388385}
  • Loading branch information
sky authored and Commit bot committed Apr 20, 2016
1 parent b5b932a commit f961b35
Show file tree
Hide file tree
Showing 42 changed files with 427 additions and 330 deletions.
23 changes: 12 additions & 11 deletions ash/accelerators/accelerator_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ash/test/test_shell_delegate.h"
#include "ash/test/test_volume_control_delegate.h"
#include "ash/volume_control_delegate.h"
#include "ash/wm/common/window_positioning_utils.h"
#include "ash/wm/common/wm_event.h"
#include "ash/wm/lock_state_controller.h"
#include "ash/wm/panels/panel_layout_manager.h"
Expand Down Expand Up @@ -450,13 +451,13 @@ TEST_F(AcceleratorControllerTest, WindowSnap) {
{
GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
window.get());
wm::WmWindowAura::Get(window.get()));
EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
}
{
GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent(
window.get());
wm::WmWindowAura::Get(window.get()));
EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
}
{
Expand Down Expand Up @@ -505,7 +506,7 @@ TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftRestore) {
GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
window1.get());
wm::WmWindowAura::Get(window1.get()));
EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
EXPECT_TRUE(window1_state->IsSnapped());
GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
Expand All @@ -527,8 +528,8 @@ TEST_F(AcceleratorControllerTest, WindowSnapRightDockRightRestore) {

GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
gfx::Rect expected_bounds =
wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get());
gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent(
wm::WmWindowAura::Get(window1.get()));
EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
EXPECT_TRUE(window1_state->IsSnapped());
GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
Expand All @@ -549,10 +550,10 @@ TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftSnapRight) {
window1_state->Activate();

GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
gfx::Rect expected_bounds =
wm::GetDefaultLeftSnappedWindowBoundsInParent(window1.get());
gfx::Rect expected_bounds2 =
wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get());
gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
wm::WmWindowAura::Get(window1.get()));
gfx::Rect expected_bounds2 = wm::GetDefaultRightSnappedWindowBoundsInParent(
wm::WmWindowAura::Get(window1.get()));
EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString());
EXPECT_TRUE(window1_state->IsSnapped());
GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
Expand Down Expand Up @@ -621,8 +622,8 @@ TEST_F(AcceleratorControllerTest, WindowPanelDockLeftDockRightRestore) {

gfx::Rect window_restore_bounds2 = window->bounds();
GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
gfx::Rect expected_bounds =
wm::GetDefaultLeftSnappedWindowBoundsInParent(window.get());
gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
wm::WmWindowAura::Get(window.get()));
gfx::Rect window_restore_bounds =
window_state->GetRestoreBoundsInScreen();
EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString());
Expand Down
9 changes: 6 additions & 3 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,13 @@
'wm/aura/wm_window_aura.h',
'wm/boot_splash_screen_chromeos.cc',
'wm/boot_splash_screen_chromeos.h',
'wm/common/window_animation_types.h',
'wm/common/window_parenting_utils.cc',
'wm/common/window_parenting_utils.h',
'wm/common/window_positioning_utils.cc',
'wm/common/window_positioning_utils.h',
'wm/common/window_state_util.cc',
'wm/common/window_state_util.h',
'wm/common/wm_event.cc',
'wm/common/wm_event.h',
'wm/common/wm_globals.h',
Expand All @@ -550,6 +555,7 @@
'wm/common/wm_window_observer.h',
'wm/common/wm_window_property.h',
'wm/common/workspace/workspace_layout_manager_delegate.h',
'wm/common/workspace/workspace_types.h',
'wm/coordinate_conversion.cc',
'wm/coordinate_conversion.h',
'wm/cursor_manager_chromeos.cc',
Expand Down Expand Up @@ -682,8 +688,6 @@
'wm/window_state_delegate.cc',
'wm/window_state_delegate.h',
'wm/window_state_observer.h',
'wm/window_state_util.cc',
'wm/window_state_util.h',
'wm/window_util.cc',
'wm/window_util.h',
'wm/workspace/magnetism_matcher.cc',
Expand All @@ -699,7 +703,6 @@
'wm/workspace/workspace_layout_manager.cc',
'wm/workspace/workspace_layout_manager.h',
'wm/workspace/workspace_layout_manager_backdrop_delegate.h',
'wm/workspace/workspace_types.h',
'wm/workspace/workspace_window_resizer.cc',
'wm/workspace/workspace_window_resizer.h',
'wm/workspace_controller.cc',
Expand Down
13 changes: 9 additions & 4 deletions ash/frame/caption_buttons/frame_size_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/window_positioning_utils.h"
#include "ash/wm/common/wm_event.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_state_aura.h"
Expand Down Expand Up @@ -223,11 +225,14 @@ void FrameSizeButton::UpdateSnapType(const ui::LocatedEvent& event) {
if (!phantom_window_controller_.get()) {
phantom_window_controller_.reset(new PhantomWindowController(window));
}
gfx::Rect phantom_bounds_in_parent = (snap_type_ == SNAP_LEFT) ?
wm::GetDefaultLeftSnappedWindowBoundsInParent(window) :
wm::GetDefaultRightSnappedWindowBoundsInParent(window);
gfx::Rect phantom_bounds_in_parent =
(snap_type_ == SNAP_LEFT)
? wm::GetDefaultLeftSnappedWindowBoundsInParent(
wm::WmWindowAura::Get(window))
: wm::GetDefaultRightSnappedWindowBoundsInParent(
wm::WmWindowAura::Get(window));
phantom_window_controller_->Show(ScreenUtil::ConvertRectToScreen(
window->parent(), phantom_bounds_in_parent));
window->parent(), phantom_bounds_in_parent));
} else {
phantom_window_controller_.reset();
}
Expand Down
3 changes: 2 additions & 1 deletion ash/root_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ash/touch/touch_hud_projection.h"
#include "ash/touch/touch_observer_hud.h"
#include "ash/wm/always_on_top_controller.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/workspace/workspace_layout_manager_delegate.h"
#include "ash/wm/dock/docked_window_layout_manager.h"
#include "ash/wm/lock_layout_manager.h"
Expand Down Expand Up @@ -134,7 +135,7 @@ void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
new_parent->id() != kShellWindowId_DockedContainer;
gfx::Rect local_bounds;
if (update_bounds) {
local_bounds = state->aura_window()->bounds();
local_bounds = wm::WmWindowAura::GetAuraWindow(state->window())->bounds();
MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
}

Expand Down
30 changes: 16 additions & 14 deletions ash/shelf/shelf_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ void ShelfLayoutManager::UpdateVisibilityState() {
} else {
// TODO(zelidrag): Verify shelf drag animation still shows on the device
// when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
WorkspaceWindowState window_state(workspace_controller_->GetWindowState());
wm::WorkspaceWindowState window_state(
workspace_controller_->GetWindowState());
switch (window_state) {
case WORKSPACE_WINDOW_STATE_FULL_SCREEN: {
case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: {
const aura::Window* fullscreen_window = GetRootWindowController(
root_window_)->GetWindowForFullscreenMode();
if (fullscreen_window && wm::GetWindowState(fullscreen_window)->
Expand All @@ -295,15 +296,15 @@ void ShelfLayoutManager::UpdateVisibilityState() {
break;
}

case WORKSPACE_WINDOW_STATE_MAXIMIZED:
case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED:
SetState(CalculateShelfVisibility());
break;

case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
case WORKSPACE_WINDOW_STATE_DEFAULT:
case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
case wm::WORKSPACE_WINDOW_STATE_DEFAULT:
SetState(CalculateShelfVisibility());
SetWindowOverlapsShelf(window_state ==
WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF);
SetWindowOverlapsShelf(
window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF);
break;
}
}
Expand Down Expand Up @@ -516,8 +517,9 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
State state;
state.visibility_state = visibility_state;
state.auto_hide_state = CalculateAutoHideState(visibility_state);
state.window_state = workspace_controller_ ?
workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT;
state.window_state = workspace_controller_
? workspace_controller_->GetWindowState()
: wm::WORKSPACE_WINDOW_STATE_DEFAULT;
// Preserve the log in screen states.
state.is_adding_user_screen = state_.is_adding_user_screen;
state.is_screen_locked = state_.is_screen_locked;
Expand Down Expand Up @@ -557,7 +559,7 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
// - Going from an auto hidden shelf in maximized mode to a visible shelf in
// maximized mode.
if (state.visibility_state == SHELF_VISIBLE &&
state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED &&
state.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED &&
old_state.visibility_state != SHELF_VISIBLE) {
change_type = BACKGROUND_CHANGE_IMMEDIATE;
} else {
Expand All @@ -579,9 +581,9 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
UpdateShelfBackground(change_type);
}

shelf_->SetDimsShelf(
state.visibility_state == SHELF_VISIBLE &&
state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED);
shelf_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE &&
state.window_state ==
wm::WORKSPACE_WINDOW_STATE_MAXIMIZED);

TargetBounds target_bounds;
CalculateTargetBounds(state_, &target_bounds);
Expand Down Expand Up @@ -875,7 +877,7 @@ void ShelfLayoutManager::UpdateShelfBackground(

ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
if (state_.visibility_state != SHELF_AUTO_HIDE &&
state_.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED) {
state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) {
return SHELF_BACKGROUND_MAXIMIZED;
}

Expand Down
15 changes: 8 additions & 7 deletions ash/shelf/shelf_layout_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "ash/shell_observer.h"
#include "ash/snap_to_pixel_layout_manager.h"
#include "ash/system/status_area_widget.h"
#include "ash/wm/common/workspace/workspace_types.h"
#include "ash/wm/dock/docked_window_layout_manager_observer.h"
#include "ash/wm/lock_state_observer.h"
#include "ash/wm/workspace/workspace_types.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/logging.h"
Expand Down Expand Up @@ -238,11 +238,12 @@ class ASH_EXPORT ShelfLayoutManager
};

struct State {
State() : visibility_state(SHELF_VISIBLE),
auto_hide_state(SHELF_AUTO_HIDE_HIDDEN),
window_state(WORKSPACE_WINDOW_STATE_DEFAULT),
is_screen_locked(false),
is_adding_user_screen(false) {}
State()
: visibility_state(SHELF_VISIBLE),
auto_hide_state(SHELF_AUTO_HIDE_HIDDEN),
window_state(wm::WORKSPACE_WINDOW_STATE_DEFAULT),
is_screen_locked(false),
is_adding_user_screen(false) {}

// Returns true if the two states are considered equal. As
// |auto_hide_state| only matters if |visibility_state| is
Expand All @@ -259,7 +260,7 @@ class ASH_EXPORT ShelfLayoutManager

ShelfVisibilityState visibility_state;
ShelfAutoHideState auto_hide_state;
WorkspaceWindowState window_state;
wm::WorkspaceWindowState window_state;
bool is_screen_locked;
bool is_adding_user_screen;
};
Expand Down
7 changes: 7 additions & 0 deletions ash/wm/aura/wm_globals_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ash/wm/aura/wm_globals_aura.h"

#include "ash/display/window_tree_host_manager.h"
#include "ash/session/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
Expand Down Expand Up @@ -45,6 +46,12 @@ WmWindow* WmGlobalsAura::GetActiveWindow() {
return WmWindowAura::Get(wm::GetActiveWindow());
}

WmWindow* WmGlobalsAura::GetRootWindowForDisplayId(int64_t display_id) {
return WmWindowAura::Get(Shell::GetInstance()
->window_tree_host_manager()
->GetRootWindowForDisplayId(display_id));
}

WmWindow* WmGlobalsAura::GetRootWindowForNewWindows() {
return WmWindowAura::Get(Shell::GetTargetRootWindow());
}
Expand Down
1 change: 1 addition & 0 deletions ash/wm/aura/wm_globals_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ASH_EXPORT WmGlobalsAura : public WmGlobals {

// WmGlobals:
WmWindow* GetActiveWindow() override;
WmWindow* GetRootWindowForDisplayId(int64_t display_id) override;
WmWindow* GetRootWindowForNewWindows() override;
std::vector<WmWindow*> GetMruWindowListIgnoreModals() override;
bool IsForceMaximizeOnFirstRun() override;
Expand Down
5 changes: 5 additions & 0 deletions ash/wm/aura/wm_root_window_controller_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ash/root_window_controller.h"
#include "ash/wm/aura/wm_globals_aura.h"
#include "ash/wm/workspace_controller.h"
#include "ui/aura/window.h"
#include "ui/aura/window_property.h"

Expand Down Expand Up @@ -57,5 +58,9 @@ WmGlobals* WmRootWindowControllerAura::GetGlobals() {
return WmGlobalsAura::Get();
}

WorkspaceWindowState WmRootWindowControllerAura::GetWorkspaceWindowState() {
return root_window_controller_->workspace_controller()->GetWindowState();
}

} // namespace wm
} // namespace ash
1 change: 1 addition & 0 deletions ash/wm/aura/wm_root_window_controller_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ASH_EXPORT WmRootWindowControllerAura : public WmRootWindowController {
// WmRootWindowController:
bool HasShelf() override;
WmGlobals* GetGlobals() override;
WorkspaceWindowState GetWorkspaceWindowState() override;

private:
RootWindowController* root_window_controller_;
Expand Down
16 changes: 16 additions & 0 deletions ash/wm/aura/wm_window_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ WmWindow* WmWindowAura::GetToplevelWindow() {
return Get(window_->GetToplevelWindow());
}

void WmWindowAura::AddChild(WmWindow* window) {
window_->AddChild(GetAuraWindow(window));
}

WmWindow* WmWindowAura::GetParent() {
return Get(window_->parent());
}
Expand All @@ -207,6 +211,14 @@ std::vector<WmWindow*> WmWindowAura::GetTransientChildren() {
return wm_windows;
}

void WmWindowAura::SetVisibilityAnimationType(int type) {
::wm::SetWindowVisibilityAnimationType(window_, type);
}

void WmWindowAura::Animate(::wm::WindowAnimationType type) {
::wm::AnimateWindow(window_, type);
}

void WmWindowAura::SetBounds(const gfx::Rect& bounds) {
window_->SetBounds(bounds);
}
Expand Down Expand Up @@ -315,6 +327,10 @@ ui::WindowShowState WmWindowAura::GetShowState() const {
return window_->GetProperty(aura::client::kShowStateKey);
}

void WmWindowAura::SetRestoreShowState(ui::WindowShowState show_state) {
window_->SetProperty(aura::client::kRestoreShowStateKey, show_state);
}

void WmWindowAura::SetCapture() {
window_->SetCapture();
}
Expand Down
4 changes: 4 additions & 0 deletions ash/wm/aura/wm_window_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ class ASH_EXPORT WmWindowAura : public WmWindow, public aura::WindowObserver {
bool GetBoolProperty(WmWindowProperty key) override;
const WindowState* GetWindowState() const override;
WmWindow* GetToplevelWindow() override;
void AddChild(WmWindow* window) override;
WmWindow* GetParent() override;
WmWindow* GetTransientParent() override;
std::vector<WmWindow*> GetTransientChildren() override;
void SetVisibilityAnimationType(int type) override;
void Animate(::wm::WindowAnimationType type) override;
void SetBounds(const gfx::Rect& bounds) override;
void SetBoundsWithTransitionDelay(const gfx::Rect& bounds,
base::TimeDelta delta) override;
Expand All @@ -78,6 +81,7 @@ class ASH_EXPORT WmWindowAura : public WmWindow, public aura::WindowObserver {
bool Contains(const WmWindow* other) const override;
void SetShowState(ui::WindowShowState show_state) override;
ui::WindowShowState GetShowState() const override;
void SetRestoreShowState(ui::WindowShowState show_state) override;
void SetCapture() override;
bool HasCapture() override;
void ReleaseCapture() override;
Expand Down
Loading

0 comments on commit f961b35

Please sign in to comment.