Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mash/wm/bridge/wm_window_mus.h" | |
| 6 | |
| 7 #include "ash/wm/common/container_finder.h" | |
| 8 #include "ash/wm/common/window_state.h" | |
| 9 #include "ash/wm/common/wm_layout_manager.h" | |
| 10 #include "ash/wm/common/wm_window_observer.h" | |
| 11 #include "ash/wm/common/wm_window_property.h" | |
| 12 #include "components/mus/public/cpp/window.h" | |
| 13 #include "components/mus/public/cpp/window_property.h" | |
| 14 #include "components/mus/public/cpp/window_tree_connection.h" | |
| 15 #include "mash/wm/bridge/mus_layout_manager_adapter.h" | |
| 16 #include "mash/wm/bridge/wm_globals_mus.h" | |
| 17 #include "mash/wm/bridge/wm_root_window_controller_mus.h" | |
| 18 #include "mash/wm/property_util.h" | |
| 19 #include "ui/aura/mus/mus_util.h" | |
| 20 #include "ui/base/hit_test.h" | |
| 21 #include "ui/gfx/display.h" | |
| 22 #include "ui/views/widget/widget.h" | |
| 23 #include "ui/views/widget/widget_delegate.h" | |
| 24 | |
| 25 MUS_DECLARE_WINDOW_PROPERTY_TYPE(mash::wm::WmWindowMus*); | |
| 26 | |
| 27 namespace mash { | |
| 28 namespace wm { | |
| 29 | |
| 30 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(mash::wm::WmWindowMus, | |
| 31 kWmWindowKey, | |
| 32 nullptr); | |
| 33 MUS_DEFINE_LOCAL_WINDOW_PROPERTY_KEY(int, kShellWindowIdKey, -1); | |
| 34 | |
| 35 namespace { | |
| 36 | |
| 37 mus::Window* GetMusWindowByShellId(mus::Window* window, int id) { | |
| 38 if (window->GetLocalProperty(kShellWindowIdKey) == id) | |
| 39 return window; | |
| 40 | |
| 41 for (mus::Window* child : window->children()) { | |
| 42 mus::Window* result = GetMusWindowByShellId(child, id); | |
| 43 if (result) | |
| 44 return result; | |
| 45 } | |
| 46 return nullptr; | |
| 47 } | |
| 48 | |
| 49 // This classes is used so that the WindowState constructor can be made | |
| 50 // protected. GetWindowState() is the only place that should be creating | |
| 51 // WindowState. | |
| 52 class WindowStateMus : public ash::wm::WindowState { | |
| 53 public: | |
| 54 explicit WindowStateMus(ash::wm::WmWindow* window) | |
| 55 : ash::wm::WindowState(window) {} | |
| 56 ~WindowStateMus() override {} | |
| 57 | |
| 58 private: | |
| 59 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); | |
| 60 }; | |
| 61 | |
| 62 ui::WindowShowState UIWindowShowStateFromMojom(mus::mojom::ShowState state) { | |
| 63 switch (state) { | |
| 64 case mus::mojom::ShowState::DEFAULT: | |
| 65 return ui::SHOW_STATE_DEFAULT; | |
| 66 case mus::mojom::ShowState::NORMAL: | |
| 67 return ui::SHOW_STATE_NORMAL; | |
| 68 case mus::mojom::ShowState::MINIMIZED: | |
| 69 return ui::SHOW_STATE_MINIMIZED; | |
| 70 case mus::mojom::ShowState::MAXIMIZED: | |
| 71 return ui::SHOW_STATE_MAXIMIZED; | |
| 72 case mus::mojom::ShowState::INACTIVE: | |
| 73 return ui::SHOW_STATE_INACTIVE; | |
| 74 case mus::mojom::ShowState::FULLSCREEN: | |
| 75 return ui::SHOW_STATE_FULLSCREEN; | |
| 76 case mus::mojom::ShowState::DOCKED: | |
| 77 return ui::SHOW_STATE_DOCKED; | |
| 78 default: | |
| 79 break; | |
| 80 } | |
| 81 return ui::SHOW_STATE_DEFAULT; | |
| 82 } | |
| 83 | |
| 84 mus::mojom::ShowState MojomWindowShowStateFromUI(ui::WindowShowState state) { | |
| 85 switch (state) { | |
| 86 case ui::SHOW_STATE_DEFAULT: | |
| 87 return mus::mojom::ShowState::DEFAULT; | |
| 88 case ui::SHOW_STATE_NORMAL: | |
| 89 return mus::mojom::ShowState::NORMAL; | |
| 90 case ui::SHOW_STATE_MINIMIZED: | |
| 91 return mus::mojom::ShowState::MINIMIZED; | |
| 92 case ui::SHOW_STATE_MAXIMIZED: | |
| 93 return mus::mojom::ShowState::MAXIMIZED; | |
| 94 case ui::SHOW_STATE_INACTIVE: | |
| 95 return mus::mojom::ShowState::INACTIVE; | |
| 96 case ui::SHOW_STATE_FULLSCREEN: | |
| 97 return mus::mojom::ShowState::FULLSCREEN; | |
| 98 case ui::SHOW_STATE_DOCKED: | |
| 99 return mus::mojom::ShowState::DOCKED; | |
| 100 default: | |
| 101 break; | |
| 102 } | |
| 103 return mus::mojom::ShowState::DEFAULT; | |
| 104 } | |
| 105 | |
| 106 } // namespace | |
| 107 | |
| 108 WmWindowMus::WmWindowMus(mus::Window* window) : window_(window) { | |
| 109 window_->AddObserver(this); | |
| 110 window_->SetLocalProperty(kWmWindowKey, this); | |
| 111 window_state_.reset(new WindowStateMus(this)); | |
| 112 } | |
| 113 | |
| 114 WmWindowMus::~WmWindowMus() { | |
| 115 window_->RemoveObserver(this); | |
| 116 } | |
| 117 | |
| 118 // static | |
| 119 WmWindowMus* WmWindowMus::Get(mus::Window* window) { | |
| 120 if (!window) | |
| 121 return nullptr; | |
| 122 | |
| 123 wm::WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); | |
| 124 if (wm_window) | |
| 125 return wm_window; | |
| 126 // WmWindowMus is owned by the mus::Window. | |
| 127 return new WmWindowMus(window); | |
| 128 } | |
| 129 | |
| 130 // static | |
| 131 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { | |
| 132 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); | |
| 133 } | |
| 134 | |
| 135 // static | |
| 136 const mus::Window* WmWindowMus::GetMusWindow( | |
| 137 const ash::wm::WmWindow* wm_window) { | |
| 138 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); | |
| 139 } | |
| 140 | |
| 141 // static | |
| 142 std::vector<ash::wm::WmWindow*> WmWindowMus::FromMusWindows( | |
| 143 const std::vector<mus::Window*>& mus_windows) { | |
| 144 std::vector<ash::wm::WmWindow*> result(mus_windows.size()); | |
| 145 for (size_t i = 0; i < mus_windows.size(); ++i) | |
| 146 result[i] = Get(mus_windows[i]); | |
| 147 return result; | |
| 148 } | |
| 149 | |
| 150 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() | |
| 151 const { | |
| 152 return WmRootWindowControllerMus::Get(window_->GetRoot()); | |
| 153 } | |
| 154 | |
| 155 const ash::wm::WmWindow* WmWindowMus::GetRootWindow() const { | |
| 156 return Get(window_->GetRoot()); | |
| 157 } | |
| 158 | |
| 159 ash::wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { | |
| 160 return GetRootWindowControllerMus(); | |
| 161 } | |
| 162 | |
| 163 ash::wm::WmGlobals* WmWindowMus::GetGlobals() const { | |
| 164 return WmGlobalsMus::Get(); | |
| 165 } | |
| 166 | |
| 167 void WmWindowMus::SetShellWindowId(int id) { | |
| 168 window_->set_local_id(id); | |
| 169 } | |
| 170 | |
| 171 int WmWindowMus::GetShellWindowId() const { | |
| 172 return window_->local_id(); | |
| 173 } | |
| 174 | |
| 175 ui::wm::WindowType WmWindowMus::GetType() const { | |
| 176 return GetWmWindowType(window_); | |
| 177 } | |
| 178 | |
| 179 ui::Layer* WmWindowMus::GetLayer() { | |
| 180 // TODO(sky): this function should be nuked entirely. | |
| 181 NOTIMPLEMENTED(); | |
| 182 return widget_ ? widget_->GetLayer() : nullptr; | |
| 183 } | |
| 184 | |
| 185 display::Display WmWindowMus::GetDisplayNearestWindow() { | |
| 186 // TODO(sky): deal with null rwc. | |
| 187 return GetRootWindowControllerMus()->GetDisplay(); | |
| 188 } | |
| 189 | |
| 190 bool WmWindowMus::HasNonClientArea() { | |
| 191 return widget_ ? true : false; | |
| 192 } | |
| 193 | |
| 194 int WmWindowMus::GetNonClientComponent(const gfx::Point& location) { | |
| 195 return widget_ ? widget_->GetNonClientComponent(location) : HTNOWHERE; | |
| 196 } | |
| 197 | |
| 198 gfx::Point WmWindowMus::ConvertPointToTarget(const WmWindow* target, | |
| 199 const gfx::Point& point) const { | |
| 200 const mus::Window* target_window = GetMusWindow(target); | |
| 201 if (target_window->Contains(window_)) { | |
| 202 gfx::Point result = point; | |
| 203 const mus::Window* window = window_; | |
| 204 while (window != target_window) { | |
| 205 result += window->bounds().origin().OffsetFromOrigin(); | |
| 206 window = window->parent(); | |
| 207 } | |
| 208 return result; | |
| 209 } | |
| 210 if (window_->Contains(target_window)) { | |
| 211 gfx::Point result(point); | |
|
James Cook
2016/05/06 19:46:47
nit: Either result = point here, or result(point)
sky
2016/05/06 22:12:57
Done.
| |
| 212 result -= | |
| 213 target->ConvertPointToTarget(this, gfx::Point()).OffsetFromOrigin(); | |
| 214 return result; | |
| 215 } | |
| 216 // Different roots. | |
| 217 gfx::Point point_in_screen = | |
| 218 GetRootWindowControllerMus()->ConvertPointToScreen(this, point); | |
| 219 return AsWmWindowMus(target) | |
| 220 ->GetRootWindowControllerMus() | |
| 221 ->ConvertPointFromScreen(AsWmWindowMus(target), point_in_screen); | |
| 222 } | |
| 223 | |
| 224 gfx::Point WmWindowMus::ConvertPointToScreen(const gfx::Point& point) const { | |
| 225 return GetRootWindowControllerMus()->ConvertPointToScreen(this, point); | |
| 226 } | |
| 227 | |
| 228 gfx::Point WmWindowMus::ConvertPointFromScreen(const gfx::Point& point) const { | |
| 229 return GetRootWindowControllerMus()->ConvertPointFromScreen(this, point); | |
| 230 } | |
| 231 | |
| 232 gfx::Rect WmWindowMus::ConvertRectToScreen(const gfx::Rect& rect) const { | |
| 233 return gfx::Rect(ConvertPointToScreen(rect.origin()), rect.size()); | |
| 234 } | |
| 235 | |
| 236 gfx::Rect WmWindowMus::ConvertRectFromScreen(const gfx::Rect& rect) const { | |
| 237 return gfx::Rect(ConvertPointFromScreen(rect.origin()), rect.size()); | |
| 238 } | |
| 239 | |
| 240 gfx::Size WmWindowMus::GetMinimumSize() const { | |
| 241 return widget_ ? widget_->GetMinimumSize() : gfx::Size(); | |
| 242 } | |
| 243 | |
| 244 gfx::Size WmWindowMus::GetMaximumSize() const { | |
| 245 return widget_ ? widget_->GetMaximumSize() : gfx::Size(); | |
| 246 } | |
| 247 | |
| 248 bool WmWindowMus::GetTargetVisibility() const { | |
| 249 NOTIMPLEMENTED(); | |
| 250 return window_->visible(); | |
| 251 } | |
| 252 | |
| 253 bool WmWindowMus::IsVisible() const { | |
| 254 return window_->visible(); | |
| 255 } | |
| 256 | |
| 257 bool WmWindowMus::IsSystemModal() const { | |
| 258 NOTIMPLEMENTED(); | |
| 259 return false; | |
| 260 } | |
| 261 | |
| 262 bool WmWindowMus::GetBoolProperty(ash::wm::WmWindowProperty key) { | |
| 263 NOTIMPLEMENTED(); | |
| 264 switch (key) { | |
| 265 case ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUDARY: | |
| 266 return true; | |
| 267 | |
| 268 case ash::wm::WmWindowProperty::ALWAYS_ON_TOP: | |
| 269 return false; | |
| 270 | |
| 271 default: | |
| 272 NOTREACHED(); | |
| 273 break; | |
| 274 } | |
| 275 | |
| 276 NOTREACHED(); | |
| 277 return false; | |
| 278 } | |
| 279 | |
| 280 int WmWindowMus::GetIntProperty(ash::wm::WmWindowProperty key) { | |
| 281 NOTIMPLEMENTED(); | |
| 282 if (key == ash::wm::WmWindowProperty::SHELF_ID) | |
| 283 return 0; | |
| 284 | |
| 285 NOTREACHED(); | |
| 286 return 0; | |
| 287 } | |
| 288 | |
| 289 const ash::wm::WindowState* WmWindowMus::GetWindowState() const { | |
| 290 return window_state_.get(); | |
| 291 } | |
| 292 | |
| 293 ash::wm::WmWindow* WmWindowMus::GetToplevelWindow() { | |
| 294 return WmGlobalsMus::GetToplevelAncestor(window_); | |
| 295 } | |
| 296 | |
| 297 void WmWindowMus::SetParentUsingContext(WmWindow* context, | |
| 298 const gfx::Rect& screen_bounds) { | |
| 299 GetDefaultParent(context, this, screen_bounds)->AddChild(this); | |
| 300 } | |
| 301 | |
| 302 void WmWindowMus::AddChild(WmWindow* window) { | |
| 303 window_->AddChild(GetMusWindow(window)); | |
| 304 } | |
| 305 | |
| 306 ash::wm::WmWindow* WmWindowMus::GetParent() { | |
| 307 return Get(window_->parent()); | |
| 308 } | |
| 309 | |
| 310 const ash::wm::WmWindow* WmWindowMus::GetTransientParent() const { | |
| 311 return Get(window_->transient_parent()); | |
| 312 } | |
| 313 | |
| 314 std::vector<ash::wm::WmWindow*> WmWindowMus::GetTransientChildren() { | |
| 315 return FromMusWindows(window_->transient_children()); | |
| 316 } | |
| 317 | |
| 318 void WmWindowMus::SetLayoutManager( | |
| 319 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager) { | |
| 320 if (layout_manager) { | |
| 321 layout_manager_adapter_.reset( | |
| 322 new MusLayoutManagerAdapter(window_, std::move(layout_manager))); | |
| 323 } else { | |
| 324 layout_manager_adapter_.reset(); | |
| 325 } | |
| 326 } | |
| 327 | |
| 328 ash::wm::WmLayoutManager* WmWindowMus::GetLayoutManager() { | |
| 329 return layout_manager_adapter_ ? layout_manager_adapter_->layout_manager() | |
| 330 : nullptr; | |
| 331 } | |
| 332 | |
| 333 void WmWindowMus::SetVisibilityAnimationType(int type) { | |
| 334 NOTIMPLEMENTED(); | |
| 335 } | |
| 336 | |
| 337 void WmWindowMus::SetVisibilityAnimationDuration(base::TimeDelta delta) { | |
| 338 NOTIMPLEMENTED(); | |
| 339 } | |
| 340 | |
| 341 void WmWindowMus::Animate(::wm::WindowAnimationType type) { | |
| 342 NOTIMPLEMENTED(); | |
| 343 } | |
| 344 | |
| 345 void WmWindowMus::SetBounds(const gfx::Rect& bounds) { | |
| 346 if (layout_manager_adapter_) | |
| 347 layout_manager_adapter_->layout_manager()->SetChildBounds(this, bounds); | |
| 348 else | |
| 349 window_->SetBounds(bounds); | |
| 350 } | |
| 351 | |
| 352 void WmWindowMus::SetBoundsWithTransitionDelay(const gfx::Rect& bounds, | |
| 353 base::TimeDelta delta) { | |
| 354 NOTIMPLEMENTED(); | |
| 355 SetBounds(bounds); | |
| 356 } | |
| 357 | |
| 358 void WmWindowMus::SetBoundsDirect(const gfx::Rect& bounds) { | |
| 359 window_->SetBounds(bounds); | |
| 360 SnapToPixelBoundaryIfNecessary(); | |
| 361 } | |
| 362 | |
| 363 void WmWindowMus::SetBoundsDirectAnimated(const gfx::Rect& bounds) { | |
| 364 NOTIMPLEMENTED(); | |
| 365 SetBoundsDirect(bounds); | |
| 366 } | |
| 367 | |
| 368 void WmWindowMus::SetBoundsDirectCrossFade(const gfx::Rect& bounds) { | |
| 369 NOTIMPLEMENTED(); | |
| 370 SetBoundsDirect(bounds); | |
| 371 } | |
| 372 | |
| 373 void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | |
| 374 const display::Display& dst_display) { | |
| 375 // TODO(sky): need to find WmRootWindowControllerMus for dst_display and | |
| 376 // convert. | |
| 377 NOTIMPLEMENTED(); | |
| 378 SetBounds(ConvertRectFromScreen(bounds_in_screen)); | |
| 379 } | |
| 380 | |
| 381 gfx::Rect WmWindowMus::GetBoundsInScreen() const { | |
| 382 return ConvertRectToScreen(window_->bounds()); | |
| 383 } | |
| 384 | |
| 385 const gfx::Rect& WmWindowMus::GetBounds() const { | |
| 386 return window_->bounds(); | |
| 387 } | |
| 388 | |
| 389 gfx::Rect WmWindowMus::GetTargetBounds() { | |
| 390 NOTIMPLEMENTED(); | |
| 391 return window_->bounds(); | |
| 392 } | |
| 393 | |
| 394 void WmWindowMus::ClearRestoreBounds() { | |
| 395 restore_bounds_in_screen_.reset(); | |
| 396 } | |
| 397 | |
| 398 void WmWindowMus::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { | |
| 399 restore_bounds_in_screen_.reset(new gfx::Rect(bounds)); | |
| 400 } | |
| 401 | |
| 402 gfx::Rect WmWindowMus::GetRestoreBoundsInScreen() const { | |
| 403 return *restore_bounds_in_screen_; | |
| 404 } | |
| 405 | |
| 406 bool WmWindowMus::Contains(const ash::wm::WmWindow* other) const { | |
| 407 return other | |
| 408 ? window_->Contains( | |
| 409 static_cast<const WmWindowMus*>(other)->window_) | |
| 410 : false; | |
| 411 } | |
| 412 | |
| 413 void WmWindowMus::SetShowState(ui::WindowShowState show_state) { | |
| 414 SetWindowShowState(window_, MojomWindowShowStateFromUI(show_state)); | |
| 415 } | |
| 416 | |
| 417 ui::WindowShowState WmWindowMus::GetShowState() const { | |
| 418 return UIWindowShowStateFromMojom(GetWindowShowState(window_)); | |
| 419 } | |
| 420 | |
| 421 void WmWindowMus::SetRestoreShowState(ui::WindowShowState show_state) { | |
| 422 restore_show_state_ = show_state; | |
| 423 } | |
| 424 | |
| 425 void WmWindowMus::SetLockedToRoot(bool value) { | |
| 426 // TODO(sky): there is no getter for this. Investigate where used. | |
| 427 NOTIMPLEMENTED(); | |
| 428 } | |
| 429 | |
| 430 void WmWindowMus::SetCapture() { | |
| 431 window_->SetCapture(); | |
| 432 } | |
| 433 | |
| 434 bool WmWindowMus::HasCapture() { | |
| 435 return window_->HasCapture(); | |
| 436 } | |
| 437 | |
| 438 void WmWindowMus::ReleaseCapture() { | |
| 439 window_->ReleaseCapture(); | |
| 440 } | |
| 441 | |
| 442 bool WmWindowMus::HasRestoreBounds() const { | |
| 443 return restore_bounds_in_screen_.get() != nullptr; | |
| 444 } | |
| 445 | |
| 446 bool WmWindowMus::CanMaximize() const { | |
| 447 return widget_ ? widget_->widget_delegate()->CanMaximize() : false; | |
| 448 } | |
| 449 | |
| 450 bool WmWindowMus::CanMinimize() const { | |
| 451 return widget_ ? widget_->widget_delegate()->CanMinimize() : false; | |
| 452 } | |
| 453 | |
| 454 bool WmWindowMus::CanResize() const { | |
| 455 return widget_ ? widget_->widget_delegate()->CanResize() : false; | |
| 456 } | |
| 457 | |
| 458 bool WmWindowMus::CanActivate() const { | |
| 459 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not | |
|
James Cook
2016/05/06 19:46:47
Can this use Widget::CanActivate()? Or do you nee
sky
2016/05/06 22:12:57
I think we only need it for widgets, but I don't t
| |
| 460 // replicated. | |
| 461 return widget_ != nullptr; | |
| 462 } | |
| 463 | |
| 464 void WmWindowMus::StackChildAtTop(ash::wm::WmWindow* child) { | |
| 465 GetMusWindow(child)->MoveToFront(); | |
| 466 } | |
| 467 | |
| 468 void WmWindowMus::StackChildAtBottom(ash::wm::WmWindow* child) { | |
| 469 GetMusWindow(child)->MoveToBack(); | |
| 470 } | |
| 471 | |
| 472 void WmWindowMus::StackChildAbove(ash::wm::WmWindow* child, | |
| 473 ash::wm::WmWindow* target) { | |
| 474 GetMusWindow(child)->Reorder(GetMusWindow(target), | |
| 475 mus::mojom::OrderDirection::ABOVE); | |
| 476 } | |
| 477 | |
| 478 void WmWindowMus::StackChildBelow(WmWindow* child, WmWindow* target) { | |
| 479 GetMusWindow(child)->Reorder(GetMusWindow(target), | |
| 480 mus::mojom::OrderDirection::BELOW); | |
| 481 } | |
| 482 | |
| 483 void WmWindowMus::SetAlwaysOnTop(bool value) { | |
| 484 // TODO(sky): need to set property on window. | |
| 485 NOTIMPLEMENTED(); | |
| 486 } | |
| 487 | |
| 488 bool WmWindowMus::IsAlwaysOnTop() const { | |
| 489 // TODO(sky): need to set property on window. | |
| 490 NOTIMPLEMENTED(); | |
| 491 return false; | |
| 492 } | |
| 493 | |
| 494 void WmWindowMus::Hide() { | |
| 495 window_->SetVisible(false); | |
| 496 } | |
| 497 | |
| 498 void WmWindowMus::Show() { | |
| 499 window_->SetVisible(true); | |
| 500 } | |
| 501 | |
| 502 bool WmWindowMus::IsFocused() const { | |
| 503 return window_->HasFocus(); | |
| 504 } | |
| 505 | |
| 506 bool WmWindowMus::IsActive() const { | |
| 507 mus::Window* focused = window_->connection()->GetFocusedWindow(); | |
| 508 return focused && window_->Contains(focused); | |
| 509 } | |
| 510 | |
| 511 void WmWindowMus::Activate() { | |
| 512 window_->SetFocus(); | |
| 513 } | |
| 514 | |
| 515 void WmWindowMus::Deactivate() { | |
| 516 if (IsActive()) | |
| 517 window_->connection()->ClearFocus(); | |
| 518 } | |
| 519 | |
| 520 void WmWindowMus::SetFullscreen() { | |
| 521 SetWindowShowState(window_, mus::mojom::ShowState::FULLSCREEN); | |
| 522 } | |
| 523 | |
| 524 void WmWindowMus::Maximize() { | |
| 525 SetWindowShowState(window_, mus::mojom::ShowState::MAXIMIZED); | |
| 526 } | |
| 527 | |
| 528 void WmWindowMus::Minimize() { | |
| 529 SetWindowShowState(window_, mus::mojom::ShowState::MINIMIZED); | |
| 530 } | |
| 531 | |
| 532 void WmWindowMus::Unminimize() { | |
| 533 SetWindowShowState(window_, MojomWindowShowStateFromUI(restore_show_state_)); | |
| 534 restore_show_state_ = ui::SHOW_STATE_DEFAULT; | |
| 535 } | |
| 536 | |
| 537 std::vector<ash::wm::WmWindow*> WmWindowMus::GetChildren() { | |
| 538 return FromMusWindows(window_->children()); | |
| 539 } | |
| 540 | |
| 541 ash::wm::WmWindow* WmWindowMus::GetChildByShellWindowId(int id) { | |
| 542 return Get(GetMusWindowByShellId(window_, id)); | |
| 543 } | |
| 544 | |
| 545 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { | |
| 546 NOTIMPLEMENTED(); | |
| 547 } | |
| 548 | |
| 549 void WmWindowMus::AddObserver(ash::wm::WmWindowObserver* observer) { | |
| 550 observers_.AddObserver(observer); | |
| 551 } | |
| 552 | |
| 553 void WmWindowMus::RemoveObserver(ash::wm::WmWindowObserver* observer) { | |
| 554 observers_.RemoveObserver(observer); | |
| 555 } | |
| 556 | |
| 557 void WmWindowMus::NotifyStackingChanged() { | |
| 558 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | |
| 559 OnWindowStackingChanged(this)); | |
| 560 } | |
| 561 | |
| 562 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { | |
| 563 ash::wm::WmWindowObserver::TreeChangeParams wm_params; | |
| 564 wm_params.target = Get(params.target); | |
| 565 wm_params.new_parent = Get(params.new_parent); | |
| 566 wm_params.old_parent = Get(params.old_parent); | |
| 567 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | |
| 568 OnWindowTreeChanged(this, wm_params)); | |
| 569 } | |
| 570 | |
| 571 void WmWindowMus::OnWindowReordered(mus::Window* window, | |
| 572 mus::Window* relative_window, | |
| 573 mus::mojom::OrderDirection direction) { | |
| 574 if (!window_->parent()) | |
| 575 return; | |
| 576 | |
| 577 static_cast<WmWindowMus*>(Get(window_->parent()))->NotifyStackingChanged(); | |
| 578 } | |
| 579 | |
| 580 void WmWindowMus::OnWindowSharedPropertyChanged( | |
| 581 mus::Window* window, | |
| 582 const std::string& name, | |
| 583 const std::vector<uint8_t>* old_data, | |
| 584 const std::vector<uint8_t>* new_data) { | |
| 585 // Deal with always on top and snap. | |
| 586 NOTIMPLEMENTED(); | |
| 587 } | |
| 588 | |
| 589 void WmWindowMus::OnWindowBoundsChanged(mus::Window* window, | |
| 590 const gfx::Rect& old_bounds, | |
| 591 const gfx::Rect& new_bounds) { | |
| 592 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | |
| 593 OnWindowBoundsChanged(this, old_bounds, new_bounds)); | |
| 594 } | |
| 595 | |
| 596 void WmWindowMus::OnWindowDestroying(mus::Window* window) { | |
| 597 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | |
| 598 OnWindowDestroying(this)); | |
| 599 } | |
| 600 | |
| 601 } // namespace wm | |
| 602 } // namespace mash | |
| OLD | NEW |