Skip to content

Commit

Permalink
Rename StackingClient -> WindowTreeClient
Browse files Browse the repository at this point in the history
Remove SetDefaultParentForRootWindow from Window, and replace with new utility function ParentWindowForContext in window_tree_client.h
This is part of my current campaign to slim down the aura Window types. I will eventually move WindowTreeClient to a new ui/wm component that I plan to create.

R=erg@chromium.org
http://crbug.com/308844

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230501 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ben@chromium.org committed Oct 23, 2013
1 parent 9e00f36 commit e3225e0
Show file tree
Hide file tree
Showing 53 changed files with 351 additions and 333 deletions.
1 change: 0 additions & 1 deletion ash/display/screen_position_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/stacking_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window_tracker.h"
#include "ui/compositor/dip_util.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/display/screen_position_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ScreenPositionControllerTest : public test::AshTestBase {
window_.reset(new aura::Window(&window_delegate_));
window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window_->Init(ui::LAYER_NOT_DRAWN);
SetDefaultParentByPrimaryRootWindow(window_.get());
ParentWindowInPrimaryRootWindow(window_.get());
window_->set_id(1);
}

Expand Down
3 changes: 2 additions & 1 deletion ash/drag_drop/drag_drop_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/root_window.h"
#include "ui/events/event.h"
#include "ui/gfx/screen.h"
Expand All @@ -22,7 +23,7 @@ aura::Window* CreateCaptureWindow(aura::RootWindow* context_root,
aura::Window* window = new aura::Window(delegate);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_NOT_DRAWN);
window->SetDefaultParentByRootWindow(context_root, gfx::Rect());
aura::client::ParentWindowWithContext(window, context_root, gfx::Rect());
window->Show();
DCHECK(window->bounds().size().IsEmpty());
return window;
Expand Down
2 changes: 1 addition & 1 deletion ash/root_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ RootWindowController::RootWindowController(aura::RootWindow* root_window)
screen_dimmer_.reset(new ScreenDimmer(root_window));

stacking_controller_.reset(new StackingController);
aura::client::SetStackingClient(root_window, stacking_controller_.get());
aura::client::SetWindowTreeClient(root_window, stacking_controller_.get());
capture_client_.reset(new views::corewm::ScopedCaptureClient(root_window));
}

Expand Down
5 changes: 3 additions & 2 deletions ash/root_window_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "base/command_line.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
Expand Down Expand Up @@ -573,8 +574,8 @@ TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) {
window1->set_owned_by_parent(false);
observer1.SetWindow(window1);
window1->Init(ui::LAYER_NOT_DRAWN);
window1->SetDefaultParentByRootWindow(
Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect());
aura::client::ParentWindowWithContext(
window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect());

DestroyedWindowObserver observer2;
aura::Window* window2 = new aura::Window(NULL);
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase {
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_TEXTURED);
SetDefaultParentByPrimaryRootWindow(window);
ParentWindowInPrimaryRootWindow(window);
return window;
}

Expand Down
1 change: 0 additions & 1 deletion ash/shell/content_client/shell_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_net_log.h"
#include "net/base/net_module.h"
#include "ui/aura/client/stacking_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
Expand Down
2 changes: 1 addition & 1 deletion ash/shell_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ TEST_F(ShellTest, ToggleAutoHide) {
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_TEXTURED);
SetDefaultParentByPrimaryRootWindow(window.get());
ParentWindowInPrimaryRootWindow(window.get());
window->Show();
wm::ActivateWindow(window.get());

Expand Down
11 changes: 6 additions & 5 deletions ash/test/ash_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "content/public/test/web_contents_tester.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h"
Expand Down Expand Up @@ -249,7 +250,7 @@ aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType(
window->Show();

if (bounds.IsEmpty()) {
SetDefaultParentByPrimaryRootWindow(window);
ParentWindowInPrimaryRootWindow(window);
} else {
gfx::Display display =
Shell::GetScreen()->GetDisplayMatching(bounds);
Expand All @@ -258,15 +259,15 @@ aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType(
gfx::Point origin = bounds.origin();
wm::ConvertPointFromScreen(root, &origin);
window->SetBounds(gfx::Rect(origin, bounds.size()));
window->SetDefaultParentByRootWindow(root, bounds);
aura::client::ParentWindowWithContext(window, root, bounds);
}
window->SetProperty(aura::client::kCanMaximizeKey, true);
return window;
}

void AshTestBase::SetDefaultParentByPrimaryRootWindow(aura::Window* window) {
window->SetDefaultParentByRootWindow(
Shell::GetPrimaryRootWindow(), gfx::Rect());
void AshTestBase::ParentWindowInPrimaryRootWindow(aura::Window* window) {
aura::client::ParentWindowWithContext(
window, Shell::GetPrimaryRootWindow(), gfx::Rect());
}

void AshTestBase::RunAllPendingInMessageLoop() {
Expand Down
2 changes: 1 addition & 1 deletion ash/test/ash_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AshTestBase : public testing::Test {
const gfx::Rect& bounds);

// Attach |window| to the current shell's root window.
void SetDefaultParentByPrimaryRootWindow(aura::Window* window);
void ParentWindowInPrimaryRootWindow(aura::Window* window);

// Returns the EventGenerator that uses screen coordinates and works
// across multiple displays. It createse a new generator if it
Expand Down
3 changes: 2 additions & 1 deletion ash/wm/dock/docked_window_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
Expand Down Expand Up @@ -111,7 +112,7 @@ void UndockWindow(aura::Window* window) {
window->layer()->GetAnimator()->StopAnimating();
gfx::Rect previous_bounds = window->bounds();
aura::Window* previous_parent = window->parent();
window->SetDefaultParentByRootWindow(window->GetRootWindow(), gfx::Rect());
aura::client::ParentWindowWithContext(window, window, gfx::Rect());
if (window->parent() != previous_parent)
wm::ReparentTransientChildrenOfChild(window->parent(), window);
// Animate maximize animation from previous window bounds.
Expand Down
6 changes: 3 additions & 3 deletions ash/wm/dock/docked_window_resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/command_line.h"
#include "base/memory/weak_ptr.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
Expand Down Expand Up @@ -270,16 +271,15 @@ void DockedWindowResizer::FinishedDragging() {
wm::ReparentChildWithTransientChildren(dock_container, window);
} else if (window->parent()->id() == kShellWindowId_DockedContainer) {
// Reparent the window back to workspace.
// We need to be careful to give SetDefaultParentByRootWindow location in
// We need to be careful to give ParentWindowWithContext a location in
// the right root window (matching the logic in DragWindowResizer) based
// on which root window a mouse pointer is in. We want to undock into the
// right screen near the edge of a multiscreen setup (based on where the
// mouse is).
gfx::Rect near_last_location(last_location_, gfx::Size());
// Reparenting will cause Relayout and possible dock shrinking.
aura::Window* previous_parent = window->parent();
window->SetDefaultParentByRootWindow(window->GetRootWindow(),
near_last_location);
aura::client::ParentWindowWithContext(window, window, near_last_location);
if (window->parent() != previous_parent)
wm::ReparentTransientChildrenOfChild(window->parent(), window);
}
Expand Down
14 changes: 7 additions & 7 deletions ash/wm/drag_window_resizer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,41 @@ class DragWindowResizerTest : public test::AshTestBase {
window_.reset(new aura::Window(&delegate_));
window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window_->Init(ui::LAYER_NOT_DRAWN);
SetDefaultParentByPrimaryRootWindow(window_.get());
ParentWindowInPrimaryRootWindow(window_.get());
window_->set_id(1);

always_on_top_window_.reset(new aura::Window(&delegate2_));
always_on_top_window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
always_on_top_window_->SetProperty(aura::client::kAlwaysOnTopKey, true);
always_on_top_window_->Init(ui::LAYER_NOT_DRAWN);
SetDefaultParentByPrimaryRootWindow(always_on_top_window_.get());
ParentWindowInPrimaryRootWindow(always_on_top_window_.get());
always_on_top_window_->set_id(2);

system_modal_window_.reset(new aura::Window(&delegate3_));
system_modal_window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
system_modal_window_->SetProperty(aura::client::kModalKey,
ui::MODAL_TYPE_SYSTEM);
system_modal_window_->Init(ui::LAYER_NOT_DRAWN);
SetDefaultParentByPrimaryRootWindow(system_modal_window_.get());
ParentWindowInPrimaryRootWindow(system_modal_window_.get());
system_modal_window_->set_id(3);

transient_child_ = new aura::Window(&delegate4_);
transient_child_->SetType(aura::client::WINDOW_TYPE_NORMAL);
transient_child_->Init(ui::LAYER_NOT_DRAWN);
SetDefaultParentByPrimaryRootWindow(transient_child_);
ParentWindowInPrimaryRootWindow(transient_child_);
transient_child_->set_id(4);

transient_parent_.reset(new aura::Window(&delegate5_));
transient_parent_->SetType(aura::client::WINDOW_TYPE_NORMAL);
transient_parent_->Init(ui::LAYER_NOT_DRAWN);
SetDefaultParentByPrimaryRootWindow(transient_parent_.get());
ParentWindowInPrimaryRootWindow(transient_parent_.get());
transient_parent_->AddTransientChild(transient_child_);
transient_parent_->set_id(5);

panel_window_.reset(new aura::Window(&delegate6_));
panel_window_->SetType(aura::client::WINDOW_TYPE_PANEL);
panel_window_->Init(ui::LAYER_NOT_DRAWN);
SetDefaultParentByPrimaryRootWindow(panel_window_.get());
ParentWindowInPrimaryRootWindow(panel_window_.get());
}

virtual void TearDown() OVERRIDE {
Expand Down Expand Up @@ -227,7 +227,7 @@ TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) {
scoped_ptr<aura::Window> window(new aura::Window(&delegate));
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_TEXTURED);
SetDefaultParentByPrimaryRootWindow(window.get());
ParentWindowInPrimaryRootWindow(window.get());
window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
Shell::GetScreen()->GetPrimaryDisplay());
window->Show();
Expand Down
5 changes: 3 additions & 2 deletions ash/wm/header_painter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "grit/ash_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window_observer.h"
#include "ui/base/hit_test.h"
Expand Down Expand Up @@ -395,8 +396,8 @@ TEST_F(HeaderPainterTest, UseSoloWindowHeaderNotDrawn) {
scoped_ptr<aura::Window> window(new aura::Window(NULL));
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_NOT_DRAWN);
window->SetDefaultParentByRootWindow(
widget->GetNativeWindow()->GetRootWindow(), gfx::Rect());
aura::client::ParentWindowWithContext(window.get(), widget->GetNativeWindow(),
gfx::Rect());
window->Show();

// Despite two windows, the first window should still be considered "solo"
Expand Down
6 changes: 3 additions & 3 deletions ash/wm/panels/panel_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
Expand Down Expand Up @@ -352,9 +353,8 @@ void PanelLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
// back to appropriate container and ignore it.
// TODO(varkha): Updating bounds during a drag can cause problems and a more
// general solution is needed. See http://crbug.com/251813 .
child->SetDefaultParentByRootWindow(
child->GetRootWindow(),
child->GetRootWindow()->GetBoundsInScreen());
aura::client::ParentWindowWithContext(
child, child, child->GetRootWindow()->GetBoundsInScreen());
wm::ReparentTransientChildrenOfChild(child->parent(), child);
DCHECK(child->parent()->id() != kShellWindowId_PanelContainer);
return;
Expand Down
19 changes: 11 additions & 8 deletions ash/wm/panels/panel_window_resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "ash/wm/window_util.h"
#include "base/memory/weak_ptr.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
Expand Down Expand Up @@ -195,10 +196,11 @@ void PanelWindowResizer::StartedDragging() {
wm::GetWindowState(GetTarget())->set_panel_attached(true);
// We use root window coordinates to ensure that during the drag the panel
// is reparented to a container in the root window that has that window.
GetTarget()->SetDefaultParentByRootWindow(
GetTarget()->GetRootWindow(),
GetTarget()->GetRootWindow()->GetBoundsInScreen());
wm::ReparentTransientChildrenOfChild(GetTarget()->parent(), GetTarget());
aura::Window* target = GetTarget();
aura::RootWindow* target_root = target->GetRootWindow();
aura::client::ParentWindowWithContext(
target, target_root, target_root->GetBoundsInScreen());
wm::ReparentTransientChildrenOfChild(target->parent(), target);
}
}

Expand All @@ -209,10 +211,11 @@ void PanelWindowResizer::FinishDragging() {
wm::GetWindowState(GetTarget())->set_panel_attached(should_attach_);
// We use last known location to ensure that after the drag the panel
// is reparented to a container in the root window that has that location.
GetTarget()->SetDefaultParentByRootWindow(
GetTarget()->GetRootWindow(),
gfx::Rect(last_location_, gfx::Size()));
wm::ReparentTransientChildrenOfChild(GetTarget()->parent(), GetTarget());
aura::Window* target = GetTarget();
aura::RootWindow* target_root = target->GetRootWindow();
aura::client::ParentWindowWithContext(
target, target_root, gfx::Rect(last_location_, gfx::Size()));
wm::ReparentTransientChildrenOfChild(target->parent(), GetTarget());
}

// If we started the drag in one root window and moved into another root
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/stacking_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ StackingController::~StackingController() {
}

////////////////////////////////////////////////////////////////////////////////
// StackingController, aura::StackingClient implementation:
// StackingController, aura::client::WindowTreeClient implementation:

aura::Window* StackingController::GetDefaultParent(aura::Window* context,
aura::Window* window,
Expand Down
6 changes: 3 additions & 3 deletions ash/wm/stacking_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/client/stacking_client.h"
#include "ui/aura/client/window_tree_client.h"

namespace aura{
class RootWindow;
Expand All @@ -21,12 +21,12 @@ namespace internal {
class AlwaysOnTopController;
}

class ASH_EXPORT StackingController : public aura::client::StackingClient {
class ASH_EXPORT StackingController : public aura::client::WindowTreeClient {
public:
StackingController();
virtual ~StackingController();

// Overridden from aura::client::StackingClient:
// Overridden from aura::client::WindowTreeClient:
virtual aura::Window* GetDefaultParent(aura::Window* context,
aura::Window* window,
const gfx::Rect& bounds) OVERRIDE;
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/stacking_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST_F(StackingControllerTest, TransientParent) {
scoped_ptr<Window> w1(CreateTestWindow());
w2->AddTransientChild(w1.get());
w1->SetBounds(gfx::Rect(10, 11, 250, 251));
SetDefaultParentByPrimaryRootWindow(w1.get());
ParentWindowInPrimaryRootWindow(w1.get());
w1->Show();
wm::ActivateWindow(w1.get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MultiWindowResizeControllerTest : public test::AshTestBase {
aura::Window* window = new aura::Window(delegate);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_TEXTURED);
SetDefaultParentByPrimaryRootWindow(window);
ParentWindowInPrimaryRootWindow(window);
window->SetBounds(bounds);
window->Show();
return window;
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/workspace/workspace_event_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WorkspaceEventHandlerTest : public test::AshTestBase {
aura::Window* window = new aura::Window(delegate);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_TEXTURED);
SetDefaultParentByPrimaryRootWindow(window);
ParentWindowInPrimaryRootWindow(window);
window->SetBounds(bounds);
window->Show();
return window;
Expand Down
2 changes: 1 addition & 1 deletion ash/wm/workspace/workspace_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
// NOTE: for this test to exercise the failure the observer needs to be added
// before the parent set. This mimics what BrowserFrameAsh does.
window->AddObserver(&window_observer);
SetDefaultParentByPrimaryRootWindow(window.get());
ParentWindowInPrimaryRootWindow(window.get());
window->Show();

wm::WindowState* window_state = wm::GetWindowState(window.get());
Expand Down
Loading

0 comments on commit e3225e0

Please sign in to comment.