Index: ash/mus/user_window_controller_impl.cc |
diff --git a/mash/wm/user_window_controller_impl.cc b/ash/mus/user_window_controller_impl.cc |
similarity index 75% |
rename from mash/wm/user_window_controller_impl.cc |
rename to ash/mus/user_window_controller_impl.cc |
index 884b55209f551616a19d8b542117013b93a3f5d2..50389a22f92584a438c508f044b96f94542e9ac9 100644 |
--- a/mash/wm/user_window_controller_impl.cc |
+++ b/ash/mus/user_window_controller_impl.cc |
@@ -2,45 +2,50 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "mash/wm/user_window_controller_impl.h" |
+#include "ash/mus/user_window_controller_impl.h" |
+#include "ash/mus/property_util.h" |
+#include "ash/mus/root_window_controller.h" |
#include "ash/public/interfaces/container.mojom.h" |
#include "components/mus/public/cpp/property_type_converters.h" |
#include "components/mus/public/cpp/window.h" |
#include "components/mus/public/cpp/window_property.h" |
#include "components/mus/public/cpp/window_tree_client.h" |
-#include "mash/wm/property_util.h" |
-#include "mash/wm/root_window_controller.h" |
#include "mojo/common/common_type_converters.h" |
#include "ui/resources/grit/ui_resources.h" |
-MUS_DECLARE_WINDOW_PROPERTY_TYPE(uint32_t); |
+MUS_DECLARE_WINDOW_PROPERTY_TYPE(uint32_t) |
-namespace mash { |
-namespace wm { |
+namespace { |
// Key used for storing identifier sent to clients for windows. |
MUS_DEFINE_LOCAL_WINDOW_PROPERTY_KEY(uint32_t, kUserWindowIdKey, 0u); |
+} // namespace |
+ |
+namespace ash { |
+namespace mus { |
+ |
namespace { |
// Returns |window|, or an ancestor thereof, parented to |container|, or null. |
-mus::Window* GetTopLevelWindow(mus::Window* window, mus::Window* container) { |
+::mus::Window* GetTopLevelWindow(::mus::Window* window, |
+ ::mus::Window* container) { |
while (window && window->parent() != container) |
window = window->parent(); |
return window; |
} |
// Get a UserWindow struct from a mus::Window. |
-ash::mojom::UserWindowPtr GetUserWindow(mus::Window* window) { |
- ash::mojom::UserWindowPtr user_window(ash::mojom::UserWindow::New()); |
+mojom::UserWindowPtr GetUserWindow(::mus::Window* window) { |
+ mojom::UserWindowPtr user_window(mojom::UserWindow::New()); |
DCHECK_NE(0u, window->GetLocalProperty(kUserWindowIdKey)); |
user_window->window_id = window->GetLocalProperty(kUserWindowIdKey); |
user_window->window_title = mojo::String::From(GetWindowTitle(window)); |
user_window->window_app_icon = GetWindowAppIcon(window); |
user_window->window_app_id = mojo::String::From(GetAppID(window)); |
user_window->ignored_by_shelf = GetWindowIgnoredByShelf(window); |
- mus::Window* focused = window->window_tree()->GetFocusedWindow(); |
+ ::mus::Window* focused = window->window_tree()->GetFocusedWindow(); |
focused = GetTopLevelWindow(focused, window->parent()); |
user_window->window_has_focus = focused == window; |
return user_window; |
@@ -51,7 +56,7 @@ ash::mojom::UserWindowPtr GetUserWindow(mus::Window* window) { |
// Observes property changes on user windows. UserWindowControllerImpl uses |
// this separate observer to avoid observing duplicate tree change |
// notifications. |
-class WindowPropertyObserver : public mus::WindowObserver { |
+class WindowPropertyObserver : public ::mus::WindowObserver { |
public: |
explicit WindowPropertyObserver(UserWindowControllerImpl* controller) |
: controller_(controller) {} |
@@ -60,17 +65,17 @@ class WindowPropertyObserver : public mus::WindowObserver { |
private: |
// mus::WindowObserver: |
void OnWindowSharedPropertyChanged( |
- mus::Window* window, |
+ ::mus::Window* window, |
const std::string& name, |
const std::vector<uint8_t>* old_data, |
const std::vector<uint8_t>* new_data) override { |
if (!controller_->user_window_observer()) |
return; |
- if (name == mus::mojom::WindowManager::kWindowTitle_Property) { |
+ if (name == ::mus::mojom::WindowManager::kWindowTitle_Property) { |
controller_->user_window_observer()->OnUserWindowTitleChanged( |
window->GetLocalProperty(kUserWindowIdKey), |
mojo::String::From(GetWindowTitle(window))); |
- } else if (name == mus::mojom::WindowManager::kWindowAppIcon_Property) { |
+ } else if (name == ::mus::mojom::WindowManager::kWindowAppIcon_Property) { |
controller_->user_window_observer()->OnUserWindowAppIconChanged( |
window->GetLocalProperty(kUserWindowIdKey), |
new_data ? mojo::Array<uint8_t>::From(*new_data) |
@@ -89,7 +94,7 @@ UserWindowControllerImpl::~UserWindowControllerImpl() { |
if (!root_controller_) |
return; |
- mus::Window* user_container = GetUserWindowContainer(); |
+ ::mus::Window* user_container = GetUserWindowContainer(); |
if (!user_container) |
return; |
@@ -104,35 +109,35 @@ void UserWindowControllerImpl::Initialize( |
GetUserWindowContainer()->AddObserver(this); |
GetUserWindowContainer()->window_tree()->AddObserver(this); |
window_property_observer_.reset(new WindowPropertyObserver(this)); |
- for (mus::Window* window : GetUserWindowContainer()->children()) { |
+ for (::mus::Window* window : GetUserWindowContainer()->children()) { |
AssignIdIfNecessary(window); |
window->AddObserver(window_property_observer_.get()); |
} |
} |
-void UserWindowControllerImpl::AssignIdIfNecessary(mus::Window* window) { |
+void UserWindowControllerImpl::AssignIdIfNecessary(::mus::Window* window) { |
if (window->GetLocalProperty(kUserWindowIdKey) == 0u) |
window->SetLocalProperty(kUserWindowIdKey, next_id_++); |
} |
-void UserWindowControllerImpl::RemoveObservers(mus::Window* user_container) { |
+void UserWindowControllerImpl::RemoveObservers(::mus::Window* user_container) { |
user_container->RemoveObserver(this); |
user_container->window_tree()->RemoveObserver(this); |
for (auto iter : user_container->children()) |
iter->RemoveObserver(window_property_observer_.get()); |
} |
-mus::Window* UserWindowControllerImpl::GetUserWindowById(uint32_t id) { |
- for (mus::Window* window : GetUserWindowContainer()->children()) { |
+::mus::Window* UserWindowControllerImpl::GetUserWindowById(uint32_t id) { |
+ for (::mus::Window* window : GetUserWindowContainer()->children()) { |
if (window->GetLocalProperty(kUserWindowIdKey) == id) |
return window; |
} |
return nullptr; |
} |
-mus::Window* UserWindowControllerImpl::GetUserWindowContainer() const { |
+::mus::Window* UserWindowControllerImpl::GetUserWindowContainer() const { |
return root_controller_->GetWindowForContainer( |
- ash::mojom::Container::USER_PRIVATE_WINDOWS); |
+ mojom::Container::USER_PRIVATE_WINDOWS); |
} |
void UserWindowControllerImpl::OnTreeChanging(const TreeChangeParams& params) { |
@@ -150,14 +155,14 @@ void UserWindowControllerImpl::OnTreeChanging(const TreeChangeParams& params) { |
} |
} |
-void UserWindowControllerImpl::OnWindowDestroying(mus::Window* window) { |
+void UserWindowControllerImpl::OnWindowDestroying(::mus::Window* window) { |
if (window == GetUserWindowContainer()) |
RemoveObservers(window); |
} |
void UserWindowControllerImpl::OnWindowTreeFocusChanged( |
- mus::Window* gained_focus, |
- mus::Window* lost_focus) { |
+ ::mus::Window* gained_focus, |
+ ::mus::Window* lost_focus) { |
if (!user_window_observer_) |
return; |
@@ -178,23 +183,23 @@ void UserWindowControllerImpl::OnWindowTreeFocusChanged( |
} |
void UserWindowControllerImpl::AddUserWindowObserver( |
- ash::mojom::UserWindowObserverPtr observer) { |
+ mojom::UserWindowObserverPtr observer) { |
// TODO(msw): Support multiple observers. |
user_window_observer_ = std::move(observer); |
- const mus::Window::Children& windows = GetUserWindowContainer()->children(); |
- mojo::Array<ash::mojom::UserWindowPtr> user_windows = |
- mojo::Array<ash::mojom::UserWindowPtr>::New(windows.size()); |
+ const ::mus::Window::Children& windows = GetUserWindowContainer()->children(); |
+ mojo::Array<mojom::UserWindowPtr> user_windows = |
+ mojo::Array<mojom::UserWindowPtr>::New(windows.size()); |
for (size_t i = 0; i < windows.size(); ++i) |
user_windows[i] = GetUserWindow(windows[i]); |
user_window_observer_->OnUserWindowObserverAdded(std::move(user_windows)); |
} |
void UserWindowControllerImpl::FocusUserWindow(uint32_t window_id) { |
- mus::Window* window = GetUserWindowById(window_id); |
+ ::mus::Window* window = GetUserWindowById(window_id); |
if (window) |
window->SetFocus(); |
} |
-} // namespace wm |
-} // namespace mash |
+} // namespace mus |
+} // namespace ash |