diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 18:23:02 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 18:23:02 +0000 |
commit | 01ba68876697c812af59ae26503db7fe72b52677 (patch) | |
tree | a601fdb4391ccd3d03d72d8af30e891dfcddfb86 /ash/display | |
parent | 4a007aac63e4f16a6d473b5a17903d66258e30d2 (diff) | |
download | chromium_src-01ba68876697c812af59ae26503db7fe72b52677.zip chromium_src-01ba68876697c812af59ae26503db7fe72b52677.tar.gz chromium_src-01ba68876697c812af59ae26503db7fe72b52677.tar.bz2 |
Revert r14457 "Cancel drag if display configuration changes."
This reverts commit 116e78b0600dd591d2b54390e290e95b8ea0355b.
link error in win_aura
TBR=oshima@chromium.org
BUG=14457
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10913174
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/display')
-rw-r--r-- | ash/display/display_controller.cc | 44 | ||||
-rw-r--r-- | ash/display/display_controller.h | 20 | ||||
-rw-r--r-- | ash/display/display_controller_unittest.cc | 40 | ||||
-rw-r--r-- | ash/display/multi_display_manager.cc | 32 | ||||
-rw-r--r-- | ash/display/multi_display_manager.h | 2 | ||||
-rw-r--r-- | ash/display/multi_display_manager_unittest.cc | 17 |
6 files changed, 49 insertions, 106 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc index 5cc96e7..16ee88c 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/display_controller.cc @@ -180,14 +180,6 @@ void DisplayController::InitSecondaryDisplays() { UpdateDisplayBoundsForLayout(); } -void DisplayController::AddObserver(Observer* observer) { - observers_.AddObserver(observer); -} - -void DisplayController::RemoveObserver(Observer* observer) { - observers_.RemoveObserver(observer); -} - aura::RootWindow* DisplayController::GetPrimaryRootWindow() { DCHECK(!root_windows_.empty()); aura::DisplayManager* display_manager = @@ -241,23 +233,14 @@ DisplayController::GetAllRootWindowControllers() { } void DisplayController::SetDefaultDisplayLayout(const DisplayLayout& layout) { - if (default_display_layout_.position != layout.position || - default_display_layout_.offset != layout.offset) { - default_display_layout_ = layout; - NotifyDisplayConfigurationChanging(); - UpdateDisplayBoundsForLayout(); - } + default_display_layout_ = layout; + UpdateDisplayBoundsForLayout(); } void DisplayController::SetLayoutForDisplayName(const std::string& name, const DisplayLayout& layout) { - DisplayLayout& display_for_name = secondary_layouts_[name]; - if (display_for_name.position != layout.position || - display_for_name.offset != layout.offset) { - secondary_layouts_[name] = layout; - NotifyDisplayConfigurationChanging(); - UpdateDisplayBoundsForLayout(); - } + secondary_layouts_[name] = layout; + UpdateDisplayBoundsForLayout(); } const DisplayLayout& DisplayController::GetLayoutForDisplayName( @@ -271,14 +254,12 @@ const DisplayLayout& DisplayController::GetLayoutForDisplayName( } void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { - NotifyDisplayConfigurationChanging(); root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); UpdateDisplayBoundsForLayout(); } void DisplayController::OnDisplayAdded(const gfx::Display& display) { DCHECK(!root_windows_.empty()); - NotifyDisplayConfigurationChanging(); aura::RootWindow* root = AddRootWindowForDisplay(display); Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root); UpdateDisplayBoundsForLayout(); @@ -289,19 +270,18 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) { DCHECK(root); // Primary display should never be removed by DisplayManager. DCHECK(root != GetPrimaryRootWindow()); - NotifyDisplayConfigurationChanging(); // Display for root window will be deleted when the Primary RootWindow // is deleted by the Shell. if (root != GetPrimaryRootWindow()) { root_windows_.erase(display.id()); internal::RootWindowController* controller = GetRootWindowController(root); - DCHECK(controller); - controller->MoveWindowsTo(GetPrimaryRootWindow()); - // Delete most of root window related objects, but don't delete - // root window itself yet because the stak may be using it. - controller->Shutdown(); - MessageLoop::current()->DeleteSoon(FROM_HERE, controller); + if (controller) { + controller->MoveWindowsTo(GetPrimaryRootWindow()); + delete controller; + } else { + delete root; + } } } @@ -377,8 +357,4 @@ void DisplayController::UpdateDisplayBoundsForLayout() { secondary_display->UpdateWorkAreaFromInsets(insets); } -void DisplayController::NotifyDisplayConfigurationChanging() { - FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); -} - } // namespace ash diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h index 661ce13..d6e122e 100644 --- a/ash/display/display_controller.h +++ b/ash/display/display_controller.h @@ -11,8 +11,6 @@ #include "ash/ash_export.h" #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "base/gtest_prod_util.h" -#include "base/observer_list.h" #include "ui/aura/display_observer.h" #include "ui/aura/display_manager.h" @@ -63,16 +61,6 @@ struct ASH_EXPORT DisplayLayout { // display, keeping them in sync with display configuration changes. class ASH_EXPORT DisplayController : public aura::DisplayObserver { public: - class Observer { - public: - // Invoked when the display configuration change is requested, - // but before the change is applied to aura/ash. - virtual void OnDisplayConfigurationChanging() = 0; - - protected: - virtual ~Observer() {} - }; - DisplayController(); virtual ~DisplayController(); @@ -82,10 +70,6 @@ class ASH_EXPORT DisplayController : public aura::DisplayObserver { // Initialize secondary displays. void InitSecondaryDisplays(); - // Add/Remove observers. - void AddObserver(Observer* observer); - void RemoveObserver(Observer* observer); - // Returns the root window for primary display. aura::RootWindow* GetPrimaryRootWindow(); @@ -127,8 +111,6 @@ class ASH_EXPORT DisplayController : public aura::DisplayObserver { void UpdateDisplayBoundsForLayout(); - void NotifyDisplayConfigurationChanging(); - // The mapping from display ID to its root window. std::map<int64, aura::RootWindow*> root_windows_; @@ -138,8 +120,6 @@ class ASH_EXPORT DisplayController : public aura::DisplayObserver { // Per-device display layout. std::map<std::string, DisplayLayout> secondary_layouts_; - ObserverList<Observer> observers_; - DISALLOW_COPY_AND_ASSIGN(DisplayController); }; diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc index d2be5b6..428d0de 100644 --- a/ash/display/display_controller_unittest.cc +++ b/ash/display/display_controller_unittest.cc @@ -16,32 +16,6 @@ namespace ash { namespace test { namespace { -class TestObserver : public DisplayController::Observer { - public: - TestObserver() : count_(0) { - Shell::GetInstance()->display_controller()->AddObserver(this); - } - - virtual ~TestObserver() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); - } - - virtual void OnDisplayConfigurationChanging() OVERRIDE { - ++count_; - } - - int CountAndReset() { - int c = count_; - count_ = 0; - return c; - } - - private: - int count_; - - DISALLOW_COPY_AND_ASSIGN(TestObserver); -}; - gfx::Display GetPrimaryDisplay() { return gfx::Screen::GetDisplayNearestWindow( Shell::GetAllRootWindows()[0]); @@ -75,9 +49,7 @@ typedef test::AshTestBase DisplayControllerTest; #endif TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) { - TestObserver observer; UpdateDisplay("500x500,400x400"); - EXPECT_EQ(2, observer.CountAndReset()); // resize and add gfx::Display* secondary_display = aura::Env::GetInstance()->display_manager()->GetDisplayAt(1); gfx::Insets insets(5, 5, 5, 5); @@ -90,32 +62,26 @@ TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) { // Layout the secondary display to the bottom of the primary. SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); - EXPECT_EQ(1, observer.CountAndReset()); EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("0,500 400x400", GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ("5,505 390x390", GetSecondaryDisplay().work_area().ToString()); // Layout the secondary display to the left of the primary. SetSecondaryDisplayLayout(DisplayLayout::LEFT); - EXPECT_EQ(1, observer.CountAndReset()); EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("-400,0 400x400", GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ("-395,5 390x390", GetSecondaryDisplay().work_area().ToString()); // Layout the secondary display to the top of the primary. SetSecondaryDisplayLayout(DisplayLayout::TOP); - EXPECT_EQ(1, observer.CountAndReset()); EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("0,-400 400x400", GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ("5,-395 390x390", GetSecondaryDisplay().work_area().ToString()); } TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) { - TestObserver observer; SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); - UpdateDisplay("200x200,300x300"); // layout, resize and add. - EXPECT_EQ(3, observer.CountAndReset()); - + UpdateDisplay("200x200,300x300"); gfx::Display* secondary_display = aura::Env::GetInstance()->display_manager()->GetDisplayAt(1); gfx::Insets insets(5, 5, 5, 5); @@ -126,24 +92,20 @@ TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) { EXPECT_EQ("5,205 290x290", GetSecondaryDisplay().work_area().ToString()); UpdateDisplay("400x400,200x200"); - EXPECT_EQ(2, observer.CountAndReset()); // two resizes EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("0,400 200x200", GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ("5,405 190x190", GetSecondaryDisplay().work_area().ToString()); UpdateDisplay("400x400,300x300"); - EXPECT_EQ(1, observer.CountAndReset()); EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("0,400 300x300", GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ("5,405 290x290", GetSecondaryDisplay().work_area().ToString()); UpdateDisplay("400x400"); - EXPECT_EQ(1, observer.CountAndReset()); EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ(1, gfx::Screen::GetNumDisplays()); UpdateDisplay("500x500,700x700"); - EXPECT_EQ(2, observer.CountAndReset()); ASSERT_EQ(2, gfx::Screen::GetNumDisplays()); EXPECT_EQ("0,0 500x500", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("0,500 700x700", GetSecondaryDisplay().bounds().ToString()); diff --git a/ash/display/multi_display_manager.cc b/ash/display/multi_display_manager.cc index 9c3bce3..ca6d44d 100644 --- a/ash/display/multi_display_manager.cc +++ b/ash/display/multi_display_manager.cc @@ -53,13 +53,18 @@ MultiDisplayManager::~MultiDisplayManager() { } // static +void MultiDisplayManager::AddRemoveDisplay() { + MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( + aura::Env::GetInstance()->display_manager()); + manager->AddRemoveDisplayImpl(); +} + void MultiDisplayManager::CycleDisplay() { MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( aura::Env::GetInstance()->display_manager()); manager->CycleDisplayImpl(); } -// static void MultiDisplayManager::ToggleDisplayScale() { MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( aura::Env::GetInstance()->display_manager()); @@ -218,10 +223,8 @@ void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root, const gfx::Size& old_size) { if (!use_fullscreen_host_window()) { gfx::Display& display = FindDisplayForRootWindow(root); - if (display.size() != root->GetHostSize()) { - display.SetSize(root->GetHostSize()); - NotifyBoundsChanged(display); - } + display.SetSize(root->GetHostSize()); + NotifyBoundsChanged(display); } } @@ -239,7 +242,7 @@ void MultiDisplayManager::Init() { AddDisplayFromSpec(std::string() /* default */); } -void MultiDisplayManager::CycleDisplayImpl() { +void MultiDisplayManager::AddRemoveDisplayImpl() { std::vector<gfx::Display> new_displays; if (displays_.size() > 1) { // Remove if there is more than one display. @@ -249,12 +252,25 @@ void MultiDisplayManager::CycleDisplayImpl() { } else { // Add if there is only one display. new_displays.push_back(displays_[0]); - new_displays.push_back(CreateDisplayFromSpec("100+200-500x400")); + new_displays.push_back(CreateDisplayFromSpec("50+50-1280x768")); } if (new_displays.size()) OnNativeDisplaysChanged(new_displays); } +void MultiDisplayManager::CycleDisplayImpl() { + if (displays_.size() > 1) { + std::vector<gfx::Display> new_displays; + for (Displays::const_iterator iter = displays_.begin() + 1; + iter != displays_.end(); ++iter) { + gfx::Display display = *iter; + new_displays.push_back(display); + } + new_displays.push_back(displays_.front()); + OnNativeDisplaysChanged(new_displays); + } +} + void MultiDisplayManager::ScaleDisplayImpl() { if (displays_.size() > 0) { std::vector<gfx::Display> new_displays; @@ -274,8 +290,6 @@ void MultiDisplayManager::ScaleDisplayImpl() { gfx::Display& MultiDisplayManager::FindDisplayForRootWindow( const aura::RootWindow* root_window) { int64 id = root_window->GetProperty(kDisplayIdKey); - // if id is |kInvaildDisplayID|, it's being deleted. - DCHECK(id != gfx::Display::kInvalidDisplayID); for (Displays::iterator iter = displays_.begin(); iter != displays_.end(); ++iter) { if ((*iter).id() == id) diff --git a/ash/display/multi_display_manager.h b/ash/display/multi_display_manager.h index 85f2f2b..61e1163 100644 --- a/ash/display/multi_display_manager.h +++ b/ash/display/multi_display_manager.h @@ -38,6 +38,7 @@ class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager, // Used to emulate display change when run in a desktop environment instead // of on a device. + static void AddRemoveDisplay(); static void CycleDisplay(); static void ToggleDisplayScale(); @@ -75,6 +76,7 @@ class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager, typedef std::vector<gfx::Display> Displays; void Init(); + void AddRemoveDisplayImpl(); void CycleDisplayImpl(); void ScaleDisplayImpl(); gfx::Display& FindDisplayForRootWindow(const aura::RootWindow* root); diff --git a/ash/display/multi_display_manager_unittest.cc b/ash/display/multi_display_manager_unittest.cc index 83c5cab..401c526 100644 --- a/ash/display/multi_display_manager_unittest.cc +++ b/ash/display/multi_display_manager_unittest.cc @@ -195,20 +195,29 @@ TEST_F(MultiDisplayManagerTest, MAYBE_NativeDisplayTest) { TEST_F(MultiDisplayManagerTest, MAYBE_EmulatorTest) { EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - internal::MultiDisplayManager::CycleDisplay(); + internal::MultiDisplayManager::AddRemoveDisplay(); // Update primary and add seconary. EXPECT_EQ(2U, display_manager()->GetNumDisplays()); - EXPECT_EQ("0 1 0", GetCountSummary()); + EXPECT_EQ("1 1 0", GetCountSummary()); reset(); internal::MultiDisplayManager::CycleDisplay(); + EXPECT_EQ(2U, display_manager()->GetNumDisplays()); + // Observer gets called twice in this mode because + // it gets notified both from |OnNativeDisplayChagned| + // and from |RootWindowObserver|, which is the consequence of + // |SetHostSize()|. + EXPECT_EQ("4 0 0", GetCountSummary()); + reset(); + + internal::MultiDisplayManager::AddRemoveDisplay(); EXPECT_EQ(1U, display_manager()->GetNumDisplays()); EXPECT_EQ("0 0 1", GetCountSummary()); reset(); internal::MultiDisplayManager::CycleDisplay(); - EXPECT_EQ(2U, display_manager()->GetNumDisplays()); - EXPECT_EQ("0 1 0", GetCountSummary()); + EXPECT_EQ(1U, display_manager()->GetNumDisplays()); + EXPECT_EQ("0 0 0", GetCountSummary()); reset(); } |