| 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/mus/bridge/wm_window_mus.h" | 5 #include "ash/mus/bridge/wm_window_mus.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/container_finder.h" | 7 #include "ash/common/wm/container_finder.h" |
| 8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 9 #include "ash/common/wm/wm_layout_manager.h" | 9 #include "ash/common/wm_layout_manager.h" |
| 10 #include "ash/common/wm/wm_window_observer.h" | 10 #include "ash/common/wm_window_observer.h" |
| 11 #include "ash/common/wm/wm_window_property.h" | 11 #include "ash/common/wm_window_property.h" |
| 12 #include "ash/mus/bridge/mus_layout_manager_adapter.h" | 12 #include "ash/mus/bridge/mus_layout_manager_adapter.h" |
| 13 #include "ash/mus/bridge/wm_globals_mus.h" | |
| 14 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 13 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
| 14 #include "ash/mus/bridge/wm_shell_mus.h" |
| 15 #include "ash/mus/property_util.h" | 15 #include "ash/mus/property_util.h" |
| 16 #include "components/mus/public/cpp/property_type_converters.h" | 16 #include "components/mus/public/cpp/property_type_converters.h" |
| 17 #include "components/mus/public/cpp/window.h" | 17 #include "components/mus/public/cpp/window.h" |
| 18 #include "components/mus/public/cpp/window_property.h" | 18 #include "components/mus/public/cpp/window_property.h" |
| 19 #include "components/mus/public/cpp/window_tree_client.h" | 19 #include "components/mus/public/cpp/window_tree_client.h" |
| 20 #include "components/mus/public/interfaces/window_manager.mojom.h" | 20 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 21 #include "ui/aura/mus/mus_util.h" | 21 #include "ui/aura/mus/mus_util.h" |
| 22 #include "ui/base/hit_test.h" | 22 #include "ui/base/hit_test.h" |
| 23 #include "ui/display/display.h" | 23 #include "ui/display/display.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 namespace ash { | 41 namespace ash { |
| 42 namespace mus { | 42 namespace mus { |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 // This classes is used so that the WindowState constructor can be made | 46 // This classes is used so that the WindowState constructor can be made |
| 47 // protected. GetWindowState() is the only place that should be creating | 47 // protected. GetWindowState() is the only place that should be creating |
| 48 // WindowState. | 48 // WindowState. |
| 49 class WindowStateMus : public wm::WindowState { | 49 class WindowStateMus : public wm::WindowState { |
| 50 public: | 50 public: |
| 51 explicit WindowStateMus(wm::WmWindow* window) : wm::WindowState(window) {} | 51 explicit WindowStateMus(WmWindow* window) : wm::WindowState(window) {} |
| 52 ~WindowStateMus() override {} | 52 ~WindowStateMus() override {} |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); | 55 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 ui::WindowShowState UIWindowShowStateFromMojom(::mus::mojom::ShowState state) { | 58 ui::WindowShowState UIWindowShowStateFromMojom(::mus::mojom::ShowState state) { |
| 59 switch (state) { | 59 switch (state) { |
| 60 case ::mus::mojom::ShowState::DEFAULT: | 60 case ::mus::mojom::ShowState::DEFAULT: |
| 61 return ui::SHOW_STATE_DEFAULT; | 61 return ui::SHOW_STATE_DEFAULT; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 break; | 97 break; |
| 98 } | 98 } |
| 99 return ::mus::mojom::ShowState::DEFAULT; | 99 return ::mus::mojom::ShowState::DEFAULT; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace | 102 } // namespace |
| 103 | 103 |
| 104 WmWindowMus::WmWindowMus(::mus::Window* window) | 104 WmWindowMus::WmWindowMus(::mus::Window* window) |
| 105 : window_(window), | 105 : window_(window), |
| 106 // Matches aura, see aura::Window for details. | 106 // Matches aura, see aura::Window for details. |
| 107 observers_( | 107 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 108 base::ObserverList<wm::WmWindowObserver>::NOTIFY_EXISTING_ONLY) { | |
| 109 window_->AddObserver(this); | 108 window_->AddObserver(this); |
| 110 window_->SetLocalProperty(kWmWindowKey, this); | 109 window_->SetLocalProperty(kWmWindowKey, this); |
| 111 window_state_.reset(new WindowStateMus(this)); | 110 window_state_.reset(new WindowStateMus(this)); |
| 112 } | 111 } |
| 113 | 112 |
| 114 WmWindowMus::~WmWindowMus() { | 113 WmWindowMus::~WmWindowMus() { |
| 115 window_->RemoveObserver(this); | 114 window_->RemoveObserver(this); |
| 116 } | 115 } |
| 117 | 116 |
| 118 // static | 117 // static |
| 119 WmWindowMus* WmWindowMus::Get(::mus::Window* window) { | 118 WmWindowMus* WmWindowMus::Get(::mus::Window* window) { |
| 120 if (!window) | 119 if (!window) |
| 121 return nullptr; | 120 return nullptr; |
| 122 | 121 |
| 123 WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); | 122 WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); |
| 124 if (wm_window) | 123 if (wm_window) |
| 125 return wm_window; | 124 return wm_window; |
| 126 // WmWindowMus is owned by the mus::Window. | 125 // WmWindowMus is owned by the mus::Window. |
| 127 return new WmWindowMus(window); | 126 return new WmWindowMus(window); |
| 128 } | 127 } |
| 129 | 128 |
| 130 // static | 129 // static |
| 131 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { | 130 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { |
| 132 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); | 131 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); |
| 133 } | 132 } |
| 134 | 133 |
| 135 // static | 134 // static |
| 136 const ::mus::Window* WmWindowMus::GetMusWindow(const wm::WmWindow* wm_window) { | 135 const ::mus::Window* WmWindowMus::GetMusWindow(const WmWindow* wm_window) { |
| 137 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); | 136 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); |
| 138 } | 137 } |
| 139 | 138 |
| 140 // static | 139 // static |
| 141 std::vector<wm::WmWindow*> WmWindowMus::FromMusWindows( | 140 std::vector<WmWindow*> WmWindowMus::FromMusWindows( |
| 142 const std::vector<::mus::Window*>& mus_windows) { | 141 const std::vector<::mus::Window*>& mus_windows) { |
| 143 std::vector<wm::WmWindow*> result(mus_windows.size()); | 142 std::vector<WmWindow*> result(mus_windows.size()); |
| 144 for (size_t i = 0; i < mus_windows.size(); ++i) | 143 for (size_t i = 0; i < mus_windows.size(); ++i) |
| 145 result[i] = Get(mus_windows[i]); | 144 result[i] = Get(mus_windows[i]); |
| 146 return result; | 145 return result; |
| 147 } | 146 } |
| 148 | 147 |
| 149 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() | 148 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() |
| 150 const { | 149 const { |
| 151 return WmRootWindowControllerMus::Get(window_->GetRoot()); | 150 return WmRootWindowControllerMus::Get(window_->GetRoot()); |
| 152 } | 151 } |
| 153 | 152 |
| 154 bool WmWindowMus::ShouldUseExtendedHitRegion() const { | 153 bool WmWindowMus::ShouldUseExtendedHitRegion() const { |
| 155 const WmWindowMus* parent = Get(window_->parent()); | 154 const WmWindowMus* parent = Get(window_->parent()); |
| 156 return parent && parent->children_use_extended_hit_region_; | 155 return parent && parent->children_use_extended_hit_region_; |
| 157 } | 156 } |
| 158 | 157 |
| 159 const wm::WmWindow* WmWindowMus::GetRootWindow() const { | 158 const WmWindow* WmWindowMus::GetRootWindow() const { |
| 160 return Get(window_->GetRoot()); | 159 return Get(window_->GetRoot()); |
| 161 } | 160 } |
| 162 | 161 |
| 163 wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { | 162 WmRootWindowController* WmWindowMus::GetRootWindowController() { |
| 164 return GetRootWindowControllerMus(); | 163 return GetRootWindowControllerMus(); |
| 165 } | 164 } |
| 166 | 165 |
| 167 wm::WmGlobals* WmWindowMus::GetGlobals() const { | 166 WmShell* WmWindowMus::GetShell() const { |
| 168 return WmGlobalsMus::Get(); | 167 return WmShellMus::Get(); |
| 169 } | 168 } |
| 170 | 169 |
| 171 void WmWindowMus::SetName(const char* name) { | 170 void WmWindowMus::SetName(const char* name) { |
| 172 if (name) { | 171 if (name) { |
| 173 window_->SetSharedProperty<std::string>( | 172 window_->SetSharedProperty<std::string>( |
| 174 ::mus::mojom::WindowManager::kName_Property, std::string(name)); | 173 ::mus::mojom::WindowManager::kName_Property, std::string(name)); |
| 175 } else { | 174 } else { |
| 176 window_->ClearSharedProperty(::mus::mojom::WindowManager::kName_Property); | 175 window_->ClearSharedProperty(::mus::mojom::WindowManager::kName_Property); |
| 177 } | 176 } |
| 178 } | 177 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 gfx::Transform WmWindowMus::GetTargetTransform() const { | 288 gfx::Transform WmWindowMus::GetTargetTransform() const { |
| 290 // TODO: need animation support: http://crbug.com/615087. | 289 // TODO: need animation support: http://crbug.com/615087. |
| 291 return gfx::Transform(); | 290 return gfx::Transform(); |
| 292 } | 291 } |
| 293 | 292 |
| 294 bool WmWindowMus::IsSystemModal() const { | 293 bool WmWindowMus::IsSystemModal() const { |
| 295 NOTIMPLEMENTED(); | 294 NOTIMPLEMENTED(); |
| 296 return false; | 295 return false; |
| 297 } | 296 } |
| 298 | 297 |
| 299 bool WmWindowMus::GetBoolProperty(wm::WmWindowProperty key) { | 298 bool WmWindowMus::GetBoolProperty(WmWindowProperty key) { |
| 300 switch (key) { | 299 switch (key) { |
| 301 case wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: | 300 case WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: |
| 302 return snap_children_to_pixel_boundary_; | 301 return snap_children_to_pixel_boundary_; |
| 303 | 302 |
| 304 case wm::WmWindowProperty::ALWAYS_ON_TOP: | 303 case WmWindowProperty::ALWAYS_ON_TOP: |
| 305 return IsAlwaysOnTop(); | 304 return IsAlwaysOnTop(); |
| 306 | 305 |
| 307 default: | 306 default: |
| 308 NOTREACHED(); | 307 NOTREACHED(); |
| 309 break; | 308 break; |
| 310 } | 309 } |
| 311 | 310 |
| 312 NOTREACHED(); | 311 NOTREACHED(); |
| 313 return false; | 312 return false; |
| 314 } | 313 } |
| 315 | 314 |
| 316 int WmWindowMus::GetIntProperty(wm::WmWindowProperty key) { | 315 int WmWindowMus::GetIntProperty(WmWindowProperty key) { |
| 317 if (key == wm::WmWindowProperty::SHELF_ID) { | 316 if (key == WmWindowProperty::SHELF_ID) { |
| 318 NOTIMPLEMENTED(); | 317 NOTIMPLEMENTED(); |
| 319 return 0; | 318 return 0; |
| 320 } | 319 } |
| 321 | 320 |
| 322 if (key == wm::WmWindowProperty::TOP_VIEW_INSET) { | 321 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| 323 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. | 322 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. |
| 324 NOTIMPLEMENTED(); | 323 NOTIMPLEMENTED(); |
| 325 return 0; | 324 return 0; |
| 326 } | 325 } |
| 327 | 326 |
| 328 NOTREACHED(); | 327 NOTREACHED(); |
| 329 return 0; | 328 return 0; |
| 330 } | 329 } |
| 331 | 330 |
| 332 const wm::WindowState* WmWindowMus::GetWindowState() const { | 331 const wm::WindowState* WmWindowMus::GetWindowState() const { |
| 333 return window_state_.get(); | 332 return window_state_.get(); |
| 334 } | 333 } |
| 335 | 334 |
| 336 wm::WmWindow* WmWindowMus::GetToplevelWindow() { | 335 WmWindow* WmWindowMus::GetToplevelWindow() { |
| 337 return WmGlobalsMus::GetToplevelAncestor(window_); | 336 return WmShellMus::GetToplevelAncestor(window_); |
| 338 } | 337 } |
| 339 | 338 |
| 340 void WmWindowMus::SetParentUsingContext(WmWindow* context, | 339 void WmWindowMus::SetParentUsingContext(WmWindow* context, |
| 341 const gfx::Rect& screen_bounds) { | 340 const gfx::Rect& screen_bounds) { |
| 342 GetDefaultParent(context, this, screen_bounds)->AddChild(this); | 341 wm::GetDefaultParent(context, this, screen_bounds)->AddChild(this); |
| 343 } | 342 } |
| 344 | 343 |
| 345 void WmWindowMus::AddChild(WmWindow* window) { | 344 void WmWindowMus::AddChild(WmWindow* window) { |
| 346 window_->AddChild(GetMusWindow(window)); | 345 window_->AddChild(GetMusWindow(window)); |
| 347 } | 346 } |
| 348 | 347 |
| 349 wm::WmWindow* WmWindowMus::GetParent() { | 348 WmWindow* WmWindowMus::GetParent() { |
| 350 return Get(window_->parent()); | 349 return Get(window_->parent()); |
| 351 } | 350 } |
| 352 | 351 |
| 353 const wm::WmWindow* WmWindowMus::GetTransientParent() const { | 352 const WmWindow* WmWindowMus::GetTransientParent() const { |
| 354 return Get(window_->transient_parent()); | 353 return Get(window_->transient_parent()); |
| 355 } | 354 } |
| 356 | 355 |
| 357 std::vector<wm::WmWindow*> WmWindowMus::GetTransientChildren() { | 356 std::vector<WmWindow*> WmWindowMus::GetTransientChildren() { |
| 358 return FromMusWindows(window_->transient_children()); | 357 return FromMusWindows(window_->transient_children()); |
| 359 } | 358 } |
| 360 | 359 |
| 361 void WmWindowMus::SetLayoutManager( | 360 void WmWindowMus::SetLayoutManager( |
| 362 std::unique_ptr<wm::WmLayoutManager> layout_manager) { | 361 std::unique_ptr<WmLayoutManager> layout_manager) { |
| 363 if (layout_manager) { | 362 if (layout_manager) { |
| 364 layout_manager_adapter_.reset( | 363 layout_manager_adapter_.reset( |
| 365 new MusLayoutManagerAdapter(window_, std::move(layout_manager))); | 364 new MusLayoutManagerAdapter(window_, std::move(layout_manager))); |
| 366 } else { | 365 } else { |
| 367 layout_manager_adapter_.reset(); | 366 layout_manager_adapter_.reset(); |
| 368 } | 367 } |
| 369 } | 368 } |
| 370 | 369 |
| 371 wm::WmLayoutManager* WmWindowMus::GetLayoutManager() { | 370 WmLayoutManager* WmWindowMus::GetLayoutManager() { |
| 372 return layout_manager_adapter_ ? layout_manager_adapter_->layout_manager() | 371 return layout_manager_adapter_ ? layout_manager_adapter_->layout_manager() |
| 373 : nullptr; | 372 : nullptr; |
| 374 } | 373 } |
| 375 | 374 |
| 376 void WmWindowMus::SetVisibilityAnimationType(int type) { | 375 void WmWindowMus::SetVisibilityAnimationType(int type) { |
| 377 // TODO: need animation support: http://crbug.com/615087. | 376 // TODO: need animation support: http://crbug.com/615087. |
| 378 NOTIMPLEMENTED(); | 377 NOTIMPLEMENTED(); |
| 379 } | 378 } |
| 380 | 379 |
| 381 void WmWindowMus::SetVisibilityAnimationDuration(base::TimeDelta delta) { | 380 void WmWindowMus::SetVisibilityAnimationDuration(base::TimeDelta delta) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 } | 472 } |
| 474 | 473 |
| 475 void WmWindowMus::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { | 474 void WmWindowMus::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { |
| 476 restore_bounds_in_screen_.reset(new gfx::Rect(bounds)); | 475 restore_bounds_in_screen_.reset(new gfx::Rect(bounds)); |
| 477 } | 476 } |
| 478 | 477 |
| 479 gfx::Rect WmWindowMus::GetRestoreBoundsInScreen() const { | 478 gfx::Rect WmWindowMus::GetRestoreBoundsInScreen() const { |
| 480 return *restore_bounds_in_screen_; | 479 return *restore_bounds_in_screen_; |
| 481 } | 480 } |
| 482 | 481 |
| 483 bool WmWindowMus::Contains(const wm::WmWindow* other) const { | 482 bool WmWindowMus::Contains(const WmWindow* other) const { |
| 484 return other | 483 return other |
| 485 ? window_->Contains( | 484 ? window_->Contains( |
| 486 static_cast<const WmWindowMus*>(other)->window_) | 485 static_cast<const WmWindowMus*>(other)->window_) |
| 487 : false; | 486 : false; |
| 488 } | 487 } |
| 489 | 488 |
| 490 void WmWindowMus::SetShowState(ui::WindowShowState show_state) { | 489 void WmWindowMus::SetShowState(ui::WindowShowState show_state) { |
| 491 SetWindowShowState(window_, MojomWindowShowStateFromUI(show_state)); | 490 SetWindowShowState(window_, MojomWindowShowStateFromUI(show_state)); |
| 492 } | 491 } |
| 493 | 492 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 bool WmWindowMus::CanResize() const { | 530 bool WmWindowMus::CanResize() const { |
| 532 return widget_ ? widget_->widget_delegate()->CanResize() : false; | 531 return widget_ ? widget_->widget_delegate()->CanResize() : false; |
| 533 } | 532 } |
| 534 | 533 |
| 535 bool WmWindowMus::CanActivate() const { | 534 bool WmWindowMus::CanActivate() const { |
| 536 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not | 535 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not |
| 537 // replicated. | 536 // replicated. |
| 538 return widget_ != nullptr; | 537 return widget_ != nullptr; |
| 539 } | 538 } |
| 540 | 539 |
| 541 void WmWindowMus::StackChildAtTop(wm::WmWindow* child) { | 540 void WmWindowMus::StackChildAtTop(WmWindow* child) { |
| 542 GetMusWindow(child)->MoveToFront(); | 541 GetMusWindow(child)->MoveToFront(); |
| 543 } | 542 } |
| 544 | 543 |
| 545 void WmWindowMus::StackChildAtBottom(wm::WmWindow* child) { | 544 void WmWindowMus::StackChildAtBottom(WmWindow* child) { |
| 546 GetMusWindow(child)->MoveToBack(); | 545 GetMusWindow(child)->MoveToBack(); |
| 547 } | 546 } |
| 548 | 547 |
| 549 void WmWindowMus::StackChildAbove(wm::WmWindow* child, wm::WmWindow* target) { | 548 void WmWindowMus::StackChildAbove(WmWindow* child, WmWindow* target) { |
| 550 GetMusWindow(child)->Reorder(GetMusWindow(target), | 549 GetMusWindow(child)->Reorder(GetMusWindow(target), |
| 551 ::mus::mojom::OrderDirection::ABOVE); | 550 ::mus::mojom::OrderDirection::ABOVE); |
| 552 } | 551 } |
| 553 | 552 |
| 554 void WmWindowMus::StackChildBelow(WmWindow* child, WmWindow* target) { | 553 void WmWindowMus::StackChildBelow(WmWindow* child, WmWindow* target) { |
| 555 GetMusWindow(child)->Reorder(GetMusWindow(target), | 554 GetMusWindow(child)->Reorder(GetMusWindow(target), |
| 556 ::mus::mojom::OrderDirection::BELOW); | 555 ::mus::mojom::OrderDirection::BELOW); |
| 557 } | 556 } |
| 558 | 557 |
| 559 void WmWindowMus::SetAlwaysOnTop(bool value) { | 558 void WmWindowMus::SetAlwaysOnTop(bool value) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 585 return window_->HasFocus(); | 584 return window_->HasFocus(); |
| 586 } | 585 } |
| 587 | 586 |
| 588 bool WmWindowMus::IsActive() const { | 587 bool WmWindowMus::IsActive() const { |
| 589 ::mus::Window* focused = window_->window_tree()->GetFocusedWindow(); | 588 ::mus::Window* focused = window_->window_tree()->GetFocusedWindow(); |
| 590 return focused && window_->Contains(focused); | 589 return focused && window_->Contains(focused); |
| 591 } | 590 } |
| 592 | 591 |
| 593 void WmWindowMus::Activate() { | 592 void WmWindowMus::Activate() { |
| 594 window_->SetFocus(); | 593 window_->SetFocus(); |
| 595 wm::WmWindow* top_level = GetToplevelWindow(); | 594 WmWindow* top_level = GetToplevelWindow(); |
| 596 if (!top_level) | 595 if (!top_level) |
| 597 return; | 596 return; |
| 598 | 597 |
| 599 // TODO(sky): mus should do this too. | 598 // TODO(sky): mus should do this too. |
| 600 GetMusWindow(top_level)->MoveToFront(); | 599 GetMusWindow(top_level)->MoveToFront(); |
| 601 } | 600 } |
| 602 | 601 |
| 603 void WmWindowMus::Deactivate() { | 602 void WmWindowMus::Deactivate() { |
| 604 if (IsActive()) | 603 if (IsActive()) |
| 605 window_->window_tree()->ClearFocus(); | 604 window_->window_tree()->ClearFocus(); |
| 606 } | 605 } |
| 607 | 606 |
| 608 void WmWindowMus::SetFullscreen() { | 607 void WmWindowMus::SetFullscreen() { |
| 609 SetWindowShowState(window_, ::mus::mojom::ShowState::FULLSCREEN); | 608 SetWindowShowState(window_, ::mus::mojom::ShowState::FULLSCREEN); |
| 610 } | 609 } |
| 611 | 610 |
| 612 void WmWindowMus::Maximize() { | 611 void WmWindowMus::Maximize() { |
| 613 SetWindowShowState(window_, ::mus::mojom::ShowState::MAXIMIZED); | 612 SetWindowShowState(window_, ::mus::mojom::ShowState::MAXIMIZED); |
| 614 } | 613 } |
| 615 | 614 |
| 616 void WmWindowMus::Minimize() { | 615 void WmWindowMus::Minimize() { |
| 617 SetWindowShowState(window_, ::mus::mojom::ShowState::MINIMIZED); | 616 SetWindowShowState(window_, ::mus::mojom::ShowState::MINIMIZED); |
| 618 } | 617 } |
| 619 | 618 |
| 620 void WmWindowMus::Unminimize() { | 619 void WmWindowMus::Unminimize() { |
| 621 SetWindowShowState(window_, MojomWindowShowStateFromUI(restore_show_state_)); | 620 SetWindowShowState(window_, MojomWindowShowStateFromUI(restore_show_state_)); |
| 622 restore_show_state_ = ui::SHOW_STATE_DEFAULT; | 621 restore_show_state_ = ui::SHOW_STATE_DEFAULT; |
| 623 } | 622 } |
| 624 | 623 |
| 625 std::vector<wm::WmWindow*> WmWindowMus::GetChildren() { | 624 std::vector<WmWindow*> WmWindowMus::GetChildren() { |
| 626 return FromMusWindows(window_->children()); | 625 return FromMusWindows(window_->children()); |
| 627 } | 626 } |
| 628 | 627 |
| 629 wm::WmWindow* WmWindowMus::GetChildByShellWindowId(int id) { | 628 WmWindow* WmWindowMus::GetChildByShellWindowId(int id) { |
| 630 if (id == shell_window_id_) | 629 if (id == shell_window_id_) |
| 631 return this; | 630 return this; |
| 632 for (::mus::Window* child : window_->children()) { | 631 for (::mus::Window* child : window_->children()) { |
| 633 wm::WmWindow* result = Get(child)->GetChildByShellWindowId(id); | 632 WmWindow* result = Get(child)->GetChildByShellWindowId(id); |
| 634 if (result) | 633 if (result) |
| 635 return result; | 634 return result; |
| 636 } | 635 } |
| 637 return nullptr; | 636 return nullptr; |
| 638 } | 637 } |
| 639 | 638 |
| 640 void WmWindowMus::ShowResizeShadow(int component) { | 639 void WmWindowMus::ShowResizeShadow(int component) { |
| 641 NOTIMPLEMENTED(); | 640 NOTIMPLEMENTED(); |
| 642 } | 641 } |
| 643 | 642 |
| 644 void WmWindowMus::HideResizeShadow() { | 643 void WmWindowMus::HideResizeShadow() { |
| 645 NOTIMPLEMENTED(); | 644 NOTIMPLEMENTED(); |
| 646 } | 645 } |
| 647 | 646 |
| 648 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( | 647 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( |
| 649 wm::WmWindow::BoundsInScreenBehavior behavior) { | 648 WmWindow::BoundsInScreenBehavior behavior) { |
| 650 // TODO: SetBoundsInScreen isn't fully implemented yet, | 649 // TODO: SetBoundsInScreen isn't fully implemented yet, |
| 651 // http://crbug.com/615552. | 650 // http://crbug.com/615552. |
| 652 NOTIMPLEMENTED(); | 651 NOTIMPLEMENTED(); |
| 653 } | 652 } |
| 654 | 653 |
| 655 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { | 654 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { |
| 656 if (snap_children_to_pixel_boundary_) | 655 if (snap_children_to_pixel_boundary_) |
| 657 return; | 656 return; |
| 658 | 657 |
| 659 snap_children_to_pixel_boundary_ = true; | 658 snap_children_to_pixel_boundary_ = true; |
| 660 FOR_EACH_OBSERVER( | 659 FOR_EACH_OBSERVER( |
| 661 wm::WmWindowObserver, observers_, | 660 WmWindowObserver, observers_, |
| 662 OnWindowPropertyChanged( | 661 OnWindowPropertyChanged( |
| 663 this, wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); | 662 this, WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); |
| 664 } | 663 } |
| 665 | 664 |
| 666 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { | 665 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { |
| 667 WmWindowMus* parent = Get(window_->parent()); | 666 WmWindowMus* parent = Get(window_->parent()); |
| 668 if (parent && parent->snap_children_to_pixel_boundary_) { | 667 if (parent && parent->snap_children_to_pixel_boundary_) { |
| 669 // TODO: implement snap to pixel: http://crbug.com/615554. | 668 // TODO: implement snap to pixel: http://crbug.com/615554. |
| 670 NOTIMPLEMENTED(); | 669 NOTIMPLEMENTED(); |
| 671 } | 670 } |
| 672 } | 671 } |
| 673 | 672 |
| 674 void WmWindowMus::SetChildrenUseExtendedHitRegion() { | 673 void WmWindowMus::SetChildrenUseExtendedHitRegion() { |
| 675 children_use_extended_hit_region_ = true; | 674 children_use_extended_hit_region_ = true; |
| 676 } | 675 } |
| 677 | 676 |
| 678 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) { | 677 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) { |
| 679 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented: | 678 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented: |
| 680 // http://crbug.com/615552. | 679 // http://crbug.com/615552. |
| 681 NOTIMPLEMENTED(); | 680 NOTIMPLEMENTED(); |
| 682 } | 681 } |
| 683 | 682 |
| 684 void WmWindowMus::AddObserver(wm::WmWindowObserver* observer) { | 683 void WmWindowMus::AddObserver(WmWindowObserver* observer) { |
| 685 observers_.AddObserver(observer); | 684 observers_.AddObserver(observer); |
| 686 } | 685 } |
| 687 | 686 |
| 688 void WmWindowMus::RemoveObserver(wm::WmWindowObserver* observer) { | 687 void WmWindowMus::RemoveObserver(WmWindowObserver* observer) { |
| 689 observers_.RemoveObserver(observer); | 688 observers_.RemoveObserver(observer); |
| 690 } | 689 } |
| 691 | 690 |
| 692 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { | 691 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { |
| 693 wm::WmWindowObserver::TreeChangeParams wm_params; | 692 WmWindowObserver::TreeChangeParams wm_params; |
| 694 wm_params.target = Get(params.target); | 693 wm_params.target = Get(params.target); |
| 695 wm_params.new_parent = Get(params.new_parent); | 694 wm_params.new_parent = Get(params.new_parent); |
| 696 wm_params.old_parent = Get(params.old_parent); | 695 wm_params.old_parent = Get(params.old_parent); |
| 697 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, | 696 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 698 OnWindowTreeChanged(this, wm_params)); | 697 OnWindowTreeChanged(this, wm_params)); |
| 699 } | 698 } |
| 700 | 699 |
| 701 void WmWindowMus::OnWindowReordered(::mus::Window* window, | 700 void WmWindowMus::OnWindowReordered(::mus::Window* window, |
| 702 ::mus::Window* relative_window, | 701 ::mus::Window* relative_window, |
| 703 ::mus::mojom::OrderDirection direction) { | 702 ::mus::mojom::OrderDirection direction) { |
| 704 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, | 703 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 705 OnWindowStackingChanged(this)); | 704 OnWindowStackingChanged(this)); |
| 706 } | 705 } |
| 707 | 706 |
| 708 void WmWindowMus::OnWindowSharedPropertyChanged( | 707 void WmWindowMus::OnWindowSharedPropertyChanged( |
| 709 ::mus::Window* window, | 708 ::mus::Window* window, |
| 710 const std::string& name, | 709 const std::string& name, |
| 711 const std::vector<uint8_t>* old_data, | 710 const std::vector<uint8_t>* old_data, |
| 712 const std::vector<uint8_t>* new_data) { | 711 const std::vector<uint8_t>* new_data) { |
| 713 if (name == ::mus::mojom::WindowManager::kShowState_Property) { | 712 if (name == ::mus::mojom::WindowManager::kShowState_Property) { |
| 714 GetWindowState()->OnWindowShowStateChanged(); | 713 GetWindowState()->OnWindowShowStateChanged(); |
| 715 return; | 714 return; |
| 716 } | 715 } |
| 717 if (name == ::mus::mojom::WindowManager::kAlwaysOnTop_Property) { | 716 if (name == ::mus::mojom::WindowManager::kAlwaysOnTop_Property) { |
| 718 FOR_EACH_OBSERVER( | 717 FOR_EACH_OBSERVER( |
| 719 wm::WmWindowObserver, observers_, | 718 WmWindowObserver, observers_, |
| 720 OnWindowPropertyChanged(this, wm::WmWindowProperty::ALWAYS_ON_TOP)); | 719 OnWindowPropertyChanged(this, WmWindowProperty::ALWAYS_ON_TOP)); |
| 721 return; | 720 return; |
| 722 } | 721 } |
| 723 | 722 |
| 724 // Deal with snap to pixel. | 723 // Deal with snap to pixel. |
| 725 NOTIMPLEMENTED(); | 724 NOTIMPLEMENTED(); |
| 726 } | 725 } |
| 727 | 726 |
| 728 void WmWindowMus::OnWindowBoundsChanged(::mus::Window* window, | 727 void WmWindowMus::OnWindowBoundsChanged(::mus::Window* window, |
| 729 const gfx::Rect& old_bounds, | 728 const gfx::Rect& old_bounds, |
| 730 const gfx::Rect& new_bounds) { | 729 const gfx::Rect& new_bounds) { |
| 731 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, | 730 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 732 OnWindowBoundsChanged(this, old_bounds, new_bounds)); | 731 OnWindowBoundsChanged(this, old_bounds, new_bounds)); |
| 733 } | 732 } |
| 734 | 733 |
| 735 void WmWindowMus::OnWindowDestroying(::mus::Window* window) { | 734 void WmWindowMus::OnWindowDestroying(::mus::Window* window) { |
| 736 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, OnWindowDestroying(this)); | 735 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowDestroying(this)); |
| 737 } | 736 } |
| 738 | 737 |
| 739 } // namespace mus | 738 } // namespace mus |
| 740 } // namespace ash | 739 } // namespace ash |
| OLD | NEW |