summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorynovikov@chromium.org <ynovikov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-19 16:24:08 +0000
committerynovikov@chromium.org <ynovikov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-19 16:24:08 +0000
commitb33657be291b673090595c3b3ef62da78d01405d (patch)
treeb5aa3e421063c77235b6c81123f6951c9b84bd13 /ash
parent0ace10fa0cb5b8852c825e743fbb7c0a77fe14f2 (diff)
downloadchromium_src-b33657be291b673090595c3b3ef62da78d01405d.zip
chromium_src-b33657be291b673090595c3b3ef62da78d01405d.tar.gz
chromium_src-b33657be291b673090595c3b3ef62da78d01405d.tar.bz2
Add IsInternal property to gfx::Display
Move knowledge whether a display is internal or not from ash::DisplayManager into gfx::Display. BUG=171310 TEST=ash_unittests, ui_unittests, unit_tests pass Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=182494 Review URL: https://chromiumcodereview.appspot.com/12217120 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/display/display_controller.cc2
-rw-r--r--ash/display/display_manager.cc21
-rw-r--r--ash/display/display_manager.h4
-rw-r--r--ash/display/event_transformation_handler.cc4
-rw-r--r--ash/system/chromeos/tray_display.cc2
-rw-r--r--ash/test/ash_test_base.cc3
6 files changed, 17 insertions, 19 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index c85aab40..5bdca9b 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -301,7 +301,7 @@ void DisplayController::InitPrimaryDisplay() {
int y = primary_candidate->bounds_in_pixel().y();
for (int i = 1; i < count; ++i) {
const gfx::Display* display = display_manager->GetDisplayAt(i);
- if (display_manager->IsInternalDisplayId(display->id())) {
+ if (display->IsInternal()) {
primary_candidate = display;
break;
} else if (display->bounds_in_pixel().y() < y) {
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 8fa1223..97d9d71 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -98,7 +98,6 @@ DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
gfx::Display::kInvalidDisplayID);
DisplayManager::DisplayManager() :
- internal_display_id_(gfx::Display::kInvalidDisplayID),
force_bounds_changed_(false) {
Init();
}
@@ -126,11 +125,11 @@ bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const {
}
bool DisplayManager::HasInternalDisplay() const {
- return internal_display_id_ != gfx::Display::kInvalidDisplayID;
+ return gfx::Display::InternalDisplayId() != gfx::Display::kInvalidDisplayID;
}
bool DisplayManager::IsInternalDisplayId(int64 id) const {
- return internal_display_id_ == id;
+ return gfx::Display::InternalDisplayId() == id;
}
bool DisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
@@ -192,11 +191,11 @@ void DisplayManager::OnNativeDisplaysChanged(
return;
}
DisplayList new_displays = updated_displays;
- if (internal_display_id_ != gfx::Display::kInvalidDisplayID) {
+ if (HasInternalDisplay()) {
bool internal_display_connected = false;
for (DisplayList::const_iterator iter = updated_displays.begin();
iter != updated_displays.end(); ++iter) {
- if ((*iter).id() == internal_display_id_) {
+ if ((*iter).IsInternal()) {
internal_display_connected = true;
// Update the internal display cache.
internal_display_.reset(new gfx::Display);
@@ -208,8 +207,9 @@ void DisplayManager::OnNativeDisplaysChanged(
if (!internal_display_connected) {
// Internal display may be reported as disconnect during startup time.
if (!internal_display_.get()) {
- internal_display_.reset(new gfx::Display(internal_display_id_,
- gfx::Rect(800, 600)));
+ internal_display_.reset(
+ new gfx::Display(gfx::Display::InternalDisplayId(),
+ gfx::Rect(800, 600)));
}
new_displays.push_back(*internal_display_.get());
}
@@ -452,7 +452,8 @@ void DisplayManager::Init() {
for (size_t i = 0; i < output_names.size(); ++i) {
if (chromeos::OutputConfigurator::IsInternalOutputName(
output_names[i])) {
- internal_display_id_ = GetDisplayIdForOutput(outputs[i], i);
+ gfx::Display::SetInternalDisplayId(
+ GetDisplayIdForOutput(outputs[i], i));
break;
}
}
@@ -537,10 +538,10 @@ void DisplayManager::AddDisplayFromSpec(const std::string& spec) {
}
int64 DisplayManager::SetFirstDisplayAsInternalDisplayForTest() {
- internal_display_id_ = displays_[0].id();
+ gfx::Display::SetInternalDisplayId(displays_[0].id());
internal_display_.reset(new gfx::Display);
*internal_display_ = displays_[0];
- return internal_display_id_;
+ return gfx::Display::InternalDisplayId();
}
void DisplayManager::EnsurePointerInDisplays() {
diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h
index bbc2280..25be7c1 100644
--- a/ash/display/display_manager.h
+++ b/ash/display/display_manager.h
@@ -59,8 +59,6 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
bool IsInternalDisplayId(int64 id) const;
- uint64 internal_display_id() const { return internal_display_id_; }
-
bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window,
const gfx::Insets& insets);
@@ -188,8 +186,6 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
DisplayList displays_;
- int64 internal_display_id_;
-
// An internal display cache used when the internal display is disconnectd.
scoped_ptr<gfx::Display> internal_display_;
diff --git a/ash/display/event_transformation_handler.cc b/ash/display/event_transformation_handler.cc
index 380399d..7ecc634 100644
--- a/ash/display/event_transformation_handler.cc
+++ b/ash/display/event_transformation_handler.cc
@@ -4,7 +4,6 @@
#include "ash/display/event_transformation_handler.h"
-#include "ash/display/display_manager.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
@@ -45,8 +44,7 @@ void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) {
wm::ConvertPointToScreen(target, &point_in_screen);
const gfx::Display& display =
Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen);
- DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- if (!display_manager->IsInternalDisplayId(display.id()))
+ if (!display.IsInternal())
scale *= kBoostForNonIntegrated;
event->Scale(scale);
diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc
index 4bf1fb7..19ca0fc 100644
--- a/ash/system/chromeos/tray_display.cc
+++ b/ash/system/chromeos/tray_display.cc
@@ -86,7 +86,7 @@ class DisplayView : public ash::internal::ActionableView {
string16 GetExternalDisplayName() {
#if defined(USE_X11)
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- int64 internal_display_id = display_manager->internal_display_id();
+ int64 internal_display_id = gfx::Display::InternalDisplayId();
int64 primary_display_id =
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id();
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc
index 4cfdac7..0116710 100644
--- a/ash/test/ash_test_base.cc
+++ b/ash/test/ash_test_base.cc
@@ -137,6 +137,9 @@ void AshTestBase::TearDown() {
metro_viewer_host_.reset();
#endif
event_generator_.reset();
+ // Some tests set an internal display id,
+ // reset it here, so other tests will continue in a clean environment.
+ gfx::Display::SetInternalDisplayId(gfx::Display::kInvalidDisplayID);
}
aura::test::EventGenerator& AshTestBase::GetEventGenerator() {