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

Side by Side Diff: ash/common/wm/system_modal_container_layout_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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/wm/system_modal_container_layout_manager.h" 5 #include "ash/common/wm/system_modal_container_layout_manager.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/wm/window_dimmer.h" 10 #include "ash/common/wm/window_dimmer.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/common/wm_window.h" 12 #include "ash/common/wm_window.h"
13 #include "ash/common/wm_window_property.h" 13 #include "ash/common/wm_window_property.h"
14 #include "ash/public/cpp/shell_window_ids.h" 14 #include "ash/public/cpp/shell_window_ids.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/window.h"
17 #include "ui/keyboard/keyboard_controller.h" 19 #include "ui/keyboard/keyboard_controller.h"
18 20
19 namespace ash { 21 namespace ash {
20 namespace { 22 namespace {
21 23
22 // The center point of the window can diverge this much from the center point 24 // The center point of the window can diverge this much from the center point
23 // of the container to be kept centered upon resizing operations. 25 // of the container to be kept centered upon resizing operations.
24 const int kCenterPixelDelta = 32; 26 const int kCenterPixelDelta = 32;
25 27
26 ui::ModalType GetModalType(WmWindow* window) { 28 ui::ModalType GetModalType(WmWindow* window) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 DCHECK(container_->GetShellWindowId() != 82 DCHECK(container_->GetShellWindowId() !=
81 kShellWindowId_LockSystemModalContainer || 83 kShellWindowId_LockSystemModalContainer ||
82 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()); 84 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked());
83 } 85 }
84 // Since this is for SystemModal, there is no good reason to add windows 86 // Since this is for SystemModal, there is no good reason to add windows
85 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple 87 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple
86 // mistake. 88 // mistake.
87 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); 89 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD);
88 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); 90 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW);
89 91
90 child->AddObserver(this); 92 child->aura_window()->AddObserver(this);
91 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM && child->IsVisible()) 93 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM && child->IsVisible())
92 AddModalWindow(child); 94 AddModalWindow(child);
93 } 95 }
94 96
95 void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout( 97 void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout(
96 WmWindow* child) { 98 WmWindow* child) {
97 child->RemoveObserver(this); 99 child->aura_window()->RemoveObserver(this);
98 windows_to_center_.erase(child); 100 windows_to_center_.erase(child);
99 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM) 101 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM)
100 RemoveModalWindow(child); 102 RemoveModalWindow(child);
101 } 103 }
102 104
103 void SystemModalContainerLayoutManager::SetChildBounds( 105 void SystemModalContainerLayoutManager::SetChildBounds(
104 WmWindow* child, 106 WmWindow* child,
105 const gfx::Rect& requested_bounds) { 107 const gfx::Rect& requested_bounds) {
106 WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); 108 WmSnapToPixelLayoutManager::SetChildBounds(child, requested_bounds);
107 if (IsBoundsCentered(requested_bounds)) 109 if (IsBoundsCentered(requested_bounds))
108 windows_to_center_.insert(child); 110 windows_to_center_.insert(child);
109 else 111 else
110 windows_to_center_.erase(child); 112 windows_to_center_.erase(child);
111 } 113 }
112 114
113 //////////////////////////////////////////////////////////////////////////////// 115 ////////////////////////////////////////////////////////////////////////////////
114 // SystemModalContainerLayoutManager, WmWindowObserver implementation: 116 // SystemModalContainerLayoutManager, aura::WindowObserver implementation:
115 117
116 void SystemModalContainerLayoutManager::OnWindowPropertyChanged( 118 void SystemModalContainerLayoutManager::OnWindowPropertyChanged(
117 WmWindow* window, 119 aura::Window* window,
118 WmWindowProperty property) { 120 const void* key,
119 if (property != WmWindowProperty::MODAL_TYPE || !window->IsVisible()) 121 intptr_t old) {
122 if (key != aura::client::kModalKey || !window->IsVisible())
120 return; 123 return;
121 124
122 if (GetModalType(window) == ui::MODAL_TYPE_SYSTEM) { 125 WmWindow* wm_window = WmWindow::Get(window);
123 if (base::ContainsValue(modal_windows_, window)) 126 if (window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM) {
127 if (base::ContainsValue(modal_windows_, wm_window))
124 return; 128 return;
125 AddModalWindow(window); 129 AddModalWindow(wm_window);
126 } else { 130 } else {
127 if (RemoveModalWindow(window)) 131 if (RemoveModalWindow(wm_window))
128 WmShell::Get()->OnModalWindowRemoved(window); 132 WmShell::Get()->OnModalWindowRemoved(wm_window);
129 } 133 }
130 } 134 }
131 135
132 //////////////////////////////////////////////////////////////////////////////// 136 ////////////////////////////////////////////////////////////////////////////////
133 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver 137 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver
134 // implementation: 138 // implementation:
135 139
136 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging( 140 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging(
137 const gfx::Rect& new_bounds) { 141 const gfx::Rect& new_bounds) {
138 PositionDialogsAfterWorkAreaResize(); 142 PositionDialogsAfterWorkAreaResize();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 bool SystemModalContainerLayoutManager::IsBoundsCentered( 272 bool SystemModalContainerLayoutManager::IsBoundsCentered(
269 const gfx::Rect& bounds) const { 273 const gfx::Rect& bounds) const {
270 gfx::Point window_center = bounds.CenterPoint(); 274 gfx::Point window_center = bounds.CenterPoint();
271 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); 275 gfx::Point container_center = GetUsableDialogArea().CenterPoint();
272 return std::abs(window_center.x() - container_center.x()) < 276 return std::abs(window_center.x() - container_center.x()) <
273 kCenterPixelDelta && 277 kCenterPixelDelta &&
274 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; 278 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta;
275 } 279 }
276 280
277 } // namespace ash 281 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/system_modal_container_layout_manager.h ('k') | ash/common/wm/window_cycle_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698