| 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 "mash/wm/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/wm_layout_manager.h" |
| 10 #include "ash/common/wm/wm_window_observer.h" | 10 #include "ash/common/wm/wm_window_observer.h" |
| 11 #include "ash/common/wm/wm_window_property.h" | 11 #include "ash/common/wm/wm_window_property.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" |
| 15 #include "ash/mus/property_util.h" |
| 12 #include "components/mus/public/cpp/property_type_converters.h" | 16 #include "components/mus/public/cpp/property_type_converters.h" |
| 13 #include "components/mus/public/cpp/window.h" | 17 #include "components/mus/public/cpp/window.h" |
| 14 #include "components/mus/public/cpp/window_property.h" | 18 #include "components/mus/public/cpp/window_property.h" |
| 15 #include "components/mus/public/cpp/window_tree_client.h" | 19 #include "components/mus/public/cpp/window_tree_client.h" |
| 16 #include "components/mus/public/interfaces/window_manager.mojom.h" | 20 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 17 #include "mash/wm/bridge/mus_layout_manager_adapter.h" | |
| 18 #include "mash/wm/bridge/wm_globals_mus.h" | |
| 19 #include "mash/wm/bridge/wm_root_window_controller_mus.h" | |
| 20 #include "mash/wm/property_util.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" |
| 25 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
| 26 | 26 |
| 27 MUS_DECLARE_WINDOW_PROPERTY_TYPE(mash::wm::WmWindowMus*); | 27 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmWindowMus*); |
| 28 | 28 |
| 29 // TODO(sky): fully implement this. Making DVLOG as too spammy to be useful. | 29 // TODO(sky): fully implement this. Making DVLOG as too spammy to be useful. |
| 30 #undef NOTIMPLEMENTED | 30 #undef NOTIMPLEMENTED |
| 31 #define NOTIMPLEMENTED() DVLOG(1) << "notimplemented" | 31 #define NOTIMPLEMENTED() DVLOG(1) << "notimplemented" |
| 32 | 32 |
| 33 namespace mash { | 33 namespace ash { |
| 34 namespace wm { | 34 namespace mus { |
| 35 | 35 |
| 36 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(mash::wm::WmWindowMus, | 36 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(mus::WmWindowMus, kWmWindowKey, nullptr); |
| 37 kWmWindowKey, | |
| 38 nullptr); | |
| 39 namespace { | 37 namespace { |
| 40 | 38 |
| 41 // This classes is used so that the WindowState constructor can be made | 39 // This classes is used so that the WindowState constructor can be made |
| 42 // protected. GetWindowState() is the only place that should be creating | 40 // protected. GetWindowState() is the only place that should be creating |
| 43 // WindowState. | 41 // WindowState. |
| 44 class WindowStateMus : public ash::wm::WindowState { | 42 class WindowStateMus : public wm::WindowState { |
| 45 public: | 43 public: |
| 46 explicit WindowStateMus(ash::wm::WmWindow* window) | 44 explicit WindowStateMus(wm::WmWindow* window) : wm::WindowState(window) {} |
| 47 : ash::wm::WindowState(window) {} | |
| 48 ~WindowStateMus() override {} | 45 ~WindowStateMus() override {} |
| 49 | 46 |
| 50 private: | 47 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); | 48 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); |
| 52 }; | 49 }; |
| 53 | 50 |
| 54 ui::WindowShowState UIWindowShowStateFromMojom(mus::mojom::ShowState state) { | 51 ui::WindowShowState UIWindowShowStateFromMojom(::mus::mojom::ShowState state) { |
| 55 switch (state) { | 52 switch (state) { |
| 56 case mus::mojom::ShowState::DEFAULT: | 53 case ::mus::mojom::ShowState::DEFAULT: |
| 57 return ui::SHOW_STATE_DEFAULT; | 54 return ui::SHOW_STATE_DEFAULT; |
| 58 case mus::mojom::ShowState::NORMAL: | 55 case ::mus::mojom::ShowState::NORMAL: |
| 59 return ui::SHOW_STATE_NORMAL; | 56 return ui::SHOW_STATE_NORMAL; |
| 60 case mus::mojom::ShowState::MINIMIZED: | 57 case ::mus::mojom::ShowState::MINIMIZED: |
| 61 return ui::SHOW_STATE_MINIMIZED; | 58 return ui::SHOW_STATE_MINIMIZED; |
| 62 case mus::mojom::ShowState::MAXIMIZED: | 59 case ::mus::mojom::ShowState::MAXIMIZED: |
| 63 return ui::SHOW_STATE_MAXIMIZED; | 60 return ui::SHOW_STATE_MAXIMIZED; |
| 64 case mus::mojom::ShowState::INACTIVE: | 61 case ::mus::mojom::ShowState::INACTIVE: |
| 65 return ui::SHOW_STATE_INACTIVE; | 62 return ui::SHOW_STATE_INACTIVE; |
| 66 case mus::mojom::ShowState::FULLSCREEN: | 63 case ::mus::mojom::ShowState::FULLSCREEN: |
| 67 return ui::SHOW_STATE_FULLSCREEN; | 64 return ui::SHOW_STATE_FULLSCREEN; |
| 68 case mus::mojom::ShowState::DOCKED: | 65 case ::mus::mojom::ShowState::DOCKED: |
| 69 return ui::SHOW_STATE_DOCKED; | 66 return ui::SHOW_STATE_DOCKED; |
| 70 default: | 67 default: |
| 71 break; | 68 break; |
| 72 } | 69 } |
| 73 return ui::SHOW_STATE_DEFAULT; | 70 return ui::SHOW_STATE_DEFAULT; |
| 74 } | 71 } |
| 75 | 72 |
| 76 mus::mojom::ShowState MojomWindowShowStateFromUI(ui::WindowShowState state) { | 73 ::mus::mojom::ShowState MojomWindowShowStateFromUI(ui::WindowShowState state) { |
| 77 switch (state) { | 74 switch (state) { |
| 78 case ui::SHOW_STATE_DEFAULT: | 75 case ui::SHOW_STATE_DEFAULT: |
| 79 return mus::mojom::ShowState::DEFAULT; | 76 return ::mus::mojom::ShowState::DEFAULT; |
| 80 case ui::SHOW_STATE_NORMAL: | 77 case ui::SHOW_STATE_NORMAL: |
| 81 return mus::mojom::ShowState::NORMAL; | 78 return ::mus::mojom::ShowState::NORMAL; |
| 82 case ui::SHOW_STATE_MINIMIZED: | 79 case ui::SHOW_STATE_MINIMIZED: |
| 83 return mus::mojom::ShowState::MINIMIZED; | 80 return ::mus::mojom::ShowState::MINIMIZED; |
| 84 case ui::SHOW_STATE_MAXIMIZED: | 81 case ui::SHOW_STATE_MAXIMIZED: |
| 85 return mus::mojom::ShowState::MAXIMIZED; | 82 return ::mus::mojom::ShowState::MAXIMIZED; |
| 86 case ui::SHOW_STATE_INACTIVE: | 83 case ui::SHOW_STATE_INACTIVE: |
| 87 return mus::mojom::ShowState::INACTIVE; | 84 return ::mus::mojom::ShowState::INACTIVE; |
| 88 case ui::SHOW_STATE_FULLSCREEN: | 85 case ui::SHOW_STATE_FULLSCREEN: |
| 89 return mus::mojom::ShowState::FULLSCREEN; | 86 return ::mus::mojom::ShowState::FULLSCREEN; |
| 90 case ui::SHOW_STATE_DOCKED: | 87 case ui::SHOW_STATE_DOCKED: |
| 91 return mus::mojom::ShowState::DOCKED; | 88 return ::mus::mojom::ShowState::DOCKED; |
| 92 default: | 89 default: |
| 93 break; | 90 break; |
| 94 } | 91 } |
| 95 return mus::mojom::ShowState::DEFAULT; | 92 return ::mus::mojom::ShowState::DEFAULT; |
| 96 } | 93 } |
| 97 | 94 |
| 98 } // namespace | 95 } // namespace |
| 99 | 96 |
| 100 WmWindowMus::WmWindowMus(mus::Window* window) | 97 WmWindowMus::WmWindowMus(::mus::Window* window) |
| 101 : window_(window), | 98 : window_(window), |
| 102 // Matches aura, see aura::Window for details. | 99 // Matches aura, see aura::Window for details. |
| 103 observers_( | 100 observers_( |
| 104 base::ObserverList<ash::wm::WmWindowObserver>::NOTIFY_EXISTING_ONLY) { | 101 base::ObserverList<wm::WmWindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 105 window_->AddObserver(this); | 102 window_->AddObserver(this); |
| 106 window_->SetLocalProperty(kWmWindowKey, this); | 103 window_->SetLocalProperty(kWmWindowKey, this); |
| 107 window_state_.reset(new WindowStateMus(this)); | 104 window_state_.reset(new WindowStateMus(this)); |
| 108 } | 105 } |
| 109 | 106 |
| 110 WmWindowMus::~WmWindowMus() { | 107 WmWindowMus::~WmWindowMus() { |
| 111 window_->RemoveObserver(this); | 108 window_->RemoveObserver(this); |
| 112 } | 109 } |
| 113 | 110 |
| 114 // static | 111 // static |
| 115 WmWindowMus* WmWindowMus::Get(mus::Window* window) { | 112 WmWindowMus* WmWindowMus::Get(::mus::Window* window) { |
| 116 if (!window) | 113 if (!window) |
| 117 return nullptr; | 114 return nullptr; |
| 118 | 115 |
| 119 wm::WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); | 116 WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); |
| 120 if (wm_window) | 117 if (wm_window) |
| 121 return wm_window; | 118 return wm_window; |
| 122 // WmWindowMus is owned by the mus::Window. | 119 // WmWindowMus is owned by the mus::Window. |
| 123 return new WmWindowMus(window); | 120 return new WmWindowMus(window); |
| 124 } | 121 } |
| 125 | 122 |
| 126 // static | 123 // static |
| 127 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { | 124 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { |
| 128 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); | 125 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); |
| 129 } | 126 } |
| 130 | 127 |
| 131 // static | 128 // static |
| 132 const mus::Window* WmWindowMus::GetMusWindow( | 129 const ::mus::Window* WmWindowMus::GetMusWindow(const wm::WmWindow* wm_window) { |
| 133 const ash::wm::WmWindow* wm_window) { | |
| 134 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); | 130 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); |
| 135 } | 131 } |
| 136 | 132 |
| 137 // static | 133 // static |
| 138 std::vector<ash::wm::WmWindow*> WmWindowMus::FromMusWindows( | 134 std::vector<wm::WmWindow*> WmWindowMus::FromMusWindows( |
| 139 const std::vector<mus::Window*>& mus_windows) { | 135 const std::vector<::mus::Window*>& mus_windows) { |
| 140 std::vector<ash::wm::WmWindow*> result(mus_windows.size()); | 136 std::vector<wm::WmWindow*> result(mus_windows.size()); |
| 141 for (size_t i = 0; i < mus_windows.size(); ++i) | 137 for (size_t i = 0; i < mus_windows.size(); ++i) |
| 142 result[i] = Get(mus_windows[i]); | 138 result[i] = Get(mus_windows[i]); |
| 143 return result; | 139 return result; |
| 144 } | 140 } |
| 145 | 141 |
| 146 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() | 142 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() |
| 147 const { | 143 const { |
| 148 return WmRootWindowControllerMus::Get(window_->GetRoot()); | 144 return WmRootWindowControllerMus::Get(window_->GetRoot()); |
| 149 } | 145 } |
| 150 | 146 |
| 151 bool WmWindowMus::ShouldUseExtendedHitRegion() const { | 147 bool WmWindowMus::ShouldUseExtendedHitRegion() const { |
| 152 const WmWindowMus* parent = Get(window_->parent()); | 148 const WmWindowMus* parent = Get(window_->parent()); |
| 153 return parent && parent->children_use_extended_hit_region_; | 149 return parent && parent->children_use_extended_hit_region_; |
| 154 } | 150 } |
| 155 | 151 |
| 156 const ash::wm::WmWindow* WmWindowMus::GetRootWindow() const { | 152 const wm::WmWindow* WmWindowMus::GetRootWindow() const { |
| 157 return Get(window_->GetRoot()); | 153 return Get(window_->GetRoot()); |
| 158 } | 154 } |
| 159 | 155 |
| 160 ash::wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { | 156 wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { |
| 161 return GetRootWindowControllerMus(); | 157 return GetRootWindowControllerMus(); |
| 162 } | 158 } |
| 163 | 159 |
| 164 ash::wm::WmGlobals* WmWindowMus::GetGlobals() const { | 160 wm::WmGlobals* WmWindowMus::GetGlobals() const { |
| 165 return WmGlobalsMus::Get(); | 161 return WmGlobalsMus::Get(); |
| 166 } | 162 } |
| 167 | 163 |
| 168 void WmWindowMus::SetName(const char* name) { | 164 void WmWindowMus::SetName(const char* name) { |
| 169 if (name) { | 165 if (name) { |
| 170 window_->SetSharedProperty<std::string>( | 166 window_->SetSharedProperty<std::string>( |
| 171 mus::mojom::WindowManager::kName_Property, std::string(name)); | 167 ::mus::mojom::WindowManager::kName_Property, std::string(name)); |
| 172 } else { | 168 } else { |
| 173 window_->ClearSharedProperty(mus::mojom::WindowManager::kName_Property); | 169 window_->ClearSharedProperty(::mus::mojom::WindowManager::kName_Property); |
| 174 } | 170 } |
| 175 } | 171 } |
| 176 | 172 |
| 177 base::string16 WmWindowMus::GetTitle() const { | 173 base::string16 WmWindowMus::GetTitle() const { |
| 178 return GetWindowTitle(window_); | 174 return GetWindowTitle(window_); |
| 179 } | 175 } |
| 180 | 176 |
| 181 void WmWindowMus::SetShellWindowId(int id) { | 177 void WmWindowMus::SetShellWindowId(int id) { |
| 182 shell_window_id_ = id; | 178 shell_window_id_ = id; |
| 183 } | 179 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 204 bool WmWindowMus::HasNonClientArea() { | 200 bool WmWindowMus::HasNonClientArea() { |
| 205 return widget_ ? true : false; | 201 return widget_ ? true : false; |
| 206 } | 202 } |
| 207 | 203 |
| 208 int WmWindowMus::GetNonClientComponent(const gfx::Point& location) { | 204 int WmWindowMus::GetNonClientComponent(const gfx::Point& location) { |
| 209 return widget_ ? widget_->GetNonClientComponent(location) : HTNOWHERE; | 205 return widget_ ? widget_->GetNonClientComponent(location) : HTNOWHERE; |
| 210 } | 206 } |
| 211 | 207 |
| 212 gfx::Point WmWindowMus::ConvertPointToTarget(const WmWindow* target, | 208 gfx::Point WmWindowMus::ConvertPointToTarget(const WmWindow* target, |
| 213 const gfx::Point& point) const { | 209 const gfx::Point& point) const { |
| 214 const mus::Window* target_window = GetMusWindow(target); | 210 const ::mus::Window* target_window = GetMusWindow(target); |
| 215 if (target_window->Contains(window_)) { | 211 if (target_window->Contains(window_)) { |
| 216 gfx::Point result(point); | 212 gfx::Point result(point); |
| 217 const mus::Window* window = window_; | 213 const ::mus::Window* window = window_; |
| 218 while (window != target_window) { | 214 while (window != target_window) { |
| 219 result += window->bounds().origin().OffsetFromOrigin(); | 215 result += window->bounds().origin().OffsetFromOrigin(); |
| 220 window = window->parent(); | 216 window = window->parent(); |
| 221 } | 217 } |
| 222 return result; | 218 return result; |
| 223 } | 219 } |
| 224 if (window_->Contains(target_window)) { | 220 if (window_->Contains(target_window)) { |
| 225 gfx::Point result(point); | 221 gfx::Point result(point); |
| 226 result -= | 222 result -= |
| 227 target->ConvertPointToTarget(this, gfx::Point()).OffsetFromOrigin(); | 223 target->ConvertPointToTarget(this, gfx::Point()).OffsetFromOrigin(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 gfx::Transform WmWindowMus::GetTargetTransform() const { | 282 gfx::Transform WmWindowMus::GetTargetTransform() const { |
| 287 // TODO: need animation support: http://crbug.com/615087. | 283 // TODO: need animation support: http://crbug.com/615087. |
| 288 return gfx::Transform(); | 284 return gfx::Transform(); |
| 289 } | 285 } |
| 290 | 286 |
| 291 bool WmWindowMus::IsSystemModal() const { | 287 bool WmWindowMus::IsSystemModal() const { |
| 292 NOTIMPLEMENTED(); | 288 NOTIMPLEMENTED(); |
| 293 return false; | 289 return false; |
| 294 } | 290 } |
| 295 | 291 |
| 296 bool WmWindowMus::GetBoolProperty(ash::wm::WmWindowProperty key) { | 292 bool WmWindowMus::GetBoolProperty(wm::WmWindowProperty key) { |
| 297 switch (key) { | 293 switch (key) { |
| 298 case ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: | 294 case wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: |
| 299 return snap_children_to_pixel_boundary_; | 295 return snap_children_to_pixel_boundary_; |
| 300 | 296 |
| 301 case ash::wm::WmWindowProperty::ALWAYS_ON_TOP: | 297 case wm::WmWindowProperty::ALWAYS_ON_TOP: |
| 302 return IsAlwaysOnTop(); | 298 return IsAlwaysOnTop(); |
| 303 | 299 |
| 304 default: | 300 default: |
| 305 NOTREACHED(); | 301 NOTREACHED(); |
| 306 break; | 302 break; |
| 307 } | 303 } |
| 308 | 304 |
| 309 NOTREACHED(); | 305 NOTREACHED(); |
| 310 return false; | 306 return false; |
| 311 } | 307 } |
| 312 | 308 |
| 313 int WmWindowMus::GetIntProperty(ash::wm::WmWindowProperty key) { | 309 int WmWindowMus::GetIntProperty(wm::WmWindowProperty key) { |
| 314 if (key == ash::wm::WmWindowProperty::SHELF_ID) { | 310 if (key == wm::WmWindowProperty::SHELF_ID) { |
| 315 NOTIMPLEMENTED(); | 311 NOTIMPLEMENTED(); |
| 316 return 0; | 312 return 0; |
| 317 } | 313 } |
| 318 | 314 |
| 319 if (key == ash::wm::WmWindowProperty::TOP_VIEW_INSET) { | 315 if (key == wm::WmWindowProperty::TOP_VIEW_INSET) { |
| 320 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. | 316 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. |
| 321 NOTIMPLEMENTED(); | 317 NOTIMPLEMENTED(); |
| 322 return 0; | 318 return 0; |
| 323 } | 319 } |
| 324 | 320 |
| 325 NOTREACHED(); | 321 NOTREACHED(); |
| 326 return 0; | 322 return 0; |
| 327 } | 323 } |
| 328 | 324 |
| 329 const ash::wm::WindowState* WmWindowMus::GetWindowState() const { | 325 const wm::WindowState* WmWindowMus::GetWindowState() const { |
| 330 return window_state_.get(); | 326 return window_state_.get(); |
| 331 } | 327 } |
| 332 | 328 |
| 333 ash::wm::WmWindow* WmWindowMus::GetToplevelWindow() { | 329 wm::WmWindow* WmWindowMus::GetToplevelWindow() { |
| 334 return WmGlobalsMus::GetToplevelAncestor(window_); | 330 return WmGlobalsMus::GetToplevelAncestor(window_); |
| 335 } | 331 } |
| 336 | 332 |
| 337 void WmWindowMus::SetParentUsingContext(WmWindow* context, | 333 void WmWindowMus::SetParentUsingContext(WmWindow* context, |
| 338 const gfx::Rect& screen_bounds) { | 334 const gfx::Rect& screen_bounds) { |
| 339 GetDefaultParent(context, this, screen_bounds)->AddChild(this); | 335 GetDefaultParent(context, this, screen_bounds)->AddChild(this); |
| 340 } | 336 } |
| 341 | 337 |
| 342 void WmWindowMus::AddChild(WmWindow* window) { | 338 void WmWindowMus::AddChild(WmWindow* window) { |
| 343 window_->AddChild(GetMusWindow(window)); | 339 window_->AddChild(GetMusWindow(window)); |
| 344 } | 340 } |
| 345 | 341 |
| 346 ash::wm::WmWindow* WmWindowMus::GetParent() { | 342 wm::WmWindow* WmWindowMus::GetParent() { |
| 347 return Get(window_->parent()); | 343 return Get(window_->parent()); |
| 348 } | 344 } |
| 349 | 345 |
| 350 const ash::wm::WmWindow* WmWindowMus::GetTransientParent() const { | 346 const wm::WmWindow* WmWindowMus::GetTransientParent() const { |
| 351 return Get(window_->transient_parent()); | 347 return Get(window_->transient_parent()); |
| 352 } | 348 } |
| 353 | 349 |
| 354 std::vector<ash::wm::WmWindow*> WmWindowMus::GetTransientChildren() { | 350 std::vector<wm::WmWindow*> WmWindowMus::GetTransientChildren() { |
| 355 return FromMusWindows(window_->transient_children()); | 351 return FromMusWindows(window_->transient_children()); |
| 356 } | 352 } |
| 357 | 353 |
| 358 void WmWindowMus::SetLayoutManager( | 354 void WmWindowMus::SetLayoutManager( |
| 359 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager) { | 355 std::unique_ptr<wm::WmLayoutManager> layout_manager) { |
| 360 if (layout_manager) { | 356 if (layout_manager) { |
| 361 layout_manager_adapter_.reset( | 357 layout_manager_adapter_.reset( |
| 362 new MusLayoutManagerAdapter(window_, std::move(layout_manager))); | 358 new MusLayoutManagerAdapter(window_, std::move(layout_manager))); |
| 363 } else { | 359 } else { |
| 364 layout_manager_adapter_.reset(); | 360 layout_manager_adapter_.reset(); |
| 365 } | 361 } |
| 366 } | 362 } |
| 367 | 363 |
| 368 ash::wm::WmLayoutManager* WmWindowMus::GetLayoutManager() { | 364 wm::WmLayoutManager* WmWindowMus::GetLayoutManager() { |
| 369 return layout_manager_adapter_ ? layout_manager_adapter_->layout_manager() | 365 return layout_manager_adapter_ ? layout_manager_adapter_->layout_manager() |
| 370 : nullptr; | 366 : nullptr; |
| 371 } | 367 } |
| 372 | 368 |
| 373 void WmWindowMus::SetVisibilityAnimationType(int type) { | 369 void WmWindowMus::SetVisibilityAnimationType(int type) { |
| 374 // TODO: need animation support: http://crbug.com/615087. | 370 // TODO: need animation support: http://crbug.com/615087. |
| 375 NOTIMPLEMENTED(); | 371 NOTIMPLEMENTED(); |
| 376 } | 372 } |
| 377 | 373 |
| 378 void WmWindowMus::SetVisibilityAnimationDuration(base::TimeDelta delta) { | 374 void WmWindowMus::SetVisibilityAnimationDuration(base::TimeDelta delta) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 } | 466 } |
| 471 | 467 |
| 472 void WmWindowMus::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { | 468 void WmWindowMus::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { |
| 473 restore_bounds_in_screen_.reset(new gfx::Rect(bounds)); | 469 restore_bounds_in_screen_.reset(new gfx::Rect(bounds)); |
| 474 } | 470 } |
| 475 | 471 |
| 476 gfx::Rect WmWindowMus::GetRestoreBoundsInScreen() const { | 472 gfx::Rect WmWindowMus::GetRestoreBoundsInScreen() const { |
| 477 return *restore_bounds_in_screen_; | 473 return *restore_bounds_in_screen_; |
| 478 } | 474 } |
| 479 | 475 |
| 480 bool WmWindowMus::Contains(const ash::wm::WmWindow* other) const { | 476 bool WmWindowMus::Contains(const wm::WmWindow* other) const { |
| 481 return other | 477 return other |
| 482 ? window_->Contains( | 478 ? window_->Contains( |
| 483 static_cast<const WmWindowMus*>(other)->window_) | 479 static_cast<const WmWindowMus*>(other)->window_) |
| 484 : false; | 480 : false; |
| 485 } | 481 } |
| 486 | 482 |
| 487 void WmWindowMus::SetShowState(ui::WindowShowState show_state) { | 483 void WmWindowMus::SetShowState(ui::WindowShowState show_state) { |
| 488 SetWindowShowState(window_, MojomWindowShowStateFromUI(show_state)); | 484 SetWindowShowState(window_, MojomWindowShowStateFromUI(show_state)); |
| 489 } | 485 } |
| 490 | 486 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 bool WmWindowMus::CanResize() const { | 524 bool WmWindowMus::CanResize() const { |
| 529 return widget_ ? widget_->widget_delegate()->CanResize() : false; | 525 return widget_ ? widget_->widget_delegate()->CanResize() : false; |
| 530 } | 526 } |
| 531 | 527 |
| 532 bool WmWindowMus::CanActivate() const { | 528 bool WmWindowMus::CanActivate() const { |
| 533 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not | 529 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not |
| 534 // replicated. | 530 // replicated. |
| 535 return widget_ != nullptr; | 531 return widget_ != nullptr; |
| 536 } | 532 } |
| 537 | 533 |
| 538 void WmWindowMus::StackChildAtTop(ash::wm::WmWindow* child) { | 534 void WmWindowMus::StackChildAtTop(wm::WmWindow* child) { |
| 539 GetMusWindow(child)->MoveToFront(); | 535 GetMusWindow(child)->MoveToFront(); |
| 540 } | 536 } |
| 541 | 537 |
| 542 void WmWindowMus::StackChildAtBottom(ash::wm::WmWindow* child) { | 538 void WmWindowMus::StackChildAtBottom(wm::WmWindow* child) { |
| 543 GetMusWindow(child)->MoveToBack(); | 539 GetMusWindow(child)->MoveToBack(); |
| 544 } | 540 } |
| 545 | 541 |
| 546 void WmWindowMus::StackChildAbove(ash::wm::WmWindow* child, | 542 void WmWindowMus::StackChildAbove(wm::WmWindow* child, wm::WmWindow* target) { |
| 547 ash::wm::WmWindow* target) { | |
| 548 GetMusWindow(child)->Reorder(GetMusWindow(target), | 543 GetMusWindow(child)->Reorder(GetMusWindow(target), |
| 549 mus::mojom::OrderDirection::ABOVE); | 544 ::mus::mojom::OrderDirection::ABOVE); |
| 550 } | 545 } |
| 551 | 546 |
| 552 void WmWindowMus::StackChildBelow(WmWindow* child, WmWindow* target) { | 547 void WmWindowMus::StackChildBelow(WmWindow* child, WmWindow* target) { |
| 553 GetMusWindow(child)->Reorder(GetMusWindow(target), | 548 GetMusWindow(child)->Reorder(GetMusWindow(target), |
| 554 mus::mojom::OrderDirection::BELOW); | 549 ::mus::mojom::OrderDirection::BELOW); |
| 555 } | 550 } |
| 556 | 551 |
| 557 void WmWindowMus::SetAlwaysOnTop(bool value) { | 552 void WmWindowMus::SetAlwaysOnTop(bool value) { |
| 558 mash::wm::SetAlwaysOnTop(window_, value); | 553 mus::SetAlwaysOnTop(window_, value); |
| 559 } | 554 } |
| 560 | 555 |
| 561 bool WmWindowMus::IsAlwaysOnTop() const { | 556 bool WmWindowMus::IsAlwaysOnTop() const { |
| 562 return mash::wm::IsAlwaysOnTop(window_); | 557 return mus::IsAlwaysOnTop(window_); |
| 563 } | 558 } |
| 564 | 559 |
| 565 void WmWindowMus::Hide() { | 560 void WmWindowMus::Hide() { |
| 566 window_->SetVisible(false); | 561 window_->SetVisible(false); |
| 567 } | 562 } |
| 568 | 563 |
| 569 void WmWindowMus::Show() { | 564 void WmWindowMus::Show() { |
| 570 window_->SetVisible(true); | 565 window_->SetVisible(true); |
| 571 } | 566 } |
| 572 | 567 |
| 573 void WmWindowMus::CloseWidget() { | 568 void WmWindowMus::CloseWidget() { |
| 574 DCHECK(widget_); | 569 DCHECK(widget_); |
| 575 // Allow the client to service the close request for remote widgets. | 570 // Allow the client to service the close request for remote widgets. |
| 576 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT) | 571 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT) |
| 577 window_->RequestClose(); | 572 window_->RequestClose(); |
| 578 else | 573 else |
| 579 widget_->Close(); | 574 widget_->Close(); |
| 580 } | 575 } |
| 581 | 576 |
| 582 bool WmWindowMus::IsFocused() const { | 577 bool WmWindowMus::IsFocused() const { |
| 583 return window_->HasFocus(); | 578 return window_->HasFocus(); |
| 584 } | 579 } |
| 585 | 580 |
| 586 bool WmWindowMus::IsActive() const { | 581 bool WmWindowMus::IsActive() const { |
| 587 mus::Window* focused = window_->window_tree()->GetFocusedWindow(); | 582 ::mus::Window* focused = window_->window_tree()->GetFocusedWindow(); |
| 588 return focused && window_->Contains(focused); | 583 return focused && window_->Contains(focused); |
| 589 } | 584 } |
| 590 | 585 |
| 591 void WmWindowMus::Activate() { | 586 void WmWindowMus::Activate() { |
| 592 window_->SetFocus(); | 587 window_->SetFocus(); |
| 593 ash::wm::WmWindow* top_level = GetToplevelWindow(); | 588 wm::WmWindow* top_level = GetToplevelWindow(); |
| 594 if (!top_level) | 589 if (!top_level) |
| 595 return; | 590 return; |
| 596 | 591 |
| 597 // TODO(sky): mus should do this too. | 592 // TODO(sky): mus should do this too. |
| 598 GetMusWindow(top_level)->MoveToFront(); | 593 GetMusWindow(top_level)->MoveToFront(); |
| 599 } | 594 } |
| 600 | 595 |
| 601 void WmWindowMus::Deactivate() { | 596 void WmWindowMus::Deactivate() { |
| 602 if (IsActive()) | 597 if (IsActive()) |
| 603 window_->window_tree()->ClearFocus(); | 598 window_->window_tree()->ClearFocus(); |
| 604 } | 599 } |
| 605 | 600 |
| 606 void WmWindowMus::SetFullscreen() { | 601 void WmWindowMus::SetFullscreen() { |
| 607 SetWindowShowState(window_, mus::mojom::ShowState::FULLSCREEN); | 602 SetWindowShowState(window_, ::mus::mojom::ShowState::FULLSCREEN); |
| 608 } | 603 } |
| 609 | 604 |
| 610 void WmWindowMus::Maximize() { | 605 void WmWindowMus::Maximize() { |
| 611 SetWindowShowState(window_, mus::mojom::ShowState::MAXIMIZED); | 606 SetWindowShowState(window_, ::mus::mojom::ShowState::MAXIMIZED); |
| 612 } | 607 } |
| 613 | 608 |
| 614 void WmWindowMus::Minimize() { | 609 void WmWindowMus::Minimize() { |
| 615 SetWindowShowState(window_, mus::mojom::ShowState::MINIMIZED); | 610 SetWindowShowState(window_, ::mus::mojom::ShowState::MINIMIZED); |
| 616 } | 611 } |
| 617 | 612 |
| 618 void WmWindowMus::Unminimize() { | 613 void WmWindowMus::Unminimize() { |
| 619 SetWindowShowState(window_, MojomWindowShowStateFromUI(restore_show_state_)); | 614 SetWindowShowState(window_, MojomWindowShowStateFromUI(restore_show_state_)); |
| 620 restore_show_state_ = ui::SHOW_STATE_DEFAULT; | 615 restore_show_state_ = ui::SHOW_STATE_DEFAULT; |
| 621 } | 616 } |
| 622 | 617 |
| 623 std::vector<ash::wm::WmWindow*> WmWindowMus::GetChildren() { | 618 std::vector<wm::WmWindow*> WmWindowMus::GetChildren() { |
| 624 return FromMusWindows(window_->children()); | 619 return FromMusWindows(window_->children()); |
| 625 } | 620 } |
| 626 | 621 |
| 627 ash::wm::WmWindow* WmWindowMus::GetChildByShellWindowId(int id) { | 622 wm::WmWindow* WmWindowMus::GetChildByShellWindowId(int id) { |
| 628 if (id == shell_window_id_) | 623 if (id == shell_window_id_) |
| 629 return this; | 624 return this; |
| 630 for (mus::Window* child : window_->children()) { | 625 for (::mus::Window* child : window_->children()) { |
| 631 ash::wm::WmWindow* result = Get(child)->GetChildByShellWindowId(id); | 626 wm::WmWindow* result = Get(child)->GetChildByShellWindowId(id); |
| 632 if (result) | 627 if (result) |
| 633 return result; | 628 return result; |
| 634 } | 629 } |
| 635 return nullptr; | 630 return nullptr; |
| 636 } | 631 } |
| 637 | 632 |
| 638 void WmWindowMus::ShowResizeShadow(int component) { | 633 void WmWindowMus::ShowResizeShadow(int component) { |
| 639 NOTIMPLEMENTED(); | 634 NOTIMPLEMENTED(); |
| 640 } | 635 } |
| 641 | 636 |
| 642 void WmWindowMus::HideResizeShadow() { | 637 void WmWindowMus::HideResizeShadow() { |
| 643 NOTIMPLEMENTED(); | 638 NOTIMPLEMENTED(); |
| 644 } | 639 } |
| 645 | 640 |
| 646 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( | 641 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( |
| 647 ash::wm::WmWindow::BoundsInScreenBehavior behavior) { | 642 wm::WmWindow::BoundsInScreenBehavior behavior) { |
| 648 // TODO: SetBoundsInScreen isn't fully implemented yet, | 643 // TODO: SetBoundsInScreen isn't fully implemented yet, |
| 649 // http://crbug.com/615552. | 644 // http://crbug.com/615552. |
| 650 NOTIMPLEMENTED(); | 645 NOTIMPLEMENTED(); |
| 651 } | 646 } |
| 652 | 647 |
| 653 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { | 648 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { |
| 654 if (snap_children_to_pixel_boundary_) | 649 if (snap_children_to_pixel_boundary_) |
| 655 return; | 650 return; |
| 656 | 651 |
| 657 snap_children_to_pixel_boundary_ = true; | 652 snap_children_to_pixel_boundary_ = true; |
| 658 FOR_EACH_OBSERVER( | 653 FOR_EACH_OBSERVER( |
| 659 ash::wm::WmWindowObserver, observers_, | 654 wm::WmWindowObserver, observers_, |
| 660 OnWindowPropertyChanged( | 655 OnWindowPropertyChanged( |
| 661 this, ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); | 656 this, wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); |
| 662 } | 657 } |
| 663 | 658 |
| 664 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { | 659 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { |
| 665 WmWindowMus* parent = Get(window_->parent()); | 660 WmWindowMus* parent = Get(window_->parent()); |
| 666 if (parent && parent->snap_children_to_pixel_boundary_) { | 661 if (parent && parent->snap_children_to_pixel_boundary_) { |
| 667 // TODO: implement snap to pixel: http://crbug.com/615554. | 662 // TODO: implement snap to pixel: http://crbug.com/615554. |
| 668 NOTIMPLEMENTED(); | 663 NOTIMPLEMENTED(); |
| 669 } | 664 } |
| 670 } | 665 } |
| 671 | 666 |
| 672 void WmWindowMus::SetChildrenUseExtendedHitRegion() { | 667 void WmWindowMus::SetChildrenUseExtendedHitRegion() { |
| 673 children_use_extended_hit_region_ = true; | 668 children_use_extended_hit_region_ = true; |
| 674 } | 669 } |
| 675 | 670 |
| 676 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) { | 671 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) { |
| 677 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented: | 672 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented: |
| 678 // http://crbug.com/615552. | 673 // http://crbug.com/615552. |
| 679 NOTIMPLEMENTED(); | 674 NOTIMPLEMENTED(); |
| 680 } | 675 } |
| 681 | 676 |
| 682 void WmWindowMus::AddObserver(ash::wm::WmWindowObserver* observer) { | 677 void WmWindowMus::AddObserver(wm::WmWindowObserver* observer) { |
| 683 observers_.AddObserver(observer); | 678 observers_.AddObserver(observer); |
| 684 } | 679 } |
| 685 | 680 |
| 686 void WmWindowMus::RemoveObserver(ash::wm::WmWindowObserver* observer) { | 681 void WmWindowMus::RemoveObserver(wm::WmWindowObserver* observer) { |
| 687 observers_.RemoveObserver(observer); | 682 observers_.RemoveObserver(observer); |
| 688 } | 683 } |
| 689 | 684 |
| 690 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { | 685 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { |
| 691 ash::wm::WmWindowObserver::TreeChangeParams wm_params; | 686 wm::WmWindowObserver::TreeChangeParams wm_params; |
| 692 wm_params.target = Get(params.target); | 687 wm_params.target = Get(params.target); |
| 693 wm_params.new_parent = Get(params.new_parent); | 688 wm_params.new_parent = Get(params.new_parent); |
| 694 wm_params.old_parent = Get(params.old_parent); | 689 wm_params.old_parent = Get(params.old_parent); |
| 695 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 690 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, |
| 696 OnWindowTreeChanged(this, wm_params)); | 691 OnWindowTreeChanged(this, wm_params)); |
| 697 } | 692 } |
| 698 | 693 |
| 699 void WmWindowMus::OnWindowReordered(mus::Window* window, | 694 void WmWindowMus::OnWindowReordered(::mus::Window* window, |
| 700 mus::Window* relative_window, | 695 ::mus::Window* relative_window, |
| 701 mus::mojom::OrderDirection direction) { | 696 ::mus::mojom::OrderDirection direction) { |
| 702 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 697 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, |
| 703 OnWindowStackingChanged(this)); | 698 OnWindowStackingChanged(this)); |
| 704 } | 699 } |
| 705 | 700 |
| 706 void WmWindowMus::OnWindowSharedPropertyChanged( | 701 void WmWindowMus::OnWindowSharedPropertyChanged( |
| 707 mus::Window* window, | 702 ::mus::Window* window, |
| 708 const std::string& name, | 703 const std::string& name, |
| 709 const std::vector<uint8_t>* old_data, | 704 const std::vector<uint8_t>* old_data, |
| 710 const std::vector<uint8_t>* new_data) { | 705 const std::vector<uint8_t>* new_data) { |
| 711 if (name == mus::mojom::WindowManager::kShowState_Property) { | 706 if (name == ::mus::mojom::WindowManager::kShowState_Property) { |
| 712 GetWindowState()->OnWindowShowStateChanged(); | 707 GetWindowState()->OnWindowShowStateChanged(); |
| 713 return; | 708 return; |
| 714 } | 709 } |
| 715 if (name == mus::mojom::WindowManager::kAlwaysOnTop_Property) { | 710 if (name == ::mus::mojom::WindowManager::kAlwaysOnTop_Property) { |
| 716 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 711 FOR_EACH_OBSERVER( |
| 717 OnWindowPropertyChanged( | 712 wm::WmWindowObserver, observers_, |
| 718 this, ash::wm::WmWindowProperty::ALWAYS_ON_TOP)); | 713 OnWindowPropertyChanged(this, wm::WmWindowProperty::ALWAYS_ON_TOP)); |
| 719 return; | 714 return; |
| 720 } | 715 } |
| 721 | 716 |
| 722 // Deal with snap to pixel. | 717 // Deal with snap to pixel. |
| 723 NOTIMPLEMENTED(); | 718 NOTIMPLEMENTED(); |
| 724 } | 719 } |
| 725 | 720 |
| 726 void WmWindowMus::OnWindowBoundsChanged(mus::Window* window, | 721 void WmWindowMus::OnWindowBoundsChanged(::mus::Window* window, |
| 727 const gfx::Rect& old_bounds, | 722 const gfx::Rect& old_bounds, |
| 728 const gfx::Rect& new_bounds) { | 723 const gfx::Rect& new_bounds) { |
| 729 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 724 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, |
| 730 OnWindowBoundsChanged(this, old_bounds, new_bounds)); | 725 OnWindowBoundsChanged(this, old_bounds, new_bounds)); |
| 731 } | 726 } |
| 732 | 727 |
| 733 void WmWindowMus::OnWindowDestroying(mus::Window* window) { | 728 void WmWindowMus::OnWindowDestroying(::mus::Window* window) { |
| 734 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 729 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, OnWindowDestroying(this)); |
| 735 OnWindowDestroying(this)); | |
| 736 } | 730 } |
| 737 | 731 |
| 738 } // namespace wm | 732 } // namespace mus |
| 739 } // namespace mash | 733 } // namespace ash |
| OLD | NEW |