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

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..2aa2fc692c0133d44c7ae02998692b4175d7aaaa 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(
@@ -181,12 +180,11 @@ aura::Window* GetWindow(AshWindowTreeHost* ash_host) {
class FocusActivationStore {
public:
FocusActivationStore()
- : activation_client_(NULL),
- capture_client_(NULL),
- focus_client_(NULL),
- focused_(NULL),
- active_(NULL) {
- }
+ : activation_client_(nullptr),
+ capture_client_(nullptr),
+ focus_client_(nullptr),
+ focused_(nullptr),
+ active_(nullptr) {}
void Store(bool clear_focus) {
if (!activation_client_) {
@@ -207,13 +205,13 @@ class FocusActivationStore {
activation_client_->DeactivateWindow(active_);
// Release capture if any.
- capture_client_->SetCapture(NULL);
+ capture_client_->SetCapture(nullptr);
// Clear the focused window if any. This is necessary because a
// window may be deleted when losing focus (fullscreen flash for
// example). If the focused window is still alive after move, it'll
// be re-focused below.
if (clear_focus)
- focus_client_->FocusWindow(NULL);
+ focus_client_->FocusWindow(nullptr);
}
void Restore() {
@@ -227,8 +225,8 @@ class FocusActivationStore {
tracker_.Remove(focused_);
if (active_)
tracker_.Remove(active_);
- focused_ = NULL;
- active_ = NULL;
+ focused_ = nullptr;
+ active_ = nullptr;
}
private:
@@ -263,7 +261,7 @@ bool DisplayController::DisplayChangeLimiter::IsThrottled() const {
// DisplayController
DisplayController::DisplayController()
- : primary_tree_host_for_replace_(NULL),
+ : primary_tree_host_for_replace_(nullptr),
focus_activation_store_(new FocusActivationStore()),
cursor_window_controller_(new CursorWindowController()),
mirror_window_controller_(new MirrorWindowController()),
@@ -289,7 +287,7 @@ void DisplayController::Start() {
void DisplayController::Shutdown() {
// Unset the display manager's delegate here because
// DisplayManager outlives DisplayController.
- Shell::GetInstance()->display_manager()->set_delegate(NULL);
+ Shell::GetInstance()->display_manager()->set_delegate(nullptr);
cursor_window_controller_.reset();
mirror_window_controller_.reset();
@@ -302,7 +300,7 @@ void DisplayController::Shutdown() {
// delete the primary root window controller.
aura::Window::Windows root_windows = DisplayController::GetAllRootWindows();
std::vector<RootWindowController*> to_delete;
- RootWindowController* primary_rwc = NULL;
+ RootWindowController* primary_rwc = nullptr;
for (aura::Window::Windows::iterator iter = root_windows.begin();
iter != root_windows.end();
++iter) {
@@ -330,7 +328,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 +360,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();
@@ -546,7 +548,7 @@ void DisplayController::UpdateMouseLocationAfterDisplayChange() {
int64 closest_distance_squared = -1;
DisplayManager* display_manager = GetDisplayManager();
- aura::Window* dst_root_window = NULL;
+ aura::Window* dst_root_window = nullptr;
for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
const gfx::Display& display = display_manager->GetDisplayAt(i);
const DisplayInfo display_info =
@@ -629,13 +631,30 @@ bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
}
void DisplayController::OnDisplayAdded(const gfx::Display& display) {
- if (primary_tree_host_for_replace_) {
+ if (GetDisplayManager()->IsInUnifiedMode()) {
+ if (primary_display_id == gfx::Display::kInvalidDisplayID)
+ primary_display_id = display.id();
+ 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_ = nullptr;
+ DeleteHost(to_delete);
+ // the host has already been removed from the window_tree_host_.
+ }
+ }
+ // TODO(oshima): It should be possible to consolidate logic for
+ // unified and non unified, but I'm keeping them separated to minimize
+ // the risk in M44. I'll consolidate this in M45.
+ else 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;
+ primary_tree_host_for_replace_ = nullptr;
const DisplayInfo& display_info =
GetDisplayManager()->GetDisplayInfo(display.id());
AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()];
@@ -645,12 +664,24 @@ void DisplayController::OnDisplayAdded(const gfx::Display& display) {
if (primary_display_id == gfx::Display::kInvalidDisplayID)
primary_display_id = display.id();
DCHECK(!window_tree_hosts_.empty());
- AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay(
- display, AshWindowTreeHostInitParams());
+ 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