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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "components/mus/public/cpp/property_type_converters.h" | 10 #include "components/mus/public/cpp/property_type_converters.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 | 167 |
168 private: | 168 private: |
169 NonClientFrameController* frame_controller_; | 169 NonClientFrameController* frame_controller_; |
170 | 170 |
171 DISALLOW_COPY_AND_ASSIGN(ClientViewMus); | 171 DISALLOW_COPY_AND_ASSIGN(ClientViewMus); |
172 }; | 172 }; |
173 | 173 |
174 } // namespace | 174 } // namespace |
175 | 175 |
| 176 // static |
| 177 void NonClientFrameController::Create( |
| 178 mojo::Connector* connector, |
| 179 mus::Window* window, |
| 180 mus::WindowManagerClient* window_manager_client) { |
| 181 new NonClientFrameController(connector, window, window_manager_client); |
| 182 } |
| 183 |
| 184 // static |
| 185 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { |
| 186 return NonClientFrameViewMash::GetPreferredClientAreaInsets(); |
| 187 } |
| 188 |
| 189 // static |
| 190 int NonClientFrameController::GetMaxTitleBarButtonWidth() { |
| 191 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth(); |
| 192 } |
| 193 |
176 NonClientFrameController::NonClientFrameController( | 194 NonClientFrameController::NonClientFrameController( |
177 mojo::Connector* connector, | 195 mojo::Connector* connector, |
178 mus::Window* window, | 196 mus::Window* window, |
179 mus::WindowManagerClient* window_manager_client) | 197 mus::WindowManagerClient* window_manager_client) |
180 : widget_(new views::Widget), window_(window) { | 198 : widget_(new views::Widget), window_(window) { |
181 window_->AddObserver(this); | 199 window_->AddObserver(this); |
182 | 200 |
| 201 // To simplify things this code creates a Widget. While a Widget is created |
| 202 // we need to ensure we don't inadvertently change random properties of the |
| 203 // underlying mus::Window. For example, showing the Widget shouldn't change |
| 204 // the bounds of the mus::Window in anyway. |
183 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 205 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
184 // We initiate focus at the mus level, not at the views level. | 206 // We initiate focus at the mus level, not at the views level. |
185 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | 207 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
186 params.delegate = this; | 208 params.delegate = this; |
187 params.native_widget = new WmNativeWidgetMus(widget_, connector, window); | 209 params.native_widget = new WmNativeWidgetMus(widget_, connector, window); |
188 widget_->Init(params); | 210 widget_->Init(params); |
189 widget_->ShowInactive(); | 211 widget_->ShowInactive(); |
190 | 212 |
191 const int shadow_inset = | 213 const int shadow_inset = |
192 Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); | 214 Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); |
193 window_manager_client->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 215 window_manager_client->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
194 window, gfx::Vector2d(shadow_inset, shadow_inset), | 216 window, gfx::Vector2d(shadow_inset, shadow_inset), |
195 FrameBorderHitTestController::GetResizeOutsideBoundsSize()); | 217 FrameBorderHitTestController::GetResizeOutsideBoundsSize()); |
196 } | 218 } |
197 | 219 |
198 // static | |
199 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { | |
200 return NonClientFrameViewMash::GetPreferredClientAreaInsets(); | |
201 } | |
202 | |
203 // static | |
204 int NonClientFrameController::GetMaxTitleBarButtonWidth() { | |
205 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth(); | |
206 } | |
207 | |
208 NonClientFrameController::~NonClientFrameController() { | 220 NonClientFrameController::~NonClientFrameController() { |
209 if (window_) | 221 if (window_) |
210 window_->RemoveObserver(this); | 222 window_->RemoveObserver(this); |
211 } | 223 } |
212 | 224 |
213 base::string16 NonClientFrameController::GetWindowTitle() const { | 225 base::string16 NonClientFrameController::GetWindowTitle() const { |
214 if (!window_->HasSharedProperty( | 226 if (!window_->HasSharedProperty( |
215 mus::mojom::WindowManager::kWindowTitle_Property)) { | 227 mus::mojom::WindowManager::kWindowTitle_Property)) { |
216 return base::string16(); | 228 return base::string16(); |
217 } | 229 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 widget_->UpdateWindowTitle(); | 270 widget_->UpdateWindowTitle(); |
259 } | 271 } |
260 | 272 |
261 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { | 273 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { |
262 window_->RemoveObserver(this); | 274 window_->RemoveObserver(this); |
263 window_ = nullptr; | 275 window_ = nullptr; |
264 } | 276 } |
265 | 277 |
266 } // namespace wm | 278 } // namespace wm |
267 } // namespace mash | 279 } // namespace mash |
OLD | NEW |