Skip to content

Commit

Permalink
Rename RootWindowObserver::OnRootWindowResized to OnRootWindowHostRes…
Browse files Browse the repository at this point in the history
…ized, and

RootWindowObserver::OnRootWindowMoved to OnRootWindowHostMoved

- Changed so that this is called only when host window's size
  is changed.
- Remove old argument as it was RootWindow's size but not HostWindow's, and it's not used.

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/16410015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205706 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
oshima@chromium.org committed Jun 12, 2013
1 parent bbd8286 commit 07481be
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 105 deletions.
13 changes: 4 additions & 9 deletions ash/display/display_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -740,23 +740,18 @@ void DisplayManager::ToggleDisplayScaleFactor() {
UpdateDisplays(new_display_info_list);
}

void DisplayManager::OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) {
void DisplayManager::OnRootWindowHostResized(const aura::RootWindow* root) {
if (change_display_upon_host_resize_) {
gfx::Display& display = FindDisplayForRootWindow(root);
gfx::Size old_display_size_in_pixel = display.GetSizeInPixel();
display_info_[display.id()].SetBounds(
gfx::Rect(root->GetHostOrigin(), root->GetHostSize()));
const gfx::Size& new_root_size = root->bounds().size();
// It's tricky to support resizing mirror window on desktop.
if (software_mirroring_enabled_ && mirrored_display_.id() == display.id())
return;
if (old_size != new_root_size) {
display.SetSize(display_info_[display.id()].size_in_pixel());
Shell::GetInstance()->screen()->NotifyBoundsChanged(display);
Shell::GetInstance()->mirror_window_controller()->
UpdateWindow();
}
display.SetSize(display_info_[display.id()].size_in_pixel());
Shell::GetInstance()->screen()->NotifyBoundsChanged(display);
Shell::GetInstance()->mirror_window_controller()->UpdateWindow();
}
}

Expand Down
3 changes: 1 addition & 2 deletions ash/display/display_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ class ASH_EXPORT DisplayManager :
void ToggleDisplayScaleFactor();

// RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& new_size) OVERRIDE;
virtual void OnRootWindowHostResized(const aura::RootWindow* root) OVERRIDE;

// SoftwareMirroringController override:
#if defined(OS_CHROMEOS)
Expand Down
7 changes: 2 additions & 5 deletions ash/display/mirror_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ void MirrorWindowController::Close() {
if (root_window_.get()) {
ui::ContextFactory::GetInstance()->RemoveReflector(reflector_);
reflector_ = NULL;
root_window_->RemoveRootWindowObserver(
Shell::GetInstance()->display_manager());
NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>(
aura::client::GetCaptureClient(root_window_.get()));
delete capture_client;
Expand Down Expand Up @@ -279,9 +277,8 @@ void MirrorWindowController::SetMirroredCursorVisibility(bool visible) {
visible ? cursor_window_->Show() : cursor_window_->Hide();
}

void MirrorWindowController::OnRootWindowResized(
const aura::RootWindow* root,
const gfx::Size& old_size) {
void MirrorWindowController::OnRootWindowHostResized(
const aura::RootWindow* root) {
// Do not use |old_size| as it contains RootWindow's (but not host's) size,
// and this parameter wil be removed soon.
if (mirror_window_host_size_ == root->GetHostSize())
Expand Down
3 changes: 1 addition & 2 deletions ash/display/mirror_window_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class MirrorWindowController : public aura::RootWindowObserver {
void SetMirroredCursorVisibility(bool visible);

// aura::RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE;
virtual void OnRootWindowHostResized(const aura::RootWindow* root) OVERRIDE;

private:
friend class test::MirrorWindowTestApi;
Expand Down
11 changes: 6 additions & 5 deletions ash/wm/app_list_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void AppListController::SetView(app_list::AppListView* view) {
widget->AddObserver(this);
Shell::GetInstance()->AddPreTargetHandler(this);
Launcher::ForWindow(widget->GetNativeWindow())->AddIconObserver(this);
widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this);
widget->GetNativeView()->GetRootWindow()->AddObserver(this);
aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this);

view_->ShowWhenReady();
Expand All @@ -172,7 +172,7 @@ void AppListController::ResetView() {
GetLayer(widget)->GetAnimator()->RemoveObserver(this);
Shell::GetInstance()->RemovePreTargetHandler(this);
Launcher::ForWindow(widget->GetNativeWindow())->RemoveIconObserver(this);
widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this);
widget->GetNativeView()->GetRootWindow()->RemoveObserver(this);
aura::client::GetFocusClient(widget->GetNativeView())->RemoveObserver(this);
view_ = NULL;
}
Expand Down Expand Up @@ -264,9 +264,10 @@ void AppListController::OnWindowFocused(aura::Window* gained_focus,
}

////////////////////////////////////////////////////////////////////////////////
// AppListController, aura::RootWindowObserver implementation:
void AppListController::OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) {
// AppListController, aura::WindowObserver implementation:
void AppListController::OnWindowBoundsChanged(aura::Window* root,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
UpdateBounds();
}

Expand Down
11 changes: 6 additions & 5 deletions ash/wm/app_list_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/timer.h"
#include "ui/app_list/pagination_model_observer.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/root_window_observer.h"
#include "ui/aura/window_observer.h"
#include "ui/base/events/event_handler.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/gfx/rect.h"
Expand All @@ -37,7 +37,7 @@ namespace internal {
// activation state and desktop mouse click to auto dismiss the UI.
class AppListController : public ui::EventHandler,
public aura::client::FocusChangeObserver,
public aura::RootWindowObserver,
public aura::WindowObserver,
public ui::ImplicitAnimationObserver,
public views::WidgetObserver,
public ShellObserver,
Expand Down Expand Up @@ -90,9 +90,10 @@ class AppListController : public ui::EventHandler,
virtual void OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) OVERRIDE;

// aura::RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE;
// aura::WindowObserver overrides:
virtual void OnWindowBoundsChanged(aura::Window* root,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;

// ui::ImplicitAnimationObserver overrides:
virtual void OnImplicitAnimationsCompleted() OVERRIDE;
Expand Down
20 changes: 8 additions & 12 deletions ash/wm/base_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ BaseLayoutManager::BaseLayoutManager(aura::RootWindow* root_window)
: root_window_(root_window) {
Shell::GetInstance()->activation_client()->AddObserver(this);
Shell::GetInstance()->AddShellObserver(this);
root_window_->AddRootWindowObserver(this);
root_window_->AddObserver(this);
}

BaseLayoutManager::~BaseLayoutManager() {
if (root_window_) {
if (root_window_)
root_window_->RemoveObserver(this);
root_window_->RemoveRootWindowObserver(this);
}
for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i)
(*i)->RemoveObserver(this);
Shell::GetInstance()->RemoveShellObserver(this);
Expand Down Expand Up @@ -105,14 +102,6 @@ void BaseLayoutManager::SetChildBounds(aura::Window* child,
SetChildBoundsDirect(child, child_bounds);
}

/////////////////////////////////////////////////////////////////////////////
// BaseLayoutManager, RootWindowObserver overrides:

void BaseLayoutManager::OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) {
AdjustWindowSizesForScreenChange();
}

/////////////////////////////////////////////////////////////////////////////
// BaseLayoutManager, ash::ShellObserver overrides:

Expand Down Expand Up @@ -150,6 +139,13 @@ void BaseLayoutManager::OnWindowDestroying(aura::Window* window) {
}
}

void BaseLayoutManager::OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
if (root_window_ == window)
AdjustWindowSizesForScreenChange();
}

//////////////////////////////////////////////////////////////////////////////
// BaseLayoutManager, aura::client::ActivationChangeObserver implementation:

Expand Down
9 changes: 3 additions & 6 deletions ash/wm/base_layout_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "base/compiler_specific.h"
#include "ui/aura/client/activation_change_observer.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/root_window_observer.h"
#include "ui/aura/window_observer.h"
#include "ui/base/events/event_handler.h"
#include "ui/base/ui_base_types.h"
Expand All @@ -33,7 +32,6 @@ namespace internal {
// properly.
class ASH_EXPORT BaseLayoutManager
: public aura::LayoutManager,
public aura::RootWindowObserver,
public ash::ShellObserver,
public aura::WindowObserver,
public aura::client::ActivationChangeObserver {
Expand Down Expand Up @@ -61,10 +59,6 @@ class ASH_EXPORT BaseLayoutManager
virtual void SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) OVERRIDE;

// RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE;

// ash::ShellObserver overrides:
virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE;

Expand All @@ -73,6 +67,9 @@ class ASH_EXPORT BaseLayoutManager
const void* key,
intptr_t old) OVERRIDE;
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
virtual void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;

// aura::client::ActivationChangeObserver overrides:
virtual void OnWindowActivated(aura::Window* gained_active,
Expand Down
9 changes: 5 additions & 4 deletions ash/wm/screen_dimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ const int kDimmingTransitionMs = 200;
ScreenDimmer::ScreenDimmer(aura::RootWindow* root_window)
: root_window_(root_window),
currently_dimming_(false) {
root_window_->AddRootWindowObserver(this);
root_window_->AddObserver(this);
}

ScreenDimmer::~ScreenDimmer() {
root_window_->RemoveRootWindowObserver(this);
root_window_->RemoveObserver(this);
}

void ScreenDimmer::SetDimming(bool should_dim) {
Expand All @@ -58,8 +58,9 @@ void ScreenDimmer::SetDimming(bool should_dim) {
dimming_layer_->SetOpacity(should_dim ? kDimmingLayerOpacity : 0.0f);
}

void ScreenDimmer::OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) {
void ScreenDimmer::OnWindowBoundsChanged(aura::Window* root,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
if (dimming_layer_)
dimming_layer_->SetBounds(gfx::Rect(root->bounds().size()));
}
Expand Down
11 changes: 6 additions & 5 deletions ash/wm/screen_dimmer.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/root_window_observer.h"
#include "ui/aura/window_observer.h"

namespace aura {
class RootWindow;
Expand All @@ -29,7 +29,7 @@ namespace internal {
// briefly dim the screen (e.g. to indicate to the user that we're
// about to suspend a machine that lacks an internal backlight that
// can be adjusted).
class ASH_EXPORT ScreenDimmer : public aura::RootWindowObserver {
class ASH_EXPORT ScreenDimmer : public aura::WindowObserver {
public:
class TestApi {
public:
Expand All @@ -49,9 +49,10 @@ class ASH_EXPORT ScreenDimmer : public aura::RootWindowObserver {
// Dim or undim the root window.
void SetDimming(bool should_dim);

// aura::RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE;
// aura::WindowObserver overrides:
virtual void OnWindowBoundsChanged(aura::Window* root_window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;

private:
friend class TestApi;
Expand Down
11 changes: 6 additions & 5 deletions ash/wm/system_background_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SystemBackgroundController::SystemBackgroundController(
SkColor color)
: root_window_(root_window),
layer_(new ui::Layer(ui::LAYER_SOLID_COLOR)) {
root_window_->AddRootWindowObserver(this);
root_window_->AddObserver(this);
layer_->SetColor(color);

ui::Layer* root_layer = root_window_->layer();
Expand All @@ -35,16 +35,17 @@ SystemBackgroundController::SystemBackgroundController(
}

SystemBackgroundController::~SystemBackgroundController() {
root_window_->RemoveRootWindowObserver(this);
root_window_->RemoveObserver(this);
}

void SystemBackgroundController::SetColor(SkColor color) {
layer_->SetColor(color);
}

void SystemBackgroundController::OnRootWindowResized(
const aura::RootWindow* root,
const gfx::Size& old_size) {
void SystemBackgroundController::OnWindowBoundsChanged(
aura::Window* root,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
DCHECK_EQ(root_window_, root);
layer_->SetBounds(gfx::Rect(root_window_->layer()->bounds().size()));
}
Expand Down
11 changes: 6 additions & 5 deletions ash/wm/system_background_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/root_window_observer.h"
#include "ui/aura/window_observer.h"

namespace aura {
class RootWindow;
Expand All @@ -30,16 +30,17 @@ namespace internal {
// desktop background image is loaded at startup, or when we scale down all of
// the other layers as part of a power-button or window-management animation).
// It should never be transformed or restacked.
class SystemBackgroundController : public aura::RootWindowObserver {
class SystemBackgroundController : public aura::WindowObserver {
public:
SystemBackgroundController(aura::RootWindow* root_window, SkColor color);
virtual ~SystemBackgroundController();

void SetColor(SkColor color);

// aura::RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE;
// aura::WindowObserver overrides:
virtual void OnWindowBoundsChanged(aura::Window* root,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;

private:
class HostContentLayerDelegate;
Expand Down
18 changes: 9 additions & 9 deletions ash/wm/workspace/workspace_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ WorkspaceLayoutManager::WorkspaceLayoutManager(Workspace* workspace)
work_area_(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
workspace->window()->parent())) {
Shell::GetInstance()->AddShellObserver(this);
root_window_->AddRootWindowObserver(this);
root_window_->AddObserver(this);
}

WorkspaceLayoutManager::~WorkspaceLayoutManager() {
if (root_window_) {
if (root_window_)
root_window_->RemoveObserver(this);
root_window_->RemoveRootWindowObserver(this);
}
for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i)
(*i)->RemoveObserver(this);
Shell::GetInstance()->RemoveShellObserver(this);
Expand Down Expand Up @@ -158,11 +155,6 @@ void WorkspaceLayoutManager::SetChildBounds(
workspace_manager()->OnWorkspaceWindowChildBoundsChanged(workspace_, child);
}

void WorkspaceLayoutManager::OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) {
AdjustWindowSizesForScreenChange(ADJUST_WINDOW_SCREEN_SIZE_CHANGED);
}

void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() {
if (workspace_manager()->active_workspace_ == workspace_) {
const gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
Expand Down Expand Up @@ -261,6 +253,14 @@ void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) {
}
}

void WorkspaceLayoutManager::OnWindowBoundsChanged(
aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
if (root_window_ == window)
AdjustWindowSizesForScreenChange(ADJUST_WINDOW_SCREEN_SIZE_CHANGED);
}

void WorkspaceLayoutManager::ShowStateChanged(
Window* window,
ui::WindowShowState last_show_state,
Expand Down
Loading

0 comments on commit 07481be

Please sign in to comment.