| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/aura/wm_window_aura.h" | 5 #include "ash/common/wm_window.h" |
| 6 | 6 |
| 7 #include "ash/aura/aura_layout_manager_adapter.h" | 7 #include "ash/aura/aura_layout_manager_adapter.h" |
| 8 #include "ash/aura/wm_shell_aura.h" | 8 #include "ash/aura/wm_shell_aura.h" |
| 9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/shelf/shelf_item_types.h" | 10 #include "ash/common/shelf/shelf_item_types.h" |
| 11 #include "ash/common/wm/window_state.h" | 11 #include "ash/common/wm/window_state.h" |
| 12 #include "ash/common/wm_layout_manager.h" | 12 #include "ash/common/wm_layout_manager.h" |
| 13 #include "ash/common/wm_transient_window_observer.h" | 13 #include "ash/common/wm_transient_window_observer.h" |
| 14 #include "ash/common/wm_window_observer.h" | 14 #include "ash/common/wm_window_observer.h" |
| 15 #include "ash/common/wm_window_property.h" | 15 #include "ash/common/wm_window_property.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 43 #include "ui/display/screen.h" | 43 #include "ui/display/screen.h" |
| 44 #include "ui/gfx/geometry/insets.h" | 44 #include "ui/gfx/geometry/insets.h" |
| 45 #include "ui/views/widget/widget.h" | 45 #include "ui/views/widget/widget.h" |
| 46 #include "ui/views/widget/widget_delegate.h" | 46 #include "ui/views/widget/widget_delegate.h" |
| 47 #include "ui/wm/core/coordinate_conversion.h" | 47 #include "ui/wm/core/coordinate_conversion.h" |
| 48 #include "ui/wm/core/easy_resize_window_targeter.h" | 48 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 49 #include "ui/wm/core/transient_window_manager.h" | 49 #include "ui/wm/core/transient_window_manager.h" |
| 50 #include "ui/wm/core/visibility_controller.h" | 50 #include "ui/wm/core/visibility_controller.h" |
| 51 #include "ui/wm/core/window_util.h" | 51 #include "ui/wm/core/window_util.h" |
| 52 | 52 |
| 53 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmWindowAura*); | 53 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmWindow*); |
| 54 | 54 |
| 55 namespace ash { | 55 namespace ash { |
| 56 | 56 |
| 57 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WmWindowAura, kWmWindowKey, nullptr); | 57 DEFINE_OWNED_WINDOW_PROPERTY_KEY(WmWindow, kWmWindowKey, nullptr); |
| 58 | 58 |
| 59 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, | 59 static_assert(aura::Window::kInitialId == kShellWindowId_Invalid, |
| 60 "ids must match"); | 60 "ids must match"); |
| 61 | 61 |
| 62 namespace { | 62 namespace { |
| 63 | 63 |
| 64 // A tentative class to set the bounds on the window. | 64 // A tentative class to set the bounds on the window. |
| 65 // TODO(oshima): Once all logic is cleaned up, move this to the real layout | 65 // TODO(oshima): Once all logic is cleaned up, move this to the real layout |
| 66 // manager with proper friendship. | 66 // manager with proper friendship. |
| 67 class BoundsSetter : public aura::LayoutManager { | 67 class BoundsSetter : public aura::LayoutManager { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 83 SetChildBoundsDirect(window, bounds); | 83 SetChildBoundsDirect(window, bounds); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(BoundsSetter); | 87 DISALLOW_COPY_AND_ASSIGN(BoundsSetter); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // namespace | 90 } // namespace |
| 91 | 91 |
| 92 // static | 92 // static |
| 93 bool WmWindowAura::default_use_empty_minimum_size_for_testing_ = false; | 93 bool WmWindow::default_use_empty_minimum_size_for_testing_ = false; |
| 94 | 94 |
| 95 WmWindowAura::~WmWindowAura() { | 95 WmWindow::~WmWindow() { |
| 96 if (added_transient_observer_) | 96 if (added_transient_observer_) |
| 97 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); | 97 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); |
| 98 | 98 |
| 99 window_->RemoveObserver(this); | 99 window_->RemoveObserver(this); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // static | 102 // static |
| 103 const WmWindowAura* WmWindowAura::Get(const aura::Window* window) { | 103 const WmWindow* WmWindow::Get(const aura::Window* window) { |
| 104 if (!window) | 104 if (!window) |
| 105 return nullptr; | 105 return nullptr; |
| 106 | 106 |
| 107 const WmWindowAura* wm_window = window->GetProperty(kWmWindowKey); | 107 const WmWindow* wm_window = window->GetProperty(kWmWindowKey); |
| 108 if (wm_window) | 108 if (wm_window) |
| 109 return wm_window; | 109 return wm_window; |
| 110 // WmWindowAura is owned by the aura::Window. | 110 // WmWindow is owned by the aura::Window. |
| 111 // TODO(sky): fix constness. | 111 // TODO(sky): fix constness. |
| 112 return new WmWindowAura(const_cast<aura::Window*>(window)); | 112 return new WmWindow(const_cast<aura::Window*>(window)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // static | 115 // static |
| 116 std::vector<WmWindow*> WmWindowAura::FromAuraWindows( | 116 std::vector<WmWindow*> WmWindow::FromAuraWindows( |
| 117 const std::vector<aura::Window*>& aura_windows) { | 117 const std::vector<aura::Window*>& aura_windows) { |
| 118 std::vector<WmWindow*> result(aura_windows.size()); | 118 std::vector<WmWindow*> result(aura_windows.size()); |
| 119 for (size_t i = 0; i < aura_windows.size(); ++i) | 119 for (size_t i = 0; i < aura_windows.size(); ++i) |
| 120 result[i] = Get(aura_windows[i]); | 120 result[i] = Get(aura_windows[i]); |
| 121 return result; | 121 return result; |
| 122 } | 122 } |
| 123 | 123 |
| 124 // static | 124 // static |
| 125 std::vector<aura::Window*> WmWindowAura::ToAuraWindows( | 125 std::vector<aura::Window*> WmWindow::ToAuraWindows( |
| 126 const std::vector<WmWindow*>& windows) { | 126 const std::vector<WmWindow*>& windows) { |
| 127 std::vector<aura::Window*> result(windows.size()); | 127 std::vector<aura::Window*> result(windows.size()); |
| 128 for (size_t i = 0; i < windows.size(); ++i) | 128 for (size_t i = 0; i < windows.size(); ++i) |
| 129 result[i] = WmWindowAura::GetAuraWindow(windows[i]); | 129 result[i] = WmWindow::GetAuraWindow(windows[i]); |
| 130 return result; | 130 return result; |
| 131 } | 131 } |
| 132 | 132 |
| 133 // static | 133 // static |
| 134 const aura::Window* WmWindowAura::GetAuraWindow(const WmWindow* wm_window) { | 134 const aura::Window* WmWindow::GetAuraWindow(const WmWindow* wm_window) { |
| 135 return wm_window ? static_cast<const WmWindowAura*>(wm_window)->aura_window() | 135 return wm_window ? static_cast<const WmWindow*>(wm_window)->aura_window() |
| 136 : nullptr; | 136 : nullptr; |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool WmWindowAura::ShouldUseExtendedHitRegion() const { | 139 bool WmWindow::ShouldUseExtendedHitRegion() const { |
| 140 const WmWindow* parent = Get(window_->parent()); | 140 const WmWindow* parent = Get(window_->parent()); |
| 141 return parent && | 141 return parent && |
| 142 static_cast<const WmWindowAura*>(parent) | 142 static_cast<const WmWindow*>(parent) |
| 143 ->children_use_extended_hit_region_; | 143 ->children_use_extended_hit_region_; |
| 144 } | 144 } |
| 145 | 145 |
| 146 void WmWindowAura::Destroy() { | 146 void WmWindow::Destroy() { |
| 147 delete window_; | 147 delete window_; |
| 148 // WARNING: this has been deleted. | 148 // WARNING: this has been deleted. |
| 149 } | 149 } |
| 150 | 150 |
| 151 const WmWindow* WmWindowAura::GetRootWindow() const { | 151 const WmWindow* WmWindow::GetRootWindow() const { |
| 152 return Get(window_->GetRootWindow()); | 152 return Get(window_->GetRootWindow()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 RootWindowController* WmWindowAura::GetRootWindowController() { | 155 RootWindowController* WmWindow::GetRootWindowController() { |
| 156 aura::Window* root = window_->GetRootWindow(); | 156 aura::Window* root = window_->GetRootWindow(); |
| 157 return root ? RootWindowController::ForWindow(root) : nullptr; | 157 return root ? RootWindowController::ForWindow(root) : nullptr; |
| 158 } | 158 } |
| 159 | 159 |
| 160 WmShell* WmWindowAura::GetShell() const { | 160 WmShell* WmWindow::GetShell() const { |
| 161 return WmShell::Get(); | 161 return WmShell::Get(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void WmWindowAura::SetName(const char* name) { | 164 void WmWindow::SetName(const char* name) { |
| 165 window_->SetName(name); | 165 window_->SetName(name); |
| 166 } | 166 } |
| 167 | 167 |
| 168 std::string WmWindowAura::GetName() const { | 168 std::string WmWindow::GetName() const { |
| 169 return window_->GetName(); | 169 return window_->GetName(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void WmWindowAura::SetTitle(const base::string16& title) { | 172 void WmWindow::SetTitle(const base::string16& title) { |
| 173 window_->SetTitle(title); | 173 window_->SetTitle(title); |
| 174 } | 174 } |
| 175 | 175 |
| 176 base::string16 WmWindowAura::GetTitle() const { | 176 base::string16 WmWindow::GetTitle() const { |
| 177 return window_->GetTitle(); | 177 return window_->GetTitle(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void WmWindowAura::SetShellWindowId(int id) { | 180 void WmWindow::SetShellWindowId(int id) { |
| 181 window_->set_id(id); | 181 window_->set_id(id); |
| 182 } | 182 } |
| 183 | 183 |
| 184 int WmWindowAura::GetShellWindowId() const { | 184 int WmWindow::GetShellWindowId() const { |
| 185 return window_->id(); | 185 return window_->id(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 ui::wm::WindowType WmWindowAura::GetType() const { | 188 ui::wm::WindowType WmWindow::GetType() const { |
| 189 return window_->type(); | 189 return window_->type(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 int WmWindowAura::GetAppType() const { | 192 int WmWindow::GetAppType() const { |
| 193 return window_->GetProperty(aura::client::kAppType); | 193 return window_->GetProperty(aura::client::kAppType); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void WmWindowAura::SetAppType(int app_type) const { | 196 void WmWindow::SetAppType(int app_type) const { |
| 197 window_->SetProperty(aura::client::kAppType, app_type); | 197 window_->SetProperty(aura::client::kAppType, app_type); |
| 198 } | 198 } |
| 199 | 199 |
| 200 ui::Layer* WmWindowAura::GetLayer() { | 200 ui::Layer* WmWindow::GetLayer() { |
| 201 return window_->layer(); | 201 return window_->layer(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 bool WmWindowAura::GetLayerTargetVisibility() { | 204 bool WmWindow::GetLayerTargetVisibility() { |
| 205 return GetLayer()->GetTargetVisibility(); | 205 return GetLayer()->GetTargetVisibility(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 bool WmWindowAura::GetLayerVisible() { | 208 bool WmWindow::GetLayerVisible() { |
| 209 return GetLayer()->visible(); | 209 return GetLayer()->visible(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 display::Display WmWindowAura::GetDisplayNearestWindow() { | 212 display::Display WmWindow::GetDisplayNearestWindow() { |
| 213 return display::Screen::GetScreen()->GetDisplayNearestWindow(window_); | 213 return display::Screen::GetScreen()->GetDisplayNearestWindow(window_); |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool WmWindowAura::HasNonClientArea() { | 216 bool WmWindow::HasNonClientArea() { |
| 217 return window_->delegate() ? true : false; | 217 return window_->delegate() ? true : false; |
| 218 } | 218 } |
| 219 | 219 |
| 220 int WmWindowAura::GetNonClientComponent(const gfx::Point& location) { | 220 int WmWindow::GetNonClientComponent(const gfx::Point& location) { |
| 221 return window_->delegate() | 221 return window_->delegate() |
| 222 ? window_->delegate()->GetNonClientComponent(location) | 222 ? window_->delegate()->GetNonClientComponent(location) |
| 223 : HTNOWHERE; | 223 : HTNOWHERE; |
| 224 } | 224 } |
| 225 | 225 |
| 226 gfx::Point WmWindowAura::ConvertPointToTarget(const WmWindow* target, | 226 gfx::Point WmWindow::ConvertPointToTarget(const WmWindow* target, |
| 227 const gfx::Point& point) const { | 227 const gfx::Point& point) const { |
| 228 gfx::Point result(point); | 228 gfx::Point result(point); |
| 229 aura::Window::ConvertPointToTarget(window_, GetAuraWindow(target), &result); | 229 aura::Window::ConvertPointToTarget(window_, GetAuraWindow(target), &result); |
| 230 return result; | 230 return result; |
| 231 } | 231 } |
| 232 | 232 |
| 233 gfx::Point WmWindowAura::ConvertPointToScreen(const gfx::Point& point) const { | 233 gfx::Point WmWindow::ConvertPointToScreen(const gfx::Point& point) const { |
| 234 gfx::Point result(point); | 234 gfx::Point result(point); |
| 235 ::wm::ConvertPointToScreen(window_, &result); | 235 ::wm::ConvertPointToScreen(window_, &result); |
| 236 return result; | 236 return result; |
| 237 } | 237 } |
| 238 | 238 |
| 239 gfx::Point WmWindowAura::ConvertPointFromScreen(const gfx::Point& point) const { | 239 gfx::Point WmWindow::ConvertPointFromScreen(const gfx::Point& point) const { |
| 240 gfx::Point result(point); | 240 gfx::Point result(point); |
| 241 ::wm::ConvertPointFromScreen(window_, &result); | 241 ::wm::ConvertPointFromScreen(window_, &result); |
| 242 return result; | 242 return result; |
| 243 } | 243 } |
| 244 | 244 |
| 245 gfx::Rect WmWindowAura::ConvertRectToScreen(const gfx::Rect& rect) const { | 245 gfx::Rect WmWindow::ConvertRectToScreen(const gfx::Rect& rect) const { |
| 246 return ScreenUtil::ConvertRectToScreen(window_, rect); | 246 return ScreenUtil::ConvertRectToScreen(window_, rect); |
| 247 } | 247 } |
| 248 | 248 |
| 249 gfx::Rect WmWindowAura::ConvertRectFromScreen(const gfx::Rect& rect) const { | 249 gfx::Rect WmWindow::ConvertRectFromScreen(const gfx::Rect& rect) const { |
| 250 return ScreenUtil::ConvertRectFromScreen(window_, rect); | 250 return ScreenUtil::ConvertRectFromScreen(window_, rect); |
| 251 } | 251 } |
| 252 | 252 |
| 253 gfx::Size WmWindowAura::GetMinimumSize() const { | 253 gfx::Size WmWindow::GetMinimumSize() const { |
| 254 return window_->delegate() && !use_empty_minimum_size_for_testing_ | 254 return window_->delegate() && !use_empty_minimum_size_for_testing_ |
| 255 ? window_->delegate()->GetMinimumSize() | 255 ? window_->delegate()->GetMinimumSize() |
| 256 : gfx::Size(); | 256 : gfx::Size(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 gfx::Size WmWindowAura::GetMaximumSize() const { | 259 gfx::Size WmWindow::GetMaximumSize() const { |
| 260 return window_->delegate() ? window_->delegate()->GetMaximumSize() | 260 return window_->delegate() ? window_->delegate()->GetMaximumSize() |
| 261 : gfx::Size(); | 261 : gfx::Size(); |
| 262 } | 262 } |
| 263 | 263 |
| 264 bool WmWindowAura::GetTargetVisibility() const { | 264 bool WmWindow::GetTargetVisibility() const { |
| 265 return window_->TargetVisibility(); | 265 return window_->TargetVisibility(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool WmWindowAura::IsVisible() const { | 268 bool WmWindow::IsVisible() const { |
| 269 return window_->IsVisible(); | 269 return window_->IsVisible(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void WmWindowAura::SetOpacity(float opacity) { | 272 void WmWindow::SetOpacity(float opacity) { |
| 273 window_->layer()->SetOpacity(opacity); | 273 window_->layer()->SetOpacity(opacity); |
| 274 } | 274 } |
| 275 | 275 |
| 276 float WmWindowAura::GetTargetOpacity() const { | 276 float WmWindow::GetTargetOpacity() const { |
| 277 return window_->layer()->GetTargetOpacity(); | 277 return window_->layer()->GetTargetOpacity(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 gfx::Rect WmWindowAura::GetMinimizeAnimationTargetBoundsInScreen() const { | 280 gfx::Rect WmWindow::GetMinimizeAnimationTargetBoundsInScreen() const { |
| 281 return ash::GetMinimizeAnimationTargetBoundsInScreen(window_); | 281 return ash::GetMinimizeAnimationTargetBoundsInScreen(window_); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void WmWindowAura::SetTransform(const gfx::Transform& transform) { | 284 void WmWindow::SetTransform(const gfx::Transform& transform) { |
| 285 window_->SetTransform(transform); | 285 window_->SetTransform(transform); |
| 286 } | 286 } |
| 287 | 287 |
| 288 gfx::Transform WmWindowAura::GetTargetTransform() const { | 288 gfx::Transform WmWindow::GetTargetTransform() const { |
| 289 return window_->layer()->GetTargetTransform(); | 289 return window_->layer()->GetTargetTransform(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 bool WmWindowAura::IsSystemModal() const { | 292 bool WmWindow::IsSystemModal() const { |
| 293 return window_->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; | 293 return window_->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; |
| 294 } | 294 } |
| 295 | 295 |
| 296 bool WmWindowAura::GetBoolProperty(WmWindowProperty key) { | 296 bool WmWindow::GetBoolProperty(WmWindowProperty key) { |
| 297 switch (key) { | 297 switch (key) { |
| 298 case WmWindowProperty::DRAW_ATTENTION: | 298 case WmWindowProperty::DRAW_ATTENTION: |
| 299 return window_->GetProperty(aura::client::kDrawAttentionKey); | 299 return window_->GetProperty(aura::client::kDrawAttentionKey); |
| 300 | 300 |
| 301 case WmWindowProperty::PANEL_ATTACHED: | 301 case WmWindowProperty::PANEL_ATTACHED: |
| 302 return window_->GetProperty(kPanelAttachedKey); | 302 return window_->GetProperty(kPanelAttachedKey); |
| 303 | 303 |
| 304 case WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: | 304 case WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: |
| 305 return window_->GetProperty(kSnapChildrenToPixelBoundary); | 305 return window_->GetProperty(kSnapChildrenToPixelBoundary); |
| 306 | 306 |
| 307 case WmWindowProperty::ALWAYS_ON_TOP: | 307 case WmWindowProperty::ALWAYS_ON_TOP: |
| 308 return window_->GetProperty(aura::client::kAlwaysOnTopKey); | 308 return window_->GetProperty(aura::client::kAlwaysOnTopKey); |
| 309 | 309 |
| 310 default: | 310 default: |
| 311 NOTREACHED(); | 311 NOTREACHED(); |
| 312 break; | 312 break; |
| 313 } | 313 } |
| 314 | 314 |
| 315 return false; | 315 return false; |
| 316 } | 316 } |
| 317 | 317 |
| 318 void WmWindowAura::SetBoolProperty(WmWindowProperty key, bool value) { | 318 void WmWindow::SetBoolProperty(WmWindowProperty key, bool value) { |
| 319 switch (key) { | 319 switch (key) { |
| 320 case WmWindowProperty::PANEL_ATTACHED: | 320 case WmWindowProperty::PANEL_ATTACHED: |
| 321 window_->SetProperty(kPanelAttachedKey, value); | 321 window_->SetProperty(kPanelAttachedKey, value); |
| 322 break; | 322 break; |
| 323 default: | 323 default: |
| 324 NOTREACHED(); | 324 NOTREACHED(); |
| 325 break; | 325 break; |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 SkColor WmWindowAura::GetColorProperty(WmWindowProperty key) { | 329 SkColor WmWindow::GetColorProperty(WmWindowProperty key) { |
| 330 if (key == WmWindowProperty::TOP_VIEW_COLOR) | 330 if (key == WmWindowProperty::TOP_VIEW_COLOR) |
| 331 return window_->GetProperty(aura::client::kTopViewColor); | 331 return window_->GetProperty(aura::client::kTopViewColor); |
| 332 | 332 |
| 333 NOTREACHED(); | 333 NOTREACHED(); |
| 334 return 0; | 334 return 0; |
| 335 } | 335 } |
| 336 | 336 |
| 337 void WmWindowAura::SetColorProperty(WmWindowProperty key, SkColor value) { | 337 void WmWindow::SetColorProperty(WmWindowProperty key, SkColor value) { |
| 338 if (key == WmWindowProperty::TOP_VIEW_COLOR) { | 338 if (key == WmWindowProperty::TOP_VIEW_COLOR) { |
| 339 window_->SetProperty(aura::client::kTopViewColor, value); | 339 window_->SetProperty(aura::client::kTopViewColor, value); |
| 340 return; | 340 return; |
| 341 } | 341 } |
| 342 | 342 |
| 343 NOTREACHED(); | 343 NOTREACHED(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 int WmWindowAura::GetIntProperty(WmWindowProperty key) { | 346 int WmWindow::GetIntProperty(WmWindowProperty key) { |
| 347 if (key == WmWindowProperty::MODAL_TYPE) | 347 if (key == WmWindowProperty::MODAL_TYPE) |
| 348 return window_->GetProperty(aura::client::kModalKey); | 348 return window_->GetProperty(aura::client::kModalKey); |
| 349 | 349 |
| 350 if (key == WmWindowProperty::SHELF_ID) | 350 if (key == WmWindowProperty::SHELF_ID) |
| 351 return window_->GetProperty(kShelfIDKey); | 351 return window_->GetProperty(kShelfIDKey); |
| 352 | 352 |
| 353 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | 353 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { |
| 354 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL || | 354 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL || |
| 355 window_->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED) { | 355 window_->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED) { |
| 356 return window_->GetProperty(kShelfItemTypeKey); | 356 return window_->GetProperty(kShelfItemTypeKey); |
| 357 } | 357 } |
| 358 // Mash provides a default shelf item type for non-ignored windows. | 358 // Mash provides a default shelf item type for non-ignored windows. |
| 359 return GetWindowState()->ignored_by_shelf() ? TYPE_UNDEFINED : TYPE_APP; | 359 return GetWindowState()->ignored_by_shelf() ? TYPE_UNDEFINED : TYPE_APP; |
| 360 } | 360 } |
| 361 | 361 |
| 362 if (key == WmWindowProperty::TOP_VIEW_INSET) | 362 if (key == WmWindowProperty::TOP_VIEW_INSET) |
| 363 return window_->GetProperty(aura::client::kTopViewInset); | 363 return window_->GetProperty(aura::client::kTopViewInset); |
| 364 | 364 |
| 365 NOTREACHED(); | 365 NOTREACHED(); |
| 366 return 0; | 366 return 0; |
| 367 } | 367 } |
| 368 | 368 |
| 369 void WmWindowAura::SetIntProperty(WmWindowProperty key, int value) { | 369 void WmWindow::SetIntProperty(WmWindowProperty key, int value) { |
| 370 if (key == WmWindowProperty::SHELF_ID) { | 370 if (key == WmWindowProperty::SHELF_ID) { |
| 371 window_->SetProperty(kShelfIDKey, value); | 371 window_->SetProperty(kShelfIDKey, value); |
| 372 return; | 372 return; |
| 373 } | 373 } |
| 374 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | 374 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { |
| 375 window_->SetProperty(kShelfItemTypeKey, value); | 375 window_->SetProperty(kShelfItemTypeKey, value); |
| 376 return; | 376 return; |
| 377 } | 377 } |
| 378 if (key == WmWindowProperty::TOP_VIEW_INSET) { | 378 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| 379 window_->SetProperty(aura::client::kTopViewInset, value); | 379 window_->SetProperty(aura::client::kTopViewInset, value); |
| 380 return; | 380 return; |
| 381 } | 381 } |
| 382 | 382 |
| 383 NOTREACHED(); | 383 NOTREACHED(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 std::string WmWindowAura::GetStringProperty(WmWindowProperty key) { | 386 std::string WmWindow::GetStringProperty(WmWindowProperty key) { |
| 387 if (key == WmWindowProperty::APP_ID) { | 387 if (key == WmWindowProperty::APP_ID) { |
| 388 std::string* value = window_->GetProperty(aura::client::kAppIdKey); | 388 std::string* value = window_->GetProperty(aura::client::kAppIdKey); |
| 389 return value ? *value : std::string(); | 389 return value ? *value : std::string(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 NOTREACHED(); | 392 NOTREACHED(); |
| 393 return std::string(); | 393 return std::string(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void WmWindowAura::SetStringProperty(WmWindowProperty key, | 396 void WmWindow::SetStringProperty(WmWindowProperty key, |
| 397 const std::string& value) { | 397 const std::string& value) { |
| 398 if (key == WmWindowProperty::APP_ID) { | 398 if (key == WmWindowProperty::APP_ID) { |
| 399 window_->SetProperty(aura::client::kAppIdKey, new std::string(value)); | 399 window_->SetProperty(aura::client::kAppIdKey, new std::string(value)); |
| 400 return; | 400 return; |
| 401 } | 401 } |
| 402 | 402 |
| 403 NOTREACHED(); | 403 NOTREACHED(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 gfx::ImageSkia WmWindowAura::GetWindowIcon() { | 406 gfx::ImageSkia WmWindow::GetWindowIcon() { |
| 407 gfx::ImageSkia* image = window_->GetProperty(aura::client::kWindowIconKey); | 407 gfx::ImageSkia* image = window_->GetProperty(aura::client::kWindowIconKey); |
| 408 return image ? *image : gfx::ImageSkia(); | 408 return image ? *image : gfx::ImageSkia(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 gfx::ImageSkia WmWindowAura::GetAppIcon() { | 411 gfx::ImageSkia WmWindow::GetAppIcon() { |
| 412 gfx::ImageSkia* image = window_->GetProperty(aura::client::kAppIconKey); | 412 gfx::ImageSkia* image = window_->GetProperty(aura::client::kAppIconKey); |
| 413 return image ? *image : gfx::ImageSkia(); | 413 return image ? *image : gfx::ImageSkia(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 const wm::WindowState* WmWindowAura::GetWindowState() const { | 416 const wm::WindowState* WmWindow::GetWindowState() const { |
| 417 return ash::wm::GetWindowState(window_); | 417 return ash::wm::GetWindowState(window_); |
| 418 } | 418 } |
| 419 | 419 |
| 420 WmWindow* WmWindowAura::GetToplevelWindow() { | 420 WmWindow* WmWindow::GetToplevelWindow() { |
| 421 return Get(window_->GetToplevelWindow()); | 421 return Get(window_->GetToplevelWindow()); |
| 422 } | 422 } |
| 423 | 423 |
| 424 WmWindow* WmWindowAura::GetToplevelWindowForFocus() { | 424 WmWindow* WmWindow::GetToplevelWindowForFocus() { |
| 425 return Get(::wm::GetToplevelWindow(window_)); | 425 return Get(::wm::GetToplevelWindow(window_)); |
| 426 } | 426 } |
| 427 | 427 |
| 428 void WmWindowAura::SetParentUsingContext(WmWindow* context, | 428 void WmWindow::SetParentUsingContext(WmWindow* context, |
| 429 const gfx::Rect& screen_bounds) { | 429 const gfx::Rect& screen_bounds) { |
| 430 aura::client::ParentWindowWithContext(window_, GetAuraWindow(context), | 430 aura::client::ParentWindowWithContext(window_, GetAuraWindow(context), |
| 431 screen_bounds); | 431 screen_bounds); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void WmWindowAura::AddChild(WmWindow* window) { | 434 void WmWindow::AddChild(WmWindow* window) { |
| 435 window_->AddChild(GetAuraWindow(window)); | 435 window_->AddChild(GetAuraWindow(window)); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void WmWindowAura::RemoveChild(WmWindow* child) { | 438 void WmWindow::RemoveChild(WmWindow* child) { |
| 439 window_->RemoveChild(GetAuraWindow(child)); | 439 window_->RemoveChild(GetAuraWindow(child)); |
| 440 } | 440 } |
| 441 | 441 |
| 442 const WmWindow* WmWindowAura::GetParent() const { | 442 const WmWindow* WmWindow::GetParent() const { |
| 443 return Get(window_->parent()); | 443 return Get(window_->parent()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 const WmWindow* WmWindowAura::GetTransientParent() const { | 446 const WmWindow* WmWindow::GetTransientParent() const { |
| 447 return Get(::wm::GetTransientParent(window_)); | 447 return Get(::wm::GetTransientParent(window_)); |
| 448 } | 448 } |
| 449 | 449 |
| 450 std::vector<WmWindow*> WmWindowAura::GetTransientChildren() { | 450 std::vector<WmWindow*> WmWindow::GetTransientChildren() { |
| 451 return FromAuraWindows(::wm::GetTransientChildren(window_)); | 451 return FromAuraWindows(::wm::GetTransientChildren(window_)); |
| 452 } | 452 } |
| 453 | 453 |
| 454 bool WmWindowAura::MoveToEventRoot(const ui::Event& event) { | 454 bool WmWindow::MoveToEventRoot(const ui::Event& event) { |
| 455 return ash::wm::MoveWindowToEventRoot(window_, event); | 455 return ash::wm::MoveWindowToEventRoot(window_, event); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void WmWindowAura::SetLayoutManager( | 458 void WmWindow::SetLayoutManager( |
| 459 std::unique_ptr<WmLayoutManager> layout_manager) { | 459 std::unique_ptr<WmLayoutManager> layout_manager) { |
| 460 // See ~AuraLayoutManagerAdapter for why SetLayoutManager(nullptr) is called. | 460 // See ~AuraLayoutManagerAdapter for why SetLayoutManager(nullptr) is called. |
| 461 window_->SetLayoutManager(nullptr); | 461 window_->SetLayoutManager(nullptr); |
| 462 if (!layout_manager) | 462 if (!layout_manager) |
| 463 return; | 463 return; |
| 464 | 464 |
| 465 // |window_| takes ownership of AuraLayoutManagerAdapter. | 465 // |window_| takes ownership of AuraLayoutManagerAdapter. |
| 466 window_->SetLayoutManager( | 466 window_->SetLayoutManager( |
| 467 new AuraLayoutManagerAdapter(window_, std::move(layout_manager))); | 467 new AuraLayoutManagerAdapter(window_, std::move(layout_manager))); |
| 468 } | 468 } |
| 469 | 469 |
| 470 WmLayoutManager* WmWindowAura::GetLayoutManager() { | 470 WmLayoutManager* WmWindow::GetLayoutManager() { |
| 471 AuraLayoutManagerAdapter* adapter = AuraLayoutManagerAdapter::Get(window_); | 471 AuraLayoutManagerAdapter* adapter = AuraLayoutManagerAdapter::Get(window_); |
| 472 return adapter ? adapter->wm_layout_manager() : nullptr; | 472 return adapter ? adapter->wm_layout_manager() : nullptr; |
| 473 } | 473 } |
| 474 | 474 |
| 475 void WmWindowAura::SetVisibilityChangesAnimated() { | 475 void WmWindow::SetVisibilityChangesAnimated() { |
| 476 ::wm::SetWindowVisibilityChangesAnimated(window_); | 476 ::wm::SetWindowVisibilityChangesAnimated(window_); |
| 477 } | 477 } |
| 478 | 478 |
| 479 void WmWindowAura::SetVisibilityAnimationType(int type) { | 479 void WmWindow::SetVisibilityAnimationType(int type) { |
| 480 ::wm::SetWindowVisibilityAnimationType(window_, type); | 480 ::wm::SetWindowVisibilityAnimationType(window_, type); |
| 481 } | 481 } |
| 482 | 482 |
| 483 void WmWindowAura::SetVisibilityAnimationDuration(base::TimeDelta delta) { | 483 void WmWindow::SetVisibilityAnimationDuration(base::TimeDelta delta) { |
| 484 ::wm::SetWindowVisibilityAnimationDuration(window_, delta); | 484 ::wm::SetWindowVisibilityAnimationDuration(window_, delta); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void WmWindowAura::SetVisibilityAnimationTransition( | 487 void WmWindow::SetVisibilityAnimationTransition( |
| 488 ::wm::WindowVisibilityAnimationTransition transition) { | 488 ::wm::WindowVisibilityAnimationTransition transition) { |
| 489 ::wm::SetWindowVisibilityAnimationTransition(window_, transition); | 489 ::wm::SetWindowVisibilityAnimationTransition(window_, transition); |
| 490 } | 490 } |
| 491 | 491 |
| 492 void WmWindowAura::Animate(::wm::WindowAnimationType type) { | 492 void WmWindow::Animate(::wm::WindowAnimationType type) { |
| 493 ::wm::AnimateWindow(window_, type); | 493 ::wm::AnimateWindow(window_, type); |
| 494 } | 494 } |
| 495 | 495 |
| 496 void WmWindowAura::StopAnimatingProperty( | 496 void WmWindow::StopAnimatingProperty( |
| 497 ui::LayerAnimationElement::AnimatableProperty property) { | 497 ui::LayerAnimationElement::AnimatableProperty property) { |
| 498 window_->layer()->GetAnimator()->StopAnimatingProperty(property); | 498 window_->layer()->GetAnimator()->StopAnimatingProperty(property); |
| 499 } | 499 } |
| 500 | 500 |
| 501 void WmWindowAura::SetChildWindowVisibilityChangesAnimated() { | 501 void WmWindow::SetChildWindowVisibilityChangesAnimated() { |
| 502 ::wm::SetChildWindowVisibilityChangesAnimated(window_); | 502 ::wm::SetChildWindowVisibilityChangesAnimated(window_); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void WmWindowAura::SetMasksToBounds(bool value) { | 505 void WmWindow::SetMasksToBounds(bool value) { |
| 506 window_->layer()->SetMasksToBounds(value); | 506 window_->layer()->SetMasksToBounds(value); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void WmWindowAura::SetBounds(const gfx::Rect& bounds) { | 509 void WmWindow::SetBounds(const gfx::Rect& bounds) { |
| 510 window_->SetBounds(bounds); | 510 window_->SetBounds(bounds); |
| 511 } | 511 } |
| 512 | 512 |
| 513 void WmWindowAura::SetBoundsWithTransitionDelay(const gfx::Rect& bounds, | 513 void WmWindow::SetBoundsWithTransitionDelay(const gfx::Rect& bounds, |
| 514 base::TimeDelta delta) { | 514 base::TimeDelta delta) { |
| 515 if (::wm::WindowAnimationsDisabled(window_)) { | 515 if (::wm::WindowAnimationsDisabled(window_)) { |
| 516 window_->SetBounds(bounds); | 516 window_->SetBounds(bounds); |
| 517 return; | 517 return; |
| 518 } | 518 } |
| 519 | 519 |
| 520 ui::ScopedLayerAnimationSettings settings(window_->layer()->GetAnimator()); | 520 ui::ScopedLayerAnimationSettings settings(window_->layer()->GetAnimator()); |
| 521 settings.SetTransitionDuration(delta); | 521 settings.SetTransitionDuration(delta); |
| 522 window_->SetBounds(bounds); | 522 window_->SetBounds(bounds); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void WmWindowAura::SetBoundsDirect(const gfx::Rect& bounds) { | 525 void WmWindow::SetBoundsDirect(const gfx::Rect& bounds) { |
| 526 BoundsSetter().SetBounds(window_, bounds); | 526 BoundsSetter().SetBounds(window_, bounds); |
| 527 wm::SnapWindowToPixelBoundary(window_); | 527 wm::SnapWindowToPixelBoundary(window_); |
| 528 } | 528 } |
| 529 | 529 |
| 530 void WmWindowAura::SetBoundsDirectAnimated(const gfx::Rect& bounds) { | 530 void WmWindow::SetBoundsDirectAnimated(const gfx::Rect& bounds) { |
| 531 const int kBoundsChangeSlideDurationMs = 120; | 531 const int kBoundsChangeSlideDurationMs = 120; |
| 532 | 532 |
| 533 ui::Layer* layer = window_->layer(); | 533 ui::Layer* layer = window_->layer(); |
| 534 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); | 534 ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); |
| 535 slide_settings.SetPreemptionStrategy( | 535 slide_settings.SetPreemptionStrategy( |
| 536 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 536 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 537 slide_settings.SetTransitionDuration( | 537 slide_settings.SetTransitionDuration( |
| 538 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); | 538 base::TimeDelta::FromMilliseconds(kBoundsChangeSlideDurationMs)); |
| 539 SetBoundsDirect(bounds); | 539 SetBoundsDirect(bounds); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void WmWindowAura::SetBoundsDirectCrossFade(const gfx::Rect& bounds) { | 542 void WmWindow::SetBoundsDirectCrossFade(const gfx::Rect& bounds) { |
| 543 const gfx::Rect old_bounds = window_->bounds(); | 543 const gfx::Rect old_bounds = window_->bounds(); |
| 544 | 544 |
| 545 // Create fresh layers for the window and all its children to paint into. | 545 // Create fresh layers for the window and all its children to paint into. |
| 546 // Takes ownership of the old layer and all its children, which will be | 546 // Takes ownership of the old layer and all its children, which will be |
| 547 // cleaned up after the animation completes. | 547 // cleaned up after the animation completes. |
| 548 // Specify |set_bounds| to true here to keep the old bounds in the child | 548 // Specify |set_bounds| to true here to keep the old bounds in the child |
| 549 // windows of |window|. | 549 // windows of |window|. |
| 550 std::unique_ptr<ui::LayerTreeOwner> old_layer_owner = | 550 std::unique_ptr<ui::LayerTreeOwner> old_layer_owner = |
| 551 ::wm::RecreateLayers(window_); | 551 ::wm::RecreateLayers(window_); |
| 552 ui::Layer* old_layer = old_layer_owner->root(); | 552 ui::Layer* old_layer = old_layer_owner->root(); |
| 553 DCHECK(old_layer); | 553 DCHECK(old_layer); |
| 554 ui::Layer* new_layer = window_->layer(); | 554 ui::Layer* new_layer = window_->layer(); |
| 555 | 555 |
| 556 // Resize the window to the new size, which will force a layout and paint. | 556 // Resize the window to the new size, which will force a layout and paint. |
| 557 SetBoundsDirect(bounds); | 557 SetBoundsDirect(bounds); |
| 558 | 558 |
| 559 // Ensure the higher-resolution layer is on top. | 559 // Ensure the higher-resolution layer is on top. |
| 560 bool old_on_top = (old_bounds.width() > bounds.width()); | 560 bool old_on_top = (old_bounds.width() > bounds.width()); |
| 561 if (old_on_top) | 561 if (old_on_top) |
| 562 old_layer->parent()->StackBelow(new_layer, old_layer); | 562 old_layer->parent()->StackBelow(new_layer, old_layer); |
| 563 else | 563 else |
| 564 old_layer->parent()->StackAbove(new_layer, old_layer); | 564 old_layer->parent()->StackAbove(new_layer, old_layer); |
| 565 | 565 |
| 566 CrossFadeAnimation(window_, std::move(old_layer_owner), gfx::Tween::EASE_OUT); | 566 CrossFadeAnimation(window_, std::move(old_layer_owner), gfx::Tween::EASE_OUT); |
| 567 } | 567 } |
| 568 | 568 |
| 569 void WmWindowAura::SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | 569 void WmWindow::SetBoundsInScreen(const gfx::Rect& bounds_in_screen, |
| 570 const display::Display& dst_display) { | 570 const display::Display& dst_display) { |
| 571 window_->SetBoundsInScreen(bounds_in_screen, dst_display); | 571 window_->SetBoundsInScreen(bounds_in_screen, dst_display); |
| 572 } | 572 } |
| 573 | 573 |
| 574 gfx::Rect WmWindowAura::GetBoundsInScreen() const { | 574 gfx::Rect WmWindow::GetBoundsInScreen() const { |
| 575 return window_->GetBoundsInScreen(); | 575 return window_->GetBoundsInScreen(); |
| 576 } | 576 } |
| 577 | 577 |
| 578 const gfx::Rect& WmWindowAura::GetBounds() const { | 578 const gfx::Rect& WmWindow::GetBounds() const { |
| 579 return window_->bounds(); | 579 return window_->bounds(); |
| 580 } | 580 } |
| 581 | 581 |
| 582 gfx::Rect WmWindowAura::GetTargetBounds() { | 582 gfx::Rect WmWindow::GetTargetBounds() { |
| 583 return window_->GetTargetBounds(); | 583 return window_->GetTargetBounds(); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void WmWindowAura::ClearRestoreBounds() { | 586 void WmWindow::ClearRestoreBounds() { |
| 587 window_->ClearProperty(aura::client::kRestoreBoundsKey); | 587 window_->ClearProperty(aura::client::kRestoreBoundsKey); |
| 588 } | 588 } |
| 589 | 589 |
| 590 void WmWindowAura::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { | 590 void WmWindow::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { |
| 591 window_->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); | 591 window_->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds)); |
| 592 } | 592 } |
| 593 | 593 |
| 594 gfx::Rect WmWindowAura::GetRestoreBoundsInScreen() const { | 594 gfx::Rect WmWindow::GetRestoreBoundsInScreen() const { |
| 595 gfx::Rect* bounds = window_->GetProperty(aura::client::kRestoreBoundsKey); | 595 gfx::Rect* bounds = window_->GetProperty(aura::client::kRestoreBoundsKey); |
| 596 return bounds ? *bounds : gfx::Rect(); | 596 return bounds ? *bounds : gfx::Rect(); |
| 597 } | 597 } |
| 598 | 598 |
| 599 bool WmWindowAura::Contains(const WmWindow* other) const { | 599 bool WmWindow::Contains(const WmWindow* other) const { |
| 600 return other | 600 return other ? window_->Contains(static_cast<const WmWindow*>(other)->window_) |
| 601 ? window_->Contains( | 601 : false; |
| 602 static_cast<const WmWindowAura*>(other)->window_) | |
| 603 : false; | |
| 604 } | 602 } |
| 605 | 603 |
| 606 void WmWindowAura::SetShowState(ui::WindowShowState show_state) { | 604 void WmWindow::SetShowState(ui::WindowShowState show_state) { |
| 607 window_->SetProperty(aura::client::kShowStateKey, show_state); | 605 window_->SetProperty(aura::client::kShowStateKey, show_state); |
| 608 } | 606 } |
| 609 | 607 |
| 610 ui::WindowShowState WmWindowAura::GetShowState() const { | 608 ui::WindowShowState WmWindow::GetShowState() const { |
| 611 return window_->GetProperty(aura::client::kShowStateKey); | 609 return window_->GetProperty(aura::client::kShowStateKey); |
| 612 } | 610 } |
| 613 | 611 |
| 614 void WmWindowAura::SetRestoreShowState(ui::WindowShowState show_state) { | 612 void WmWindow::SetRestoreShowState(ui::WindowShowState show_state) { |
| 615 window_->SetProperty(aura::client::kRestoreShowStateKey, show_state); | 613 window_->SetProperty(aura::client::kRestoreShowStateKey, show_state); |
| 616 } | 614 } |
| 617 | 615 |
| 618 void WmWindowAura::SetRestoreOverrides( | 616 void WmWindow::SetRestoreOverrides(const gfx::Rect& bounds_override, |
| 619 const gfx::Rect& bounds_override, | 617 ui::WindowShowState window_state_override) { |
| 620 ui::WindowShowState window_state_override) { | |
| 621 if (bounds_override.IsEmpty()) { | 618 if (bounds_override.IsEmpty()) { |
| 622 window_->ClearProperty(kRestoreShowStateOverrideKey); | 619 window_->ClearProperty(kRestoreShowStateOverrideKey); |
| 623 window_->ClearProperty(kRestoreBoundsOverrideKey); | 620 window_->ClearProperty(kRestoreBoundsOverrideKey); |
| 624 return; | 621 return; |
| 625 } | 622 } |
| 626 window_->SetProperty(kRestoreShowStateOverrideKey, window_state_override); | 623 window_->SetProperty(kRestoreShowStateOverrideKey, window_state_override); |
| 627 window_->SetProperty(kRestoreBoundsOverrideKey, | 624 window_->SetProperty(kRestoreBoundsOverrideKey, |
| 628 new gfx::Rect(bounds_override)); | 625 new gfx::Rect(bounds_override)); |
| 629 } | 626 } |
| 630 | 627 |
| 631 void WmWindowAura::SetLockedToRoot(bool value) { | 628 void WmWindow::SetLockedToRoot(bool value) { |
| 632 window_->SetProperty(kLockedToRootKey, value); | 629 window_->SetProperty(kLockedToRootKey, value); |
| 633 } | 630 } |
| 634 | 631 |
| 635 bool WmWindowAura::IsLockedToRoot() const { | 632 bool WmWindow::IsLockedToRoot() const { |
| 636 return window_->GetProperty(kLockedToRootKey); | 633 return window_->GetProperty(kLockedToRootKey); |
| 637 } | 634 } |
| 638 | 635 |
| 639 void WmWindowAura::SetCapture() { | 636 void WmWindow::SetCapture() { |
| 640 window_->SetCapture(); | 637 window_->SetCapture(); |
| 641 } | 638 } |
| 642 | 639 |
| 643 bool WmWindowAura::HasCapture() { | 640 bool WmWindow::HasCapture() { |
| 644 return window_->HasCapture(); | 641 return window_->HasCapture(); |
| 645 } | 642 } |
| 646 | 643 |
| 647 void WmWindowAura::ReleaseCapture() { | 644 void WmWindow::ReleaseCapture() { |
| 648 window_->ReleaseCapture(); | 645 window_->ReleaseCapture(); |
| 649 } | 646 } |
| 650 | 647 |
| 651 bool WmWindowAura::HasRestoreBounds() const { | 648 bool WmWindow::HasRestoreBounds() const { |
| 652 return window_->GetProperty(aura::client::kRestoreBoundsKey) != nullptr; | 649 return window_->GetProperty(aura::client::kRestoreBoundsKey) != nullptr; |
| 653 } | 650 } |
| 654 | 651 |
| 655 bool WmWindowAura::CanMaximize() const { | 652 bool WmWindow::CanMaximize() const { |
| 656 return (window_->GetProperty(aura::client::kResizeBehaviorKey) & | 653 return (window_->GetProperty(aura::client::kResizeBehaviorKey) & |
| 657 ui::mojom::kResizeBehaviorCanMaximize) != 0; | 654 ui::mojom::kResizeBehaviorCanMaximize) != 0; |
| 658 } | 655 } |
| 659 | 656 |
| 660 bool WmWindowAura::CanMinimize() const { | 657 bool WmWindow::CanMinimize() const { |
| 661 return (window_->GetProperty(aura::client::kResizeBehaviorKey) & | 658 return (window_->GetProperty(aura::client::kResizeBehaviorKey) & |
| 662 ui::mojom::kResizeBehaviorCanMinimize) != 0; | 659 ui::mojom::kResizeBehaviorCanMinimize) != 0; |
| 663 } | 660 } |
| 664 | 661 |
| 665 bool WmWindowAura::CanResize() const { | 662 bool WmWindow::CanResize() const { |
| 666 return (window_->GetProperty(aura::client::kResizeBehaviorKey) & | 663 return (window_->GetProperty(aura::client::kResizeBehaviorKey) & |
| 667 ui::mojom::kResizeBehaviorCanResize) != 0; | 664 ui::mojom::kResizeBehaviorCanResize) != 0; |
| 668 } | 665 } |
| 669 | 666 |
| 670 bool WmWindowAura::CanActivate() const { | 667 bool WmWindow::CanActivate() const { |
| 671 // TODO(sky): for aura-mus need to key off CanFocus() as well, which is not | 668 // TODO(sky): for aura-mus need to key off CanFocus() as well, which is not |
| 672 // currently mirrored to ash. | 669 // currently mirrored to ash. |
| 673 return ::wm::CanActivateWindow(window_); | 670 return ::wm::CanActivateWindow(window_); |
| 674 } | 671 } |
| 675 | 672 |
| 676 void WmWindowAura::StackChildAtTop(WmWindow* child) { | 673 void WmWindow::StackChildAtTop(WmWindow* child) { |
| 677 window_->StackChildAtTop(GetAuraWindow(child)); | 674 window_->StackChildAtTop(GetAuraWindow(child)); |
| 678 } | 675 } |
| 679 | 676 |
| 680 void WmWindowAura::StackChildAtBottom(WmWindow* child) { | 677 void WmWindow::StackChildAtBottom(WmWindow* child) { |
| 681 window_->StackChildAtBottom(GetAuraWindow(child)); | 678 window_->StackChildAtBottom(GetAuraWindow(child)); |
| 682 } | 679 } |
| 683 | 680 |
| 684 void WmWindowAura::StackChildAbove(WmWindow* child, WmWindow* target) { | 681 void WmWindow::StackChildAbove(WmWindow* child, WmWindow* target) { |
| 685 window_->StackChildAbove(GetAuraWindow(child), GetAuraWindow(target)); | 682 window_->StackChildAbove(GetAuraWindow(child), GetAuraWindow(target)); |
| 686 } | 683 } |
| 687 | 684 |
| 688 void WmWindowAura::StackChildBelow(WmWindow* child, WmWindow* target) { | 685 void WmWindow::StackChildBelow(WmWindow* child, WmWindow* target) { |
| 689 window_->StackChildBelow(GetAuraWindow(child), GetAuraWindow(target)); | 686 window_->StackChildBelow(GetAuraWindow(child), GetAuraWindow(target)); |
| 690 } | 687 } |
| 691 | 688 |
| 692 void WmWindowAura::SetPinned(bool trusted) { | 689 void WmWindow::SetPinned(bool trusted) { |
| 693 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) { | 690 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) { |
| 694 // TODO: fix, see http://crbug.com/622486. With aura-mus pinning may just | 691 // TODO: fix, see http://crbug.com/622486. With aura-mus pinning may just |
| 695 // work. | 692 // work. |
| 696 NOTIMPLEMENTED(); | 693 NOTIMPLEMENTED(); |
| 697 return; | 694 return; |
| 698 } | 695 } |
| 699 wm::PinWindow(window_, trusted); | 696 wm::PinWindow(window_, trusted); |
| 700 } | 697 } |
| 701 | 698 |
| 702 void WmWindowAura::SetAlwaysOnTop(bool value) { | 699 void WmWindow::SetAlwaysOnTop(bool value) { |
| 703 window_->SetProperty(aura::client::kAlwaysOnTopKey, value); | 700 window_->SetProperty(aura::client::kAlwaysOnTopKey, value); |
| 704 } | 701 } |
| 705 | 702 |
| 706 bool WmWindowAura::IsAlwaysOnTop() const { | 703 bool WmWindow::IsAlwaysOnTop() const { |
| 707 return window_->GetProperty(aura::client::kAlwaysOnTopKey); | 704 return window_->GetProperty(aura::client::kAlwaysOnTopKey); |
| 708 } | 705 } |
| 709 | 706 |
| 710 void WmWindowAura::Hide() { | 707 void WmWindow::Hide() { |
| 711 window_->Hide(); | 708 window_->Hide(); |
| 712 } | 709 } |
| 713 | 710 |
| 714 void WmWindowAura::Show() { | 711 void WmWindow::Show() { |
| 715 window_->Show(); | 712 window_->Show(); |
| 716 } | 713 } |
| 717 | 714 |
| 718 views::Widget* WmWindowAura::GetInternalWidget() { | 715 views::Widget* WmWindow::GetInternalWidget() { |
| 719 return window_->GetProperty(kWidgetCreationTypeKey) == | 716 return window_->GetProperty(kWidgetCreationTypeKey) == |
| 720 WidgetCreationType::INTERNAL | 717 WidgetCreationType::INTERNAL |
| 721 ? views::Widget::GetWidgetForNativeView(window_) | 718 ? views::Widget::GetWidgetForNativeView(window_) |
| 722 : nullptr; | 719 : nullptr; |
| 723 } | 720 } |
| 724 | 721 |
| 725 void WmWindowAura::CloseWidget() { | 722 void WmWindow::CloseWidget() { |
| 726 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS && | 723 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS && |
| 727 aura_window()->GetProperty(kWidgetCreationTypeKey) == | 724 aura_window()->GetProperty(kWidgetCreationTypeKey) == |
| 728 WidgetCreationType::FOR_CLIENT) { | 725 WidgetCreationType::FOR_CLIENT) { |
| 729 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated | 726 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated |
| 730 // with the window. Mash only creates widgets for top level windows if mash | 727 // with the window. Mash only creates widgets for top level windows if mash |
| 731 // renders the non-client frame. | 728 // renders the non-client frame. |
| 732 DCHECK(Shell::window_manager_client()); | 729 DCHECK(Shell::window_manager_client()); |
| 733 Shell::window_manager_client()->RequestClose(aura_window()); | 730 Shell::window_manager_client()->RequestClose(aura_window()); |
| 734 return; | 731 return; |
| 735 } | 732 } |
| 736 DCHECK(GetInternalWidget()); | 733 DCHECK(GetInternalWidget()); |
| 737 GetInternalWidget()->Close(); | 734 GetInternalWidget()->Close(); |
| 738 } | 735 } |
| 739 | 736 |
| 740 void WmWindowAura::SetFocused() { | 737 void WmWindow::SetFocused() { |
| 741 aura::client::GetFocusClient(window_)->FocusWindow(window_); | 738 aura::client::GetFocusClient(window_)->FocusWindow(window_); |
| 742 } | 739 } |
| 743 | 740 |
| 744 bool WmWindowAura::IsFocused() const { | 741 bool WmWindow::IsFocused() const { |
| 745 return window_->HasFocus(); | 742 return window_->HasFocus(); |
| 746 } | 743 } |
| 747 | 744 |
| 748 bool WmWindowAura::IsActive() const { | 745 bool WmWindow::IsActive() const { |
| 749 return wm::IsActiveWindow(window_); | 746 return wm::IsActiveWindow(window_); |
| 750 } | 747 } |
| 751 | 748 |
| 752 void WmWindowAura::Activate() { | 749 void WmWindow::Activate() { |
| 753 wm::ActivateWindow(window_); | 750 wm::ActivateWindow(window_); |
| 754 } | 751 } |
| 755 | 752 |
| 756 void WmWindowAura::Deactivate() { | 753 void WmWindow::Deactivate() { |
| 757 wm::DeactivateWindow(window_); | 754 wm::DeactivateWindow(window_); |
| 758 } | 755 } |
| 759 | 756 |
| 760 void WmWindowAura::SetFullscreen() { | 757 void WmWindow::SetFullscreen() { |
| 761 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 758 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 762 } | 759 } |
| 763 | 760 |
| 764 void WmWindowAura::Maximize() { | 761 void WmWindow::Maximize() { |
| 765 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 762 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 766 } | 763 } |
| 767 | 764 |
| 768 void WmWindowAura::Minimize() { | 765 void WmWindow::Minimize() { |
| 769 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 766 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 770 } | 767 } |
| 771 | 768 |
| 772 void WmWindowAura::Unminimize() { | 769 void WmWindow::Unminimize() { |
| 773 window_->SetProperty( | 770 window_->SetProperty( |
| 774 aura::client::kShowStateKey, | 771 aura::client::kShowStateKey, |
| 775 window_->GetProperty(aura::client::kRestoreShowStateKey)); | 772 window_->GetProperty(aura::client::kRestoreShowStateKey)); |
| 776 window_->ClearProperty(aura::client::kRestoreShowStateKey); | 773 window_->ClearProperty(aura::client::kRestoreShowStateKey); |
| 777 } | 774 } |
| 778 | 775 |
| 779 std::vector<WmWindow*> WmWindowAura::GetChildren() { | 776 std::vector<WmWindow*> WmWindow::GetChildren() { |
| 780 return FromAuraWindows(window_->children()); | 777 return FromAuraWindows(window_->children()); |
| 781 } | 778 } |
| 782 | 779 |
| 783 WmWindow* WmWindowAura::GetChildByShellWindowId(int id) { | 780 WmWindow* WmWindow::GetChildByShellWindowId(int id) { |
| 784 return Get(window_->GetChildById(id)); | 781 return Get(window_->GetChildById(id)); |
| 785 } | 782 } |
| 786 | 783 |
| 787 void WmWindowAura::ShowResizeShadow(int component) { | 784 void WmWindow::ShowResizeShadow(int component) { |
| 788 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) { | 785 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) { |
| 789 // TODO: http://crbug.com/640773. | 786 // TODO: http://crbug.com/640773. |
| 790 return; | 787 return; |
| 791 } | 788 } |
| 792 ResizeShadowController* resize_shadow_controller = | 789 ResizeShadowController* resize_shadow_controller = |
| 793 Shell::GetInstance()->resize_shadow_controller(); | 790 Shell::GetInstance()->resize_shadow_controller(); |
| 794 if (resize_shadow_controller) | 791 if (resize_shadow_controller) |
| 795 resize_shadow_controller->ShowShadow(window_, component); | 792 resize_shadow_controller->ShowShadow(window_, component); |
| 796 } | 793 } |
| 797 | 794 |
| 798 void WmWindowAura::HideResizeShadow() { | 795 void WmWindow::HideResizeShadow() { |
| 799 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) { | 796 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) { |
| 800 // TODO: http://crbug.com/640773. | 797 // TODO: http://crbug.com/640773. |
| 801 return; | 798 return; |
| 802 } | 799 } |
| 803 ResizeShadowController* resize_shadow_controller = | 800 ResizeShadowController* resize_shadow_controller = |
| 804 Shell::GetInstance()->resize_shadow_controller(); | 801 Shell::GetInstance()->resize_shadow_controller(); |
| 805 if (resize_shadow_controller) | 802 if (resize_shadow_controller) |
| 806 resize_shadow_controller->HideShadow(window_); | 803 resize_shadow_controller->HideShadow(window_); |
| 807 } | 804 } |
| 808 | 805 |
| 809 void WmWindowAura::InstallResizeHandleWindowTargeter( | 806 void WmWindow::InstallResizeHandleWindowTargeter( |
| 810 ImmersiveFullscreenController* immersive_fullscreen_controller) { | 807 ImmersiveFullscreenController* immersive_fullscreen_controller) { |
| 811 window_->SetEventTargeter(base::MakeUnique<ResizeHandleWindowTargeter>( | 808 window_->SetEventTargeter(base::MakeUnique<ResizeHandleWindowTargeter>( |
| 812 window_, immersive_fullscreen_controller)); | 809 window_, immersive_fullscreen_controller)); |
| 813 } | 810 } |
| 814 | 811 |
| 815 void WmWindowAura::SetBoundsInScreenBehaviorForChildren( | 812 void WmWindow::SetBoundsInScreenBehaviorForChildren( |
| 816 BoundsInScreenBehavior behavior) { | 813 BoundsInScreenBehavior behavior) { |
| 817 window_->SetProperty( | 814 window_->SetProperty( |
| 818 kUsesScreenCoordinatesKey, | 815 kUsesScreenCoordinatesKey, |
| 819 behavior == BoundsInScreenBehavior::USE_SCREEN_COORDINATES); | 816 behavior == BoundsInScreenBehavior::USE_SCREEN_COORDINATES); |
| 820 } | 817 } |
| 821 | 818 |
| 822 void WmWindowAura::SetSnapsChildrenToPhysicalPixelBoundary() { | 819 void WmWindow::SetSnapsChildrenToPhysicalPixelBoundary() { |
| 823 wm::SetSnapsChildrenToPhysicalPixelBoundary(window_); | 820 wm::SetSnapsChildrenToPhysicalPixelBoundary(window_); |
| 824 } | 821 } |
| 825 | 822 |
| 826 void WmWindowAura::SnapToPixelBoundaryIfNecessary() { | 823 void WmWindow::SnapToPixelBoundaryIfNecessary() { |
| 827 wm::SnapWindowToPixelBoundary(window_); | 824 wm::SnapWindowToPixelBoundary(window_); |
| 828 } | 825 } |
| 829 | 826 |
| 830 void WmWindowAura::SetChildrenUseExtendedHitRegion() { | 827 void WmWindow::SetChildrenUseExtendedHitRegion() { |
| 831 children_use_extended_hit_region_ = true; | 828 children_use_extended_hit_region_ = true; |
| 832 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, | 829 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, |
| 833 -kResizeOutsideBoundsSize, | 830 -kResizeOutsideBoundsSize, |
| 834 -kResizeOutsideBoundsSize); | 831 -kResizeOutsideBoundsSize); |
| 835 gfx::Insets touch_extend = | 832 gfx::Insets touch_extend = |
| 836 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); | 833 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); |
| 837 // TODO: EasyResizeWindowTargeter makes it so children get events outside | 834 // TODO: EasyResizeWindowTargeter makes it so children get events outside |
| 838 // their bounds. This only works in mash when mash is providing the non-client | 835 // their bounds. This only works in mash when mash is providing the non-client |
| 839 // frame. Mus needs to support an api for the WindowManager that enables | 836 // frame. Mus needs to support an api for the WindowManager that enables |
| 840 // events to be dispatched to windows outside the windows bounds that this | 837 // events to be dispatched to windows outside the windows bounds that this |
| 841 // function calls into. http://crbug.com/679056. | 838 // function calls into. http://crbug.com/679056. |
| 842 window_->SetEventTargeter(base::MakeUnique<::wm::EasyResizeWindowTargeter>( | 839 window_->SetEventTargeter(base::MakeUnique<::wm::EasyResizeWindowTargeter>( |
| 843 window_, mouse_extend, touch_extend)); | 840 window_, mouse_extend, touch_extend)); |
| 844 } | 841 } |
| 845 | 842 |
| 846 std::unique_ptr<views::View> WmWindowAura::CreateViewWithRecreatedLayers() { | 843 std::unique_ptr<views::View> WmWindow::CreateViewWithRecreatedLayers() { |
| 847 return base::MakeUnique<wm::WindowMirrorView>(this); | 844 return base::MakeUnique<wm::WindowMirrorView>(this); |
| 848 } | 845 } |
| 849 | 846 |
| 850 void WmWindowAura::AddObserver(WmWindowObserver* observer) { | 847 void WmWindow::AddObserver(WmWindowObserver* observer) { |
| 851 observers_.AddObserver(observer); | 848 observers_.AddObserver(observer); |
| 852 } | 849 } |
| 853 | 850 |
| 854 void WmWindowAura::RemoveObserver(WmWindowObserver* observer) { | 851 void WmWindow::RemoveObserver(WmWindowObserver* observer) { |
| 855 observers_.RemoveObserver(observer); | 852 observers_.RemoveObserver(observer); |
| 856 } | 853 } |
| 857 | 854 |
| 858 bool WmWindowAura::HasObserver(const WmWindowObserver* observer) const { | 855 bool WmWindow::HasObserver(const WmWindowObserver* observer) const { |
| 859 return observers_.HasObserver(observer); | 856 return observers_.HasObserver(observer); |
| 860 } | 857 } |
| 861 | 858 |
| 862 void WmWindowAura::AddTransientWindowObserver( | 859 void WmWindow::AddTransientWindowObserver(WmTransientWindowObserver* observer) { |
| 863 WmTransientWindowObserver* observer) { | |
| 864 if (!added_transient_observer_) { | 860 if (!added_transient_observer_) { |
| 865 added_transient_observer_ = true; | 861 added_transient_observer_ = true; |
| 866 ::wm::TransientWindowManager::Get(window_)->AddObserver(this); | 862 ::wm::TransientWindowManager::Get(window_)->AddObserver(this); |
| 867 } | 863 } |
| 868 transient_observers_.AddObserver(observer); | 864 transient_observers_.AddObserver(observer); |
| 869 } | 865 } |
| 870 | 866 |
| 871 void WmWindowAura::RemoveTransientWindowObserver( | 867 void WmWindow::RemoveTransientWindowObserver( |
| 872 WmTransientWindowObserver* observer) { | 868 WmTransientWindowObserver* observer) { |
| 873 transient_observers_.RemoveObserver(observer); | 869 transient_observers_.RemoveObserver(observer); |
| 874 if (added_transient_observer_ && | 870 if (added_transient_observer_ && |
| 875 !transient_observers_.might_have_observers()) { | 871 !transient_observers_.might_have_observers()) { |
| 876 added_transient_observer_ = false; | 872 added_transient_observer_ = false; |
| 877 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); | 873 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); |
| 878 } | 874 } |
| 879 } | 875 } |
| 880 | 876 |
| 881 void WmWindowAura::AddLimitedPreTargetHandler(ui::EventHandler* handler) { | 877 void WmWindow::AddLimitedPreTargetHandler(ui::EventHandler* handler) { |
| 882 // In mus AddPreTargetHandler() only works for windows created by this client. | 878 // In mus AddPreTargetHandler() only works for windows created by this client. |
| 883 DCHECK(aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL || | 879 DCHECK(aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL || |
| 884 Shell::window_tree_client()->WasCreatedByThisClient( | 880 Shell::window_tree_client()->WasCreatedByThisClient( |
| 885 aura::WindowMus::Get(window_))); | 881 aura::WindowMus::Get(window_))); |
| 886 window_->AddPreTargetHandler(handler); | 882 window_->AddPreTargetHandler(handler); |
| 887 } | 883 } |
| 888 | 884 |
| 889 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { | 885 void WmWindow::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { |
| 890 window_->RemovePreTargetHandler(handler); | 886 window_->RemovePreTargetHandler(handler); |
| 891 } | 887 } |
| 892 | 888 |
| 893 WmWindowAura::WmWindowAura(aura::Window* window) | 889 WmWindow::WmWindow(aura::Window* window) |
| 894 : window_(window), | 890 : window_(window), |
| 895 // Mirrors that of aura::Window. | 891 // Mirrors that of aura::Window. |
| 896 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY), | 892 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY), |
| 897 use_empty_minimum_size_for_testing_( | 893 use_empty_minimum_size_for_testing_( |
| 898 default_use_empty_minimum_size_for_testing_) { | 894 default_use_empty_minimum_size_for_testing_) { |
| 899 window_->AddObserver(this); | 895 window_->AddObserver(this); |
| 900 window_->SetProperty(kWmWindowKey, this); | 896 window_->SetProperty(kWmWindowKey, this); |
| 901 } | 897 } |
| 902 | 898 |
| 903 // static | 899 void WmWindow::OnWindowHierarchyChanging(const HierarchyChangeParams& params) { |
| 904 bool WmWindowAura::HasInstance(const aura::Window* window) { | |
| 905 return window->GetProperty(kWmWindowKey) != nullptr; | |
| 906 } | |
| 907 | |
| 908 void WmWindowAura::OnWindowHierarchyChanging( | |
| 909 const HierarchyChangeParams& params) { | |
| 910 WmWindowObserver::TreeChangeParams wm_params; | 900 WmWindowObserver::TreeChangeParams wm_params; |
| 911 wm_params.target = Get(params.target); | 901 wm_params.target = Get(params.target); |
| 912 wm_params.new_parent = Get(params.new_parent); | 902 wm_params.new_parent = Get(params.new_parent); |
| 913 wm_params.old_parent = Get(params.old_parent); | 903 wm_params.old_parent = Get(params.old_parent); |
| 914 for (auto& observer : observers_) | 904 for (auto& observer : observers_) |
| 915 observer.OnWindowTreeChanging(this, wm_params); | 905 observer.OnWindowTreeChanging(this, wm_params); |
| 916 } | 906 } |
| 917 | 907 |
| 918 void WmWindowAura::OnWindowHierarchyChanged( | 908 void WmWindow::OnWindowHierarchyChanged(const HierarchyChangeParams& params) { |
| 919 const HierarchyChangeParams& params) { | |
| 920 WmWindowObserver::TreeChangeParams wm_params; | 909 WmWindowObserver::TreeChangeParams wm_params; |
| 921 wm_params.target = Get(params.target); | 910 wm_params.target = Get(params.target); |
| 922 wm_params.new_parent = Get(params.new_parent); | 911 wm_params.new_parent = Get(params.new_parent); |
| 923 wm_params.old_parent = Get(params.old_parent); | 912 wm_params.old_parent = Get(params.old_parent); |
| 924 for (auto& observer : observers_) | 913 for (auto& observer : observers_) |
| 925 observer.OnWindowTreeChanged(this, wm_params); | 914 observer.OnWindowTreeChanged(this, wm_params); |
| 926 } | 915 } |
| 927 | 916 |
| 928 void WmWindowAura::OnWindowStackingChanged(aura::Window* window) { | 917 void WmWindow::OnWindowStackingChanged(aura::Window* window) { |
| 929 for (auto& observer : observers_) | 918 for (auto& observer : observers_) |
| 930 observer.OnWindowStackingChanged(this); | 919 observer.OnWindowStackingChanged(this); |
| 931 } | 920 } |
| 932 | 921 |
| 933 void WmWindowAura::OnWindowPropertyChanged(aura::Window* window, | 922 void WmWindow::OnWindowPropertyChanged(aura::Window* window, |
| 934 const void* key, | 923 const void* key, |
| 935 intptr_t old) { | 924 intptr_t old) { |
| 936 if (key == aura::client::kShowStateKey) { | 925 if (key == aura::client::kShowStateKey) { |
| 937 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged(); | 926 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged(); |
| 938 return; | 927 return; |
| 939 } | 928 } |
| 940 WmWindowProperty wm_property; | 929 WmWindowProperty wm_property; |
| 941 if (key == aura::client::kAlwaysOnTopKey) { | 930 if (key == aura::client::kAlwaysOnTopKey) { |
| 942 wm_property = WmWindowProperty::ALWAYS_ON_TOP; | 931 wm_property = WmWindowProperty::ALWAYS_ON_TOP; |
| 943 } else if (key == aura::client::kAppIconKey) { | 932 } else if (key == aura::client::kAppIconKey) { |
| 944 wm_property = WmWindowProperty::APP_ICON; | 933 wm_property = WmWindowProperty::APP_ICON; |
| 945 } else if (key == aura::client::kDrawAttentionKey) { | 934 } else if (key == aura::client::kDrawAttentionKey) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 958 wm_property = WmWindowProperty::TOP_VIEW_INSET; | 947 wm_property = WmWindowProperty::TOP_VIEW_INSET; |
| 959 } else if (key == aura::client::kWindowIconKey) { | 948 } else if (key == aura::client::kWindowIconKey) { |
| 960 wm_property = WmWindowProperty::WINDOW_ICON; | 949 wm_property = WmWindowProperty::WINDOW_ICON; |
| 961 } else { | 950 } else { |
| 962 return; | 951 return; |
| 963 } | 952 } |
| 964 for (auto& observer : observers_) | 953 for (auto& observer : observers_) |
| 965 observer.OnWindowPropertyChanged(this, wm_property); | 954 observer.OnWindowPropertyChanged(this, wm_property); |
| 966 } | 955 } |
| 967 | 956 |
| 968 void WmWindowAura::OnWindowBoundsChanged(aura::Window* window, | 957 void WmWindow::OnWindowBoundsChanged(aura::Window* window, |
| 969 const gfx::Rect& old_bounds, | 958 const gfx::Rect& old_bounds, |
| 970 const gfx::Rect& new_bounds) { | 959 const gfx::Rect& new_bounds) { |
| 971 for (auto& observer : observers_) | 960 for (auto& observer : observers_) |
| 972 observer.OnWindowBoundsChanged(this, old_bounds, new_bounds); | 961 observer.OnWindowBoundsChanged(this, old_bounds, new_bounds); |
| 973 } | 962 } |
| 974 | 963 |
| 975 void WmWindowAura::OnWindowDestroying(aura::Window* window) { | 964 void WmWindow::OnWindowDestroying(aura::Window* window) { |
| 976 for (auto& observer : observers_) | 965 for (auto& observer : observers_) |
| 977 observer.OnWindowDestroying(this); | 966 observer.OnWindowDestroying(this); |
| 978 } | 967 } |
| 979 | 968 |
| 980 void WmWindowAura::OnWindowDestroyed(aura::Window* window) { | 969 void WmWindow::OnWindowDestroyed(aura::Window* window) { |
| 981 for (auto& observer : observers_) | 970 for (auto& observer : observers_) |
| 982 observer.OnWindowDestroyed(this); | 971 observer.OnWindowDestroyed(this); |
| 983 } | 972 } |
| 984 | 973 |
| 985 void WmWindowAura::OnWindowVisibilityChanging(aura::Window* window, | 974 void WmWindow::OnWindowVisibilityChanging(aura::Window* window, bool visible) { |
| 986 bool visible) { | |
| 987 DCHECK_EQ(window, window_); | 975 DCHECK_EQ(window, window_); |
| 988 for (auto& observer : observers_) | 976 for (auto& observer : observers_) |
| 989 observer.OnWindowVisibilityChanging(this, visible); | 977 observer.OnWindowVisibilityChanging(this, visible); |
| 990 } | 978 } |
| 991 | 979 |
| 992 void WmWindowAura::OnWindowVisibilityChanged(aura::Window* window, | 980 void WmWindow::OnWindowVisibilityChanged(aura::Window* window, bool visible) { |
| 993 bool visible) { | |
| 994 for (auto& observer : observers_) | 981 for (auto& observer : observers_) |
| 995 observer.OnWindowVisibilityChanged(Get(window), visible); | 982 observer.OnWindowVisibilityChanged(Get(window), visible); |
| 996 } | 983 } |
| 997 | 984 |
| 998 void WmWindowAura::OnWindowTitleChanged(aura::Window* window) { | 985 void WmWindow::OnWindowTitleChanged(aura::Window* window) { |
| 999 for (auto& observer : observers_) | 986 for (auto& observer : observers_) |
| 1000 observer.OnWindowTitleChanged(this); | 987 observer.OnWindowTitleChanged(this); |
| 1001 } | 988 } |
| 1002 | 989 |
| 1003 void WmWindowAura::OnTransientChildAdded(aura::Window* window, | 990 void WmWindow::OnTransientChildAdded(aura::Window* window, |
| 1004 aura::Window* transient) { | 991 aura::Window* transient) { |
| 1005 for (auto& observer : transient_observers_) | 992 for (auto& observer : transient_observers_) |
| 1006 observer.OnTransientChildAdded(this, Get(transient)); | 993 observer.OnTransientChildAdded(this, Get(transient)); |
| 1007 } | 994 } |
| 1008 | 995 |
| 1009 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, | 996 void WmWindow::OnTransientChildRemoved(aura::Window* window, |
| 1010 aura::Window* transient) { | 997 aura::Window* transient) { |
| 1011 for (auto& observer : transient_observers_) | 998 for (auto& observer : transient_observers_) |
| 1012 observer.OnTransientChildRemoved(this, Get(transient)); | 999 observer.OnTransientChildRemoved(this, Get(transient)); |
| 1013 } | 1000 } |
| 1014 | 1001 |
| 1015 } // namespace ash | 1002 } // namespace ash |
| OLD | NEW |