Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: ash/monitor/monitor_controller.cc

Issue 10696002: ASH: Use virtual screen coordinates in Display::bounds() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/monitor/monitor_controller.cc
diff --git a/ash/monitor/monitor_controller.cc b/ash/monitor/monitor_controller.cc
index 0e6288036efb56f0b88b3698b1f4b3ae53da7365..b97c9b22fd04ed1679d2d00b1e6b88284c988fe1 100644
--- a/ash/monitor/monitor_controller.cc
+++ b/ash/monitor/monitor_controller.cc
@@ -51,18 +51,18 @@ MonitorController::~MonitorController() {
void MonitorController::InitPrimaryDisplay() {
aura::MonitorManager* monitor_manager =
aura::Env::GetInstance()->monitor_manager();
- const gfx::Display& display = monitor_manager->GetDisplayAt(0);
- DCHECK_EQ(0, display.id());
- aura::RootWindow* root = AddRootWindowForDisplay(display);
- root->SetHostBounds(display.bounds_in_pixel());
+ const gfx::Display* display = monitor_manager->GetDisplayAt(0);
+ DCHECK_EQ(0, display->id());
+ aura::RootWindow* root = AddRootWindowForDisplay(*display);
+ root->SetHostBounds(display->bounds_in_pixel());
}
void MonitorController::InitSecondaryDisplays() {
aura::MonitorManager* monitor_manager =
aura::Env::GetInstance()->monitor_manager();
for (size_t i = 1; i < monitor_manager->GetNumDisplays(); ++i) {
- const gfx::Display& display = monitor_manager->GetDisplayAt(i);
- aura::RootWindow* root = AddRootWindowForDisplay(display);
+ const gfx::Display* display = monitor_manager->GetDisplayAt(i);
+ aura::RootWindow* root = AddRootWindowForDisplay(*display);
Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root);
}
}
@@ -116,6 +116,7 @@ MonitorController::GetAllRootWindowControllers() {
void MonitorController::SetSecondaryDisplayLayout(
SecondaryDisplayLayout layout) {
secondary_display_layout_ = layout;
+ UpdateDisplayBoundsForLayout();
}
bool MonitorController::WarpMouseCursorIfNecessary(
@@ -191,6 +192,7 @@ bool MonitorController::WarpMouseCursorIfNecessary(
void MonitorController::OnDisplayBoundsChanged(const gfx::Display& display) {
root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel());
+ UpdateDisplayBoundsForLayout();
}
void MonitorController::OnDisplayAdded(const gfx::Display& display) {
@@ -202,6 +204,7 @@ void MonitorController::OnDisplayAdded(const gfx::Display& display) {
}
aura::RootWindow* root = AddRootWindowForDisplay(display);
Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root);
+ UpdateDisplayBoundsForLayout();
}
void MonitorController::OnDisplayRemoved(const gfx::Display& display) {
@@ -236,9 +239,10 @@ void MonitorController::SetExtendedDesktopEnabled(bool enabled) {
// static
bool MonitorController::IsVirtualScreenCoordinatesEnabled() {
- return virtual_screen_coordinates_enabled ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshVirtualScreenCoordinates);
+ return IsExtendedDesktopEnabled() &&
+ (virtual_screen_coordinates_enabled ||
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshVirtualScreenCoordinates));
}
// static
@@ -263,5 +267,39 @@ aura::RootWindow* MonitorController::AddRootWindowForDisplay(
return root;
}
+void MonitorController::UpdateDisplayBoundsForLayout() {
+ if (!IsVirtualScreenCoordinatesEnabled() ||
+ gfx::Screen::GetNumDisplays() <= 1) {
+ return;
+ }
+ DCHECK_EQ(2, gfx::Screen::GetNumDisplays());
+ aura::MonitorManager* monitor_manager =
+ aura::Env::GetInstance()->monitor_manager();
+ const gfx::Rect& primary_bounds = monitor_manager->GetDisplayAt(0)->bounds();
+ gfx::Display* secondary_display = monitor_manager->GetDisplayAt(1);
+ const gfx::Rect& secondary_bounds = secondary_display->bounds();
+ gfx::Point new_secondary_origin = primary_bounds.origin();
+
+ // TODO(oshima|mukai): Implement more flexible layout.
+ switch (secondary_display_layout_) {
+ case TOP:
+ new_secondary_origin.Offset(0, -secondary_bounds.height());
+ break;
+ case RIGHT:
+ new_secondary_origin.Offset(primary_bounds.width(), 0);
+ break;
+ case BOTTOM:
+ new_secondary_origin.Offset(0, primary_bounds.height());
+ break;
+ case LEFT:
+ new_secondary_origin.Offset(-secondary_bounds.width(), 0);
+ break;
+ }
+ gfx::Insets insets = secondary_display->GetWorkAreaInsets();
+ secondary_display->set_bounds(
+ gfx::Rect(new_secondary_origin, secondary_bounds.size()));
+ secondary_display->UpdateWorkAreaFromInsets(insets);
+}
+
} // namespace internal
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698