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

Unified Diff: ash/common/wm/maximize_mode/maximize_mode_window_manager.cc

Issue 2699033002: Replace WmWindowObserver with aura::WindowObserver. (Closed)
Patch Set: Check for null images in ShelfWindowWatcher. Created 3 years, 10 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/common/wm/maximize_mode/maximize_mode_window_manager.cc
diff --git a/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc b/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc
index 03dee3ec67e1cb9a084a296ee005c8a73cbf86aa..cea2689b228de4ab96d748f49721ea572491b894 100644
--- a/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc
+++ b/ash/common/wm/maximize_mode/maximize_mode_window_manager.cc
@@ -19,9 +19,12 @@
#include "ash/common/wm_window_property.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h"
+#include "ash/shell.h"
+#include "ash/wm/window_state_aura.h"
#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/display/screen.h"
namespace ash {
@@ -43,7 +46,7 @@ MaximizeModeWindowManager::~MaximizeModeWindowManager() {
// transforming windows which are currently in
// overview: http://crbug.com/366605
CancelOverview();
- for (auto* window : added_windows_)
+ for (aura::Window* window : added_windows_)
window->RemoveObserver(this);
added_windows_.clear();
WmShell::Get()->RemoveShellObserver(this);
@@ -62,7 +65,7 @@ void MaximizeModeWindowManager::AddWindow(WmWindow* window) {
// and not yet tracked.
if (!ShouldHandleWindow(window) ||
base::ContainsKey(window_state_map_, window) ||
- !IsContainerWindow(window->GetParent())) {
+ !IsContainerWindow(window->GetParent()->aura_window())) {
return;
}
@@ -72,7 +75,7 @@ void MaximizeModeWindowManager::AddWindow(WmWindow* window) {
void MaximizeModeWindowManager::WindowStateDestroyed(WmWindow* window) {
// At this time ForgetWindow() should already have been called. If not,
// someone else must have replaced the "window manager's state object".
- DCHECK(!window->HasObserver(this));
+ DCHECK(!window->aura_window()->HasObserver(this));
auto it = window_state_map_.find(window);
DCHECK(it != window_state_map_.end());
@@ -97,7 +100,7 @@ void MaximizeModeWindowManager::OnOverviewModeEnded() {
SetDeferBoundsUpdates(false);
}
-void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) {
+void MaximizeModeWindowManager::OnWindowDestroying(aura::Window* window) {
if (IsContainerWindow(window)) {
// container window can be removed on display destruction.
window->RemoveObserver(this);
@@ -109,16 +112,15 @@ void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) {
} else {
// If a known window gets destroyed we need to remove all knowledge about
// it.
- ForgetWindow(window);
+ ForgetWindow(WmWindow::Get(window));
}
}
-void MaximizeModeWindowManager::OnWindowTreeChanged(
- WmWindow* window,
- const TreeChangeParams& params) {
+void MaximizeModeWindowManager::OnWindowHierarchyChanged(
+ const HierarchyChangeParams& params) {
// A window can get removed and then re-added by a drag and drop operation.
if (params.new_parent && IsContainerWindow(params.new_parent) &&
- !base::ContainsKey(window_state_map_, params.target)) {
+ !base::ContainsKey(window_state_map_, WmWindow::Get(params.target))) {
// Don't register the window if the window is invisible. Instead,
// wait until it becomes visible because the client may update the
// flag to control if the window should be added.
@@ -129,26 +131,28 @@ void MaximizeModeWindowManager::OnWindowTreeChanged(
}
return;
}
- MaximizeAndTrackWindow(params.target);
+ MaximizeAndTrackWindow(WmWindow::Get(params.target));
// When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
// already sent and we have to notify our state again.
- if (base::ContainsKey(window_state_map_, params.target)) {
+ if (base::ContainsKey(window_state_map_, WmWindow::Get(params.target))) {
wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
- params.target->GetWindowState()->OnWMEvent(&event);
+ wm::GetWindowState(params.target)->OnWMEvent(&event);
}
}
}
-void MaximizeModeWindowManager::OnWindowPropertyChanged(
- WmWindow* window,
- WmWindowProperty property) {
+void MaximizeModeWindowManager::OnWindowPropertyChanged(aura::Window* window,
+ const void* key,
+ intptr_t old) {
// Stop managing |window| if the always-on-top property is added.
- if (property == WmWindowProperty::ALWAYS_ON_TOP && window->IsAlwaysOnTop())
- ForgetWindow(window);
+ if (key == aura::client::kAlwaysOnTopKey &&
+ window->GetProperty(aura::client::kAlwaysOnTopKey)) {
+ ForgetWindow(WmWindow::Get(window));
+ }
}
void MaximizeModeWindowManager::OnWindowBoundsChanged(
- WmWindow* window,
+ aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
if (!IsContainerWindow(window))
@@ -158,22 +162,22 @@ void MaximizeModeWindowManager::OnWindowBoundsChanged(
pair.second->UpdateWindowPosition(pair.first->GetWindowState());
}
-void MaximizeModeWindowManager::OnWindowVisibilityChanged(WmWindow* window,
+void MaximizeModeWindowManager::OnWindowVisibilityChanged(aura::Window* window,
bool visible) {
// Skip if it's already managed.
- if (base::ContainsKey(window_state_map_, window))
+ if (base::ContainsKey(window_state_map_, WmWindow::Get(window)))
return;
- if (IsContainerWindow(window->GetParent()) &&
+ if (IsContainerWindow(window->parent()) &&
base::ContainsValue(added_windows_, window) && visible) {
added_windows_.erase(window);
window->RemoveObserver(this);
- MaximizeAndTrackWindow(window);
+ MaximizeAndTrackWindow(WmWindow::Get(window));
// When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
// already sent and we have to notify our state again.
- if (base::ContainsKey(window_state_map_, window)) {
+ if (base::ContainsKey(window_state_map_, WmWindow::Get(window))) {
wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
- window->GetWindowState()->OnWMEvent(&event);
+ wm::GetWindowState(window)->OnWMEvent(&event);
}
}
}
@@ -231,7 +235,7 @@ void MaximizeModeWindowManager::MaximizeAndTrackWindow(WmWindow* window) {
return;
DCHECK(!base::ContainsKey(window_state_map_, window));
- window->AddObserver(this);
+ window->aura_window()->AddObserver(this);
// We create and remember a maximize mode state which will attach itself to
// the provided state object.
@@ -245,7 +249,7 @@ void MaximizeModeWindowManager::ForgetWindow(WmWindow* window) {
// earlier by someone else. However - at this point there is no other client
// which replaces the state object and therefore this should not happen.
DCHECK(it != window_state_map_.end());
- window->RemoveObserver(this);
+ window->aura_window()->RemoveObserver(this);
// By telling the state object to revert, it will switch back the old
// State object and destroy itself, calling WindowStateDestroyed().
@@ -277,9 +281,9 @@ void MaximizeModeWindowManager::AddWindowCreationObservers() {
DCHECK(observed_container_windows_.empty());
// Observe window activations/creations in the default containers on all root
// windows.
- for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) {
- WmWindow* default_container =
- root->GetChildByShellWindowId(kShellWindowId_DefaultContainer);
+ for (aura::Window* root : Shell::GetInstance()->GetAllRootWindows()) {
+ aura::Window* default_container =
+ root->GetChildById(kShellWindowId_DefaultContainer);
DCHECK(!base::ContainsKey(observed_container_windows_, default_container));
default_container->AddObserver(this);
observed_container_windows_.insert(default_container);
@@ -287,7 +291,7 @@ void MaximizeModeWindowManager::AddWindowCreationObservers() {
}
void MaximizeModeWindowManager::RemoveWindowCreationObservers() {
- for (WmWindow* window : observed_container_windows_)
+ for (aura::Window* window : observed_container_windows_)
window->RemoveObserver(this);
observed_container_windows_.clear();
}
@@ -299,7 +303,7 @@ void MaximizeModeWindowManager::DisplayConfigurationChanged() {
EnableBackdropBehindTopWindowOnEachDisplay(true);
}
-bool MaximizeModeWindowManager::IsContainerWindow(WmWindow* window) {
+bool MaximizeModeWindowManager::IsContainerWindow(aura::Window* window) {
return base::ContainsKey(observed_container_windows_, window);
}
« no previous file with comments | « ash/common/wm/maximize_mode/maximize_mode_window_manager.h ('k') | ash/common/wm/maximize_mode/workspace_backdrop_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698