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 <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 int NonClientFrameController::GetMaxTitleBarButtonWidth() { | 196 int NonClientFrameController::GetMaxTitleBarButtonWidth() { |
197 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth(); | 197 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth(); |
198 } | 198 } |
199 | 199 |
200 NonClientFrameController::NonClientFrameController( | 200 NonClientFrameController::NonClientFrameController( |
201 shell::Connector* connector, | 201 shell::Connector* connector, |
202 mus::Window* parent, | 202 mus::Window* parent, |
203 mus::Window* window, | 203 mus::Window* window, |
204 mus::WindowManagerClient* window_manager_client) | 204 mus::WindowManagerClient* window_manager_client) |
205 : widget_(new views::Widget), window_(window) { | 205 : widget_(new views::Widget), window_(window) { |
206 WmWindowMus::Get(window)->set_widget( | 206 WmWindowMus* wm_window = WmWindowMus::Get(window); |
207 widget_, WmWindowMus::WidgetCreationType::FOR_CLIENT); | 207 wm_window->set_widget(widget_, WmWindowMus::WidgetCreationType::FOR_CLIENT); |
208 window_->AddObserver(this); | 208 window_->AddObserver(this); |
209 | 209 |
210 // To simplify things this code creates a Widget. While a Widget is created | 210 // To simplify things this code creates a Widget. While a Widget is created |
211 // we need to ensure we don't inadvertently change random properties of the | 211 // we need to ensure we don't inadvertently change random properties of the |
212 // underlying mus::Window. For example, showing the Widget shouldn't change | 212 // underlying mus::Window. For example, showing the Widget shouldn't change |
213 // the bounds of the mus::Window in anyway. | 213 // the bounds of the mus::Window in anyway. |
214 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 214 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
215 // We initiate focus at the mus level, not at the views level. | 215 // We initiate focus at the mus level, not at the views level. |
216 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | 216 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
217 params.delegate = this; | 217 params.delegate = this; |
218 params.native_widget = | 218 params.native_widget = |
219 new WmNativeWidgetMus(widget_, connector, window, window_manager_client); | 219 new WmNativeWidgetMus(widget_, connector, window, window_manager_client); |
220 widget_->Init(params); | 220 widget_->Init(params); |
221 | 221 |
222 parent->AddChild(window); | 222 parent->AddChild(window); |
223 | 223 |
224 widget_->ShowInactive(); | 224 widget_->ShowInactive(); |
225 | 225 |
226 const int shadow_inset = | 226 const int shadow_inset = |
227 Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); | 227 Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); |
| 228 const gfx::Insets extended_hit_region = |
| 229 wm_window->ShouldUseExtendedHitRegion() |
| 230 ? FrameBorderHitTestController::GetResizeOutsideBoundsSize() |
| 231 : gfx::Insets(); |
228 window_manager_client->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 232 window_manager_client->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
229 window, gfx::Vector2d(shadow_inset, shadow_inset), | 233 window, gfx::Vector2d(shadow_inset, shadow_inset), extended_hit_region); |
230 FrameBorderHitTestController::GetResizeOutsideBoundsSize()); | |
231 } | 234 } |
232 | 235 |
233 NonClientFrameController::~NonClientFrameController() { | 236 NonClientFrameController::~NonClientFrameController() { |
234 if (window_) | 237 if (window_) |
235 window_->RemoveObserver(this); | 238 window_->RemoveObserver(this); |
236 } | 239 } |
237 | 240 |
238 base::string16 NonClientFrameController::GetWindowTitle() const { | 241 base::string16 NonClientFrameController::GetWindowTitle() const { |
239 if (!window_->HasSharedProperty( | 242 if (!window_->HasSharedProperty( |
240 mus::mojom::WindowManager::kWindowTitle_Property)) { | 243 mus::mojom::WindowManager::kWindowTitle_Property)) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 307 } |
305 } | 308 } |
306 | 309 |
307 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { | 310 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { |
308 window_->RemoveObserver(this); | 311 window_->RemoveObserver(this); |
309 window_ = nullptr; | 312 window_ = nullptr; |
310 } | 313 } |
311 | 314 |
312 } // namespace wm | 315 } // namespace wm |
313 } // namespace mash | 316 } // namespace mash |
OLD | NEW |