summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 19:44:43 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 19:44:43 +0000
commitdf3b1348283bf2f58d6598d05035a111cdde82eb (patch)
treeb383705613e1ab8c3d16a1cae23a858966db3b08
parentfa202fd676d44a25fd67bc7ff2ad618633f92715 (diff)
downloadchromium_src-df3b1348283bf2f58d6598d05035a111cdde82eb.zip
chromium_src-df3b1348283bf2f58d6598d05035a111cdde82eb.tar.gz
chromium_src-df3b1348283bf2f58d6598d05035a111cdde82eb.tar.bz2
Another fix of display overscan settings.
The existing code directly edits |displays_| and sends it to OnNativeDisplaysChanged(), but this is wrong in case the new Insets is empty(). In that case no display bounds change events are signaled. Rather it would be better to copy the list of displays. BUG=None TEST=ash_unittests passed with the new test case. Review URL: https://chromiumcodereview.appspot.com/11191050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162764 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/display/multi_display_manager.cc18
-rw-r--r--ash/display/multi_display_manager_unittest.cc23
2 files changed, 34 insertions, 7 deletions
diff --git a/ash/display/multi_display_manager.cc b/ash/display/multi_display_manager.cc
index e09abd8..e7fbf5e 100644
--- a/ash/display/multi_display_manager.cc
+++ b/ash/display/multi_display_manager.cc
@@ -142,20 +142,24 @@ const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint(
void MultiDisplayManager::SetOverscanInsets(int64 display_id,
const gfx::Insets& insets_in_dip) {
+ DisplayList displays = displays_;
std::map<int64, gfx::Insets>::const_iterator old_overscan =
overscan_mapping_.find(display_id);
if (old_overscan != overscan_mapping_.end()) {
gfx::Insets old_insets = old_overscan->second;
- gfx::Display& display = FindDisplayForId(display_id);
- if (display.is_valid()) {
- // Undo the existing insets before applying the new insets.
- gfx::Rect bounds = display.bounds_in_pixel();
- bounds.Inset(old_insets.Scale(-display.device_scale_factor()));
- display.SetScaleAndBounds(display.device_scale_factor(), bounds);
+ for (DisplayList::iterator iter = displays.begin();
+ iter != displays.end(); ++iter) {
+ if (iter->id() == display_id) {
+ // Undo the existing insets before applying the new insets.
+ gfx::Rect bounds = iter->bounds_in_pixel();
+ bounds.Inset(old_insets.Scale(-iter->device_scale_factor()));
+ iter->SetScaleAndBounds(iter->device_scale_factor(), bounds);
+ break;
+ }
}
}
overscan_mapping_[display_id] = insets_in_dip;
- OnNativeDisplaysChanged(displays_);
+ OnNativeDisplaysChanged(displays);
}
void MultiDisplayManager::OnNativeDisplaysChanged(
diff --git a/ash/display/multi_display_manager_unittest.cc b/ash/display/multi_display_manager_unittest.cc
index 19b4206..b7e293a 100644
--- a/ash/display/multi_display_manager_unittest.cc
+++ b/ash/display/multi_display_manager_unittest.cc
@@ -101,10 +101,12 @@ class MultiDisplayManagerTest : public test::AshTestBase,
#define MAYBE_NativeDisplayTest NativeDisplayTest
#define MAYBE_EmulatorTest EmulatorTest
#define MAYBE_OverscanInsetsTest OverscanInsetsTest
+#define MAYBE_ZeroOverscanInsets ZeroOverscanInsets
#else
#define MAYBE_NativeDisplayTest DISABLED_NativeDisplayTest
#define MAYBE_EmulatorTest DISABLED_EmulatorTest
#define MAYBE_OverscanInsetsTest DISABLED_OverscanInsetsTest
+#define MAYBE_ZeroOverscanInsets DISABLED_ZeroOverscanInsets
#endif
TEST_F(MultiDisplayManagerTest, MAYBE_NativeDisplayTest) {
@@ -276,6 +278,27 @@ TEST_F(MultiDisplayManagerTest, MAYBE_OverscanInsetsTest) {
EXPECT_EQ("188x190", display_manager()->GetDisplayAt(1)->size().ToString());
}
+TEST_F(MultiDisplayManagerTest, MAYBE_ZeroOverscanInsets) {
+ // Make sure the display change events is emitted for overscan inset changes.
+ UpdateDisplay("0+0-500x500,0+501-400x400");
+ ASSERT_EQ(2u, display_manager()->GetNumDisplays());
+ int64 display2_id = display_manager()->GetDisplayAt(1)->id();
+
+ reset();
+ display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
+ EXPECT_EQ(0u, changed().size());
+
+ reset();
+ display_manager()->SetOverscanInsets(display2_id, gfx::Insets(1, 0, 0, 0));
+ EXPECT_EQ(1u, changed().size());
+ EXPECT_EQ(display2_id, changed()[0].id());
+
+ reset();
+ display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
+ EXPECT_EQ(1u, changed().size());
+ EXPECT_EQ(display2_id, changed()[0].id());
+}
+
// TODO(oshima): Device scale factor is supported on chromeos only for now.
#if defined(OS_CHROMEOS)
#define MAYBE_TestDeviceScaleOnlyChange TestDeviceScaleOnlyChange