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

Unified Diff: ash/display/display_controller.cc

Issue 1107733006: Unified Desktop: hook up ash to allow unified desktop mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/display/display_controller.cc
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 304b9270eca9de43fcde4cd0620c9eb655e396fb..01b361c7505e2518847f6245ab31fef770cfaff3 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -160,8 +160,7 @@ void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host,
host->compositor()->ScheduleFullRedraw();
}
-void ClearDisplayPropertiesOnHost(AshWindowTreeHost* ash_host,
- const gfx::Display& display) {
+void ClearDisplayPropertiesOnHost(AshWindowTreeHost* ash_host) {
#if defined(OS_CHROMEOS) && defined(USE_OZONE)
aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
ui::CursorController::GetInstance()->ClearCursorConfigForWindow(
@@ -330,7 +329,6 @@ void DisplayController::CreatePrimaryHost(
void DisplayController::InitDisplays() {
RootWindowController::CreateForPrimaryDisplay(
window_tree_hosts_[primary_display_id]);
-
DisplayManager* display_manager = GetDisplayManager();
for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
const gfx::Display& display = display_manager->GetDisplayAt(i);
@@ -363,12 +361,17 @@ aura::Window* DisplayController::GetPrimaryRootWindow() {
}
aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) {
- CHECK_EQ(1u, window_tree_hosts_.count(id));
- AshWindowTreeHost* host = window_tree_hosts_[id];
+ AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id);
CHECK(host);
return GetWindow(host);
}
+AshWindowTreeHost* DisplayController::GetAshWindowTreeHostForDisplayId(
+ int64 id) {
+ CHECK_EQ(1u, window_tree_hosts_.count(id));
+ return window_tree_hosts_[id];
+}
+
void DisplayController::CloseChildWindows() {
for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin();
it != window_tree_hosts_.end();
@@ -629,28 +632,56 @@ bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
}
void DisplayController::OnDisplayAdded(const gfx::Display& display) {
- if (primary_tree_host_for_replace_) {
- DCHECK(window_tree_hosts_.empty());
- primary_display_id = display.id();
- window_tree_hosts_[display.id()] = primary_tree_host_for_replace_;
- GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_))
- ->display_id = display.id();
- primary_tree_host_for_replace_ = NULL;
- const DisplayInfo& display_info =
- GetDisplayManager()->GetDisplayInfo(display.id());
- AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
- ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
- SetDisplayPropertiesOnHost(ash_host, display);
- } else {
+ // TODO(oshima): Consolidate these logic.
+ if (GetDisplayManager()->IsInUnifiedMode()) {
if (primary_display_id == gfx::Display::kInvalidDisplayID)
primary_display_id = display.id();
- DCHECK(!window_tree_hosts_.empty());
AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay(
display, AshWindowTreeHostInitParams());
RootWindowController::CreateForSecondaryDisplay(ash_host);
+
+ if (primary_tree_host_for_replace_) {
+ AshWindowTreeHost* to_delete = primary_tree_host_for_replace_;
+ primary_tree_host_for_replace_ = NULL;
Jun Mukai 2015/04/26 23:45:07 nullptr
oshima 2015/04/27 17:48:38 Done.
+ DeleteHost(to_delete);
+ // the host has already been removed from the window_tree_host_.
+ }
+ } else {
+ if (primary_tree_host_for_replace_) {
Jun Mukai 2015/04/26 23:45:07 why not else if?
oshima 2015/04/27 17:48:38 Done.
+ DCHECK(window_tree_hosts_.empty());
+ primary_display_id = display.id();
+ window_tree_hosts_[display.id()] = primary_tree_host_for_replace_;
+ GetRootWindowSettings(GetWindow(primary_tree_host_for_replace_))
+ ->display_id = display.id();
+ primary_tree_host_for_replace_ = NULL;
Jun Mukai 2015/04/26 23:45:07 nullptr
oshima 2015/04/27 17:48:38 Done.
+ const DisplayInfo& display_info =
+ GetDisplayManager()->GetDisplayInfo(display.id());
+ AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
+ ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native());
+ SetDisplayPropertiesOnHost(ash_host, display);
+ } else {
+ if (primary_display_id == gfx::Display::kInvalidDisplayID)
+ primary_display_id = display.id();
+ DCHECK(!window_tree_hosts_.empty());
+ AshWindowTreeHost* ash_host =
+ AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams());
+ RootWindowController::CreateForSecondaryDisplay(ash_host);
+ }
}
}
+void DisplayController::DeleteHost(AshWindowTreeHost* host_to_delete) {
+ ClearDisplayPropertiesOnHost(host_to_delete);
+ RootWindowController* controller =
+ GetRootWindowController(GetWindow(host_to_delete));
+ DCHECK(controller);
+ controller->MoveWindowsTo(GetPrimaryRootWindow());
+ // Delete most of root window related objects, but don't delete
+ // root window itself yet because the stack may be using it.
+ controller->Shutdown();
+ base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller);
+}
+
void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()];
CHECK(host_to_delete) << display.ToString();
@@ -690,15 +721,8 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
GetDisplayManager()->GetDisplayForId(primary_display_id),
DISPLAY_METRIC_BOUNDS);
}
- ClearDisplayPropertiesOnHost(host_to_delete, display);
- RootWindowController* controller =
- GetRootWindowController(GetWindow(host_to_delete));
- DCHECK(controller);
- controller->MoveWindowsTo(GetPrimaryRootWindow());
- // Delete most of root window related objects, but don't delete
- // root window itself yet because the stack may be using it.
- controller->Shutdown();
- base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller);
+
+ DeleteHost(host_to_delete);
// The window tree host should be erased at last because some handlers can
// access to the host through GetRootWindowForDisplayId() during
@@ -731,10 +755,11 @@ void DisplayController::OnHostResized(const aura::WindowTreeHost* host) {
}
void DisplayController::CreateOrUpdateMirroringDisplay(
- const DisplayInfo& info) {
- switch (GetDisplayManager()->second_display_mode()) {
+ const DisplayInfoList& info_list) {
+ switch (GetDisplayManager()->multi_display_mode()) {
case DisplayManager::MIRRORING:
- mirror_window_controller_->UpdateWindow(info);
+ case DisplayManager::UNIFIED:
+ mirror_window_controller_->UpdateWindow(info_list);
cursor_window_controller_->UpdateContainer();
break;
case DisplayManager::EXTENDED:
@@ -780,9 +805,9 @@ void DisplayController::PostDisplayConfigurationChange() {
if (display_manager->num_connected_displays() > 1) {
DisplayIdPair pair = display_manager->GetCurrentDisplayIdPair();
layout_store->UpdateMirrorStatus(pair, display_manager->IsInMirrorMode());
- DisplayLayout layout = layout_store->GetRegisteredDisplayLayout(pair);
if (Shell::GetScreen()->GetNumDisplays() > 1 ) {
+ DisplayLayout layout = layout_store->GetRegisteredDisplayLayout(pair);
int64 primary_id = layout.primary_id;
SetPrimaryDisplayId(
primary_id == gfx::Display::kInvalidDisplayID ?
@@ -807,10 +832,14 @@ AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay(
GetDisplayManager()->GetDisplayInfo(display.id());
AshWindowTreeHostInitParams params_with_bounds(init_params);
params_with_bounds.initial_bounds = display_info.bounds_in_native();
+ params_with_bounds.offscreen =
+ display.id() == DisplayManager::kUnifiedDisplayId;
AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds);
aura::WindowTreeHost* host = ash_host->AsWindowTreeHost();
- host->window()->SetName(base::StringPrintf("RootWindow-%d", host_count++));
+ host->window()->SetName(base::StringPrintf(
+ "%sRootWindow-%d", params_with_bounds.offscreen ? "Offscreen" : "",
+ host_count++));
host->window()->SetTitle(base::UTF8ToUTF16(display_info.name()));
host->compositor()->SetBackgroundColor(SK_ColorBLACK);
// No need to remove our observer observer because the DisplayController
@@ -823,10 +852,7 @@ AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay(
SetDisplayPropertiesOnHost(ash_host, display);
#if defined(OS_CHROMEOS)
- static bool force_constrain_pointer_to_root =
- base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshConstrainPointerToRoot);
- if (base::SysInfo::IsRunningOnChromeOS() || force_constrain_pointer_to_root)
+ if (switches::ConstrainPointerToRoot())
ash_host->ConfineCursorToRootWindow();
#endif
return ash_host;

Powered by Google App Engine
This is Rietveld 408576698