Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 1953293004: PlatformWindowMus::SetBounds to NativeWidgetMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cast to PlatformWindowDelegate for OnBoundsChanged Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/mus/platform_window_mus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "components/mus/public/cpp/window_observer.h" 11 #include "components/mus/public/cpp/window_observer.h"
12 #include "components/mus/public/cpp/window_property.h" 12 #include "components/mus/public/cpp/window_property.h"
13 #include "components/mus/public/cpp/window_tree_connection.h" 13 #include "components/mus/public/cpp/window_tree_connection.h"
14 #include "components/mus/public/interfaces/cursor.mojom.h" 14 #include "components/mus/public/interfaces/cursor.mojom.h"
15 #include "mojo/converters/geometry/geometry_type_converters.h" 15 #include "mojo/converters/geometry/geometry_type_converters.h"
16 #include "ui/aura/client/default_capture_client.h" 16 #include "ui/aura/client/default_capture_client.h"
17 #include "ui/aura/client/window_tree_client.h" 17 #include "ui/aura/client/window_tree_client.h"
18 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
19 #include "ui/aura/layout_manager.h" 19 #include "ui/aura/layout_manager.h"
20 #include "ui/aura/mus/mus_util.h" 20 #include "ui/aura/mus/mus_util.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/aura/window_property.h" 22 #include "ui/aura/window_property.h"
23 #include "ui/base/hit_test.h" 23 #include "ui/base/hit_test.h"
24 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
25 #include "ui/native_theme/native_theme_aura.h" 25 #include "ui/native_theme/native_theme_aura.h"
26 #include "ui/platform_window/platform_window_delegate.h"
26 #include "ui/views/mus/platform_window_mus.h" 27 #include "ui/views/mus/platform_window_mus.h"
27 #include "ui/views/mus/surface_context_factory.h" 28 #include "ui/views/mus/surface_context_factory.h"
28 #include "ui/views/mus/window_manager_constants_converters.h" 29 #include "ui/views/mus/window_manager_constants_converters.h"
29 #include "ui/views/mus/window_manager_frame_values.h" 30 #include "ui/views/mus/window_manager_frame_values.h"
30 #include "ui/views/mus/window_tree_host_mus.h" 31 #include "ui/views/mus/window_tree_host_mus.h"
31 #include "ui/views/widget/native_widget_aura.h" 32 #include "ui/views/widget/native_widget_aura.h"
32 #include "ui/views/widget/widget_delegate.h" 33 #include "ui/views/widget/widget_delegate.h"
33 #include "ui/views/window/custom_frame_view.h" 34 #include "ui/views/window/custom_frame_view.h"
34 #include "ui/wm/core/base_focus_rules.h" 35 #include "ui/wm/core/base_focus_rules.h"
35 #include "ui/wm/core/capture_controller.h" 36 #include "ui/wm/core/capture_controller.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return SkBitmap(); 292 return SkBitmap();
292 return app_icon.GetRepresentation(1.f).sk_bitmap(); 293 return app_icon.GetRepresentation(1.f).sk_bitmap();
293 } 294 }
294 295
295 } // namespace 296 } // namespace
296 297
297 class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { 298 class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver {
298 public: 299 public:
299 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus) 300 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus)
300 : native_widget_mus_(native_widget_mus) { 301 : native_widget_mus_(native_widget_mus) {
301 native_widget_mus_->window_->AddObserver(this); 302 mus_window()->AddObserver(this);
302 } 303 }
303 304
304 ~MusWindowObserver() override { 305 ~MusWindowObserver() override {
305 native_widget_mus_->window_->RemoveObserver(this); 306 mus_window()->RemoveObserver(this);
306 } 307 }
307 308
308 // mus::WindowObserver: 309 // mus::WindowObserver:
309 void OnWindowVisibilityChanging(mus::Window* window) override { 310 void OnWindowVisibilityChanging(mus::Window* window) override {
310 native_widget_mus_->OnMusWindowVisibilityChanging(window); 311 native_widget_mus_->OnMusWindowVisibilityChanging(window);
311 } 312 }
312 void OnWindowVisibilityChanged(mus::Window* window) override { 313 void OnWindowVisibilityChanged(mus::Window* window) override {
313 native_widget_mus_->OnMusWindowVisibilityChanged(window); 314 native_widget_mus_->OnMusWindowVisibilityChanged(window);
314 } 315 }
316 void OnWindowBoundsChanged(mus::Window* window,
317 const gfx::Rect& old_bounds,
318 const gfx::Rect& new_bounds) override {
319 platform_window_delegate()->OnBoundsChanged(new_bounds);
320 }
315 321
316 private: 322 private:
323 mus::Window* mus_window() { return native_widget_mus_->window(); }
324 WindowTreeHostMus* window_tree_host() {
325 return native_widget_mus_->window_tree_host();
326 }
327 ui::PlatformWindowDelegate* platform_window_delegate() {
328 return static_cast<ui::PlatformWindowDelegate*>(
329 native_widget_mus_->window_tree_host());
330 }
331
317 NativeWidgetMus* native_widget_mus_; 332 NativeWidgetMus* native_widget_mus_;
318 333
319 DISALLOW_COPY_AND_ASSIGN(MusWindowObserver); 334 DISALLOW_COPY_AND_ASSIGN(MusWindowObserver);
320 }; 335 };
321 336
322 //////////////////////////////////////////////////////////////////////////////// 337 ////////////////////////////////////////////////////////////////////////////////
323 // NativeWidgetMus, public: 338 // NativeWidgetMus, public:
324 339
325 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, 340 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate,
326 shell::Connector* connector, 341 shell::Connector* connector,
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property); 730 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property);
716 } 731 }
717 return GetWindowBoundsInScreen(); 732 return GetWindowBoundsInScreen();
718 } 733 }
719 734
720 std::string NativeWidgetMus::GetWorkspace() const { 735 std::string NativeWidgetMus::GetWorkspace() const {
721 return std::string(); 736 return std::string();
722 } 737 }
723 738
724 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds) { 739 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds) {
725 if (!window_tree_host_) 740 if (!(window_ && window_tree_host_))
726 return; 741 return;
727 742
728 gfx::Size size(bounds.size()); 743 gfx::Size size(bounds.size());
729 const gfx::Size min_size = GetMinimumSize(); 744 const gfx::Size min_size = GetMinimumSize();
730 const gfx::Size max_size = GetMaximumSize(); 745 const gfx::Size max_size = GetMaximumSize();
731 if (!max_size.IsEmpty()) 746 if (!max_size.IsEmpty())
732 size.SetToMin(max_size); 747 size.SetToMin(max_size);
733 size.SetToMax(min_size); 748 size.SetToMax(min_size);
734 window_tree_host_->SetBounds(gfx::Rect(bounds.origin(), size)); 749 window_tree_host_->SetBounds(gfx::Rect(bounds.origin(), size));
750 window_->SetBounds(gfx::Rect(bounds.origin(), size));
735 } 751 }
736 752
737 void NativeWidgetMus::SetSize(const gfx::Size& size) { 753 void NativeWidgetMus::SetSize(const gfx::Size& size) {
738 if (!window_tree_host_) 754 if (!window_tree_host_)
739 return; 755 return;
740 756
741 gfx::Rect bounds = window_tree_host_->GetBounds(); 757 gfx::Rect bounds = window_tree_host_->GetBounds();
742 SetBounds(gfx::Rect(bounds.origin(), size)); 758 SetBounds(gfx::Rect(bounds.origin(), size));
743 } 759 }
744 760
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 window_tree_host_->Show(); 1150 window_tree_host_->Show();
1135 GetNativeWindow()->Show(); 1151 GetNativeWindow()->Show();
1136 } else { 1152 } else {
1137 window_tree_host_->Hide(); 1153 window_tree_host_->Hide();
1138 GetNativeWindow()->Hide(); 1154 GetNativeWindow()->Hide();
1139 } 1155 }
1140 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); 1156 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible());
1141 } 1157 }
1142 1158
1143 } // namespace views 1159 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/mus/platform_window_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698