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 "mash/wm/non_client_frame_controller.h" | 5 #include "mash/wm/non_client_frame_controller.h" |
6 | 6 |
7 #include "components/mus/public/cpp/window.h" | 7 #include "components/mus/public/cpp/window.h" |
8 #include "mash/wm/non_client_frame_view_impl.h" | 8 #include "mash/wm/frame/non_client_frame_view_mash.h" |
9 #include "mash/wm/property_util.h" | 9 #include "mash/wm/property_util.h" |
10 #include "ui/views/mus/native_widget_mus.h" | 10 #include "ui/views/mus/native_widget_mus.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 class WmNativeWidgetMus : public views::NativeWidgetMus { | 15 class WmNativeWidgetMus : public views::NativeWidgetMus { |
16 public: | 16 public: |
17 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, | 17 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, |
18 mojo::Shell* shell, | 18 mojo::Shell* shell, |
19 mus::Window* window) | 19 mus::Window* window) |
20 : NativeWidgetMus(delegate, | 20 : NativeWidgetMus(delegate, |
21 shell, | 21 shell, |
22 window, | 22 window, |
23 mus::mojom::SURFACE_TYPE_UNDERLAY) {} | 23 mus::mojom::SURFACE_TYPE_UNDERLAY) {} |
24 ~WmNativeWidgetMus() override {} | 24 ~WmNativeWidgetMus() override {} |
25 | 25 |
26 // NativeWidgetMus: | 26 // NativeWidgetMus: |
27 views::NonClientFrameView* CreateNonClientFrameView() override { | 27 views::NonClientFrameView* CreateNonClientFrameView() override { |
28 NonClientFrameViewImpl* frame_view = new NonClientFrameViewImpl(window()); | 28 views::Widget* widget = |
29 frame_view->Init( | 29 static_cast<views::internal::NativeWidgetPrivate*>(this)->GetWidget(); |
30 static_cast<views::internal::NativeWidgetPrivate*>(this)->GetWidget()); | 30 mash::wm::NonClientFrameViewMash* frame_view = |
| 31 new mash::wm::NonClientFrameViewMash(widget, window()); |
31 return frame_view; | 32 return frame_view; |
32 } | 33 } |
33 void CenterWindow(const gfx::Size& size) override { | 34 void CenterWindow(const gfx::Size& size) override { |
34 // Do nothing. The client controls the size, not us. | 35 // Do nothing. The client controls the size, not us. |
35 } | 36 } |
36 void UpdateClientArea() override { | 37 void UpdateClientArea() override { |
37 // This pushes the client area to the WS. We don't want to do that as | 38 // This pushes the client area to the WS. We don't want to do that as |
38 // the client area should come from the client, not us. | 39 // the client area should come from the client, not us. |
39 } | 40 } |
40 | 41 |
41 private: | 42 private: |
42 DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetMus); | 43 DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetMus); |
43 }; | 44 }; |
44 | 45 |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 NonClientFrameController::NonClientFrameController(mojo::Shell* shell, | 48 NonClientFrameController::NonClientFrameController(mojo::Shell* shell, |
48 mus::Window* window) | 49 mus::Window* window) |
49 : widget_(new views::Widget), window_(window) { | 50 : widget_(new views::Widget), window_(window) { |
50 window_->AddObserver(this); | 51 window_->AddObserver(this); |
51 | 52 |
52 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 53 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
53 params.delegate = this; | 54 params.delegate = this; |
54 params.native_widget = new WmNativeWidgetMus(widget_, shell, window); | 55 params.native_widget = new WmNativeWidgetMus(widget_, shell, window); |
55 widget_->Init(params); | 56 widget_->Init(params); |
56 widget_->Show(); | 57 widget_->Show(); |
57 } | 58 } |
58 | 59 |
| 60 // static |
| 61 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { |
| 62 return mash::wm::NonClientFrameViewMash::GetPreferredClientAreaInsets(); |
| 63 } |
| 64 |
59 NonClientFrameController::~NonClientFrameController() { | 65 NonClientFrameController::~NonClientFrameController() { |
60 if (window_) | 66 if (window_) |
61 window_->RemoveObserver(this); | 67 window_->RemoveObserver(this); |
62 } | 68 } |
63 | 69 |
64 views::View* NonClientFrameController::GetContentsView() { | 70 views::View* NonClientFrameController::GetContentsView() { |
65 return this; | 71 return this; |
66 } | 72 } |
67 | 73 |
68 bool NonClientFrameController::CanResize() const { | 74 bool NonClientFrameController::CanResize() const { |
(...skipping 20 matching lines...) Expand all Loading... |
89 const std::vector<uint8_t>* old_data, | 95 const std::vector<uint8_t>* old_data, |
90 const std::vector<uint8_t>* new_data) { | 96 const std::vector<uint8_t>* new_data) { |
91 if (name == mus::mojom::WindowManager::kResizeBehavior_Property) | 97 if (name == mus::mojom::WindowManager::kResizeBehavior_Property) |
92 widget_->OnSizeConstraintsChanged(); | 98 widget_->OnSizeConstraintsChanged(); |
93 } | 99 } |
94 | 100 |
95 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { | 101 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { |
96 window_->RemoveObserver(this); | 102 window_->RemoveObserver(this); |
97 window_ = nullptr; | 103 window_ = nullptr; |
98 } | 104 } |
OLD | NEW |