Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "components/mus/public/cpp/property_type_converters.h" | 9 #include "components/mus/public/cpp/property_type_converters.h" |
| 10 #include "components/mus/public/cpp/window.h" | 10 #include "components/mus/public/cpp/window.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 return SkBitmap(); | 291 return SkBitmap(); |
| 292 return app_icon.GetRepresentation(1.f).sk_bitmap(); | 292 return app_icon.GetRepresentation(1.f).sk_bitmap(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace | 295 } // namespace |
| 296 | 296 |
| 297 class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { | 297 class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { |
| 298 public: | 298 public: |
| 299 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus) | 299 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus) |
| 300 : native_widget_mus_(native_widget_mus) { | 300 : native_widget_mus_(native_widget_mus) { |
| 301 native_widget_mus_->window_->AddObserver(this); | 301 mus_window()->AddObserver(this); |
| 302 } | 302 } |
| 303 | 303 |
| 304 ~MusWindowObserver() override { | 304 ~MusWindowObserver() override { |
| 305 native_widget_mus_->window_->RemoveObserver(this); | 305 mus_window()->RemoveObserver(this); |
| 306 } | 306 } |
| 307 | 307 |
| 308 // mus::WindowObserver: | 308 // mus::WindowObserver: |
| 309 void OnWindowVisibilityChanging(mus::Window* window) override { | 309 void OnWindowVisibilityChanging(mus::Window* window) override { |
| 310 native_widget_mus_->OnMusWindowVisibilityChanging(window); | 310 native_widget_mus_->OnMusWindowVisibilityChanging(window); |
| 311 } | 311 } |
| 312 void OnWindowVisibilityChanged(mus::Window* window) override { | 312 void OnWindowVisibilityChanged(mus::Window* window) override { |
| 313 native_widget_mus_->OnMusWindowVisibilityChanged(window); | 313 native_widget_mus_->OnMusWindowVisibilityChanged(window); |
| 314 } | 314 } |
| 315 void OnWindowBoundsChanged(mus::Window* window, | |
| 316 const gfx::Rect& old_bounds, | |
| 317 const gfx::Rect& new_bounds) override { | |
| 318 window_tree_host()->OnBoundsChanged(new_bounds); | |
| 319 } | |
| 315 | 320 |
| 316 private: | 321 private: |
| 322 mus::Window* mus_window() { return native_widget_mus_->window(); } | |
| 323 WindowTreeHostMus* window_tree_host() { | |
|
sadrul
2016/05/09 20:19:46
Change this to aura::WindowTreeHost*. That should
Mark Dittmer
2016/05/10 13:26:03
I believe OnBoundsChanged is part of the PlatformW
| |
| 324 return native_widget_mus_->window_tree_host(); | |
| 325 } | |
| 326 | |
| 317 NativeWidgetMus* native_widget_mus_; | 327 NativeWidgetMus* native_widget_mus_; |
| 318 | 328 |
| 319 DISALLOW_COPY_AND_ASSIGN(MusWindowObserver); | 329 DISALLOW_COPY_AND_ASSIGN(MusWindowObserver); |
| 320 }; | 330 }; |
| 321 | 331 |
| 322 //////////////////////////////////////////////////////////////////////////////// | 332 //////////////////////////////////////////////////////////////////////////////// |
| 323 // NativeWidgetMus, public: | 333 // NativeWidgetMus, public: |
| 324 | 334 |
| 325 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, | 335 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
| 326 shell::Connector* connector, | 336 shell::Connector* connector, |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property); | 725 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property); |
| 716 } | 726 } |
| 717 return GetWindowBoundsInScreen(); | 727 return GetWindowBoundsInScreen(); |
| 718 } | 728 } |
| 719 | 729 |
| 720 std::string NativeWidgetMus::GetWorkspace() const { | 730 std::string NativeWidgetMus::GetWorkspace() const { |
| 721 return std::string(); | 731 return std::string(); |
| 722 } | 732 } |
| 723 | 733 |
| 724 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds) { | 734 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds) { |
| 725 if (!window_tree_host_) | 735 if (!(window_ && window_tree_host_)) |
| 726 return; | 736 return; |
| 727 | 737 |
| 728 gfx::Size size(bounds.size()); | 738 gfx::Size size(bounds.size()); |
| 729 const gfx::Size min_size = GetMinimumSize(); | 739 const gfx::Size min_size = GetMinimumSize(); |
| 730 const gfx::Size max_size = GetMaximumSize(); | 740 const gfx::Size max_size = GetMaximumSize(); |
| 731 if (!max_size.IsEmpty()) | 741 if (!max_size.IsEmpty()) |
| 732 size.SetToMin(max_size); | 742 size.SetToMin(max_size); |
| 733 size.SetToMax(min_size); | 743 size.SetToMax(min_size); |
| 734 window_tree_host_->SetBounds(gfx::Rect(bounds.origin(), size)); | 744 window_tree_host_->SetBounds(gfx::Rect(bounds.origin(), size)); |
| 745 window_->SetBounds(gfx::Rect(bounds.origin(), size)); | |
| 735 } | 746 } |
| 736 | 747 |
| 737 void NativeWidgetMus::SetSize(const gfx::Size& size) { | 748 void NativeWidgetMus::SetSize(const gfx::Size& size) { |
| 738 if (!window_tree_host_) | 749 if (!window_tree_host_) |
| 739 return; | 750 return; |
| 740 | 751 |
| 741 gfx::Rect bounds = window_tree_host_->GetBounds(); | 752 gfx::Rect bounds = window_tree_host_->GetBounds(); |
| 742 SetBounds(gfx::Rect(bounds.origin(), size)); | 753 SetBounds(gfx::Rect(bounds.origin(), size)); |
| 743 } | 754 } |
| 744 | 755 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1134 window_tree_host_->Show(); | 1145 window_tree_host_->Show(); |
| 1135 GetNativeWindow()->Show(); | 1146 GetNativeWindow()->Show(); |
| 1136 } else { | 1147 } else { |
| 1137 window_tree_host_->Hide(); | 1148 window_tree_host_->Hide(); |
| 1138 GetNativeWindow()->Hide(); | 1149 GetNativeWindow()->Hide(); |
| 1139 } | 1150 } |
| 1140 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); | 1151 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); |
| 1141 } | 1152 } |
| 1142 | 1153 |
| 1143 } // namespace views | 1154 } // namespace views |
| OLD | NEW |