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 "ash/mus/non_client_frame_controller.h" | 5 #include "ash/mus/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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 std::unique_ptr<DetachedTitleAreaRendererForInternal> title_area_renderer_; | 165 std::unique_ptr<DetachedTitleAreaRendererForInternal> title_area_renderer_; |
166 | 166 |
167 DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenControllerDelegateMus); | 167 DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenControllerDelegateMus); |
168 }; | 168 }; |
169 | 169 |
170 class WmNativeWidgetAura : public views::NativeWidgetAura { | 170 class WmNativeWidgetAura : public views::NativeWidgetAura { |
171 public: | 171 public: |
172 WmNativeWidgetAura(views::internal::NativeWidgetDelegate* delegate, | 172 WmNativeWidgetAura(views::internal::NativeWidgetDelegate* delegate, |
173 aura::WindowManagerClient* window_manager_client, | 173 aura::WindowManagerClient* window_manager_client, |
174 bool remove_standard_frame, | 174 bool remove_standard_frame, |
175 bool enable_immersive) | 175 bool enable_immersive, |
176 mojom::WindowStyle window_style) | |
176 // The NativeWidget is mirroring the real Widget created in client code. | 177 // The NativeWidget is mirroring the real Widget created in client code. |
177 // |is_parallel_widget_in_window_manager| is used to indicate this | 178 // |is_parallel_widget_in_window_manager| is used to indicate this |
178 : views::NativeWidgetAura( | 179 : views::NativeWidgetAura( |
179 delegate, | 180 delegate, |
180 true /* is_parallel_widget_in_window_manager */), | 181 true /* is_parallel_widget_in_window_manager */), |
181 remove_standard_frame_(remove_standard_frame), | 182 remove_standard_frame_(remove_standard_frame), |
182 enable_immersive_(enable_immersive), | 183 enable_immersive_(enable_immersive), |
184 window_style_(window_style), | |
183 window_manager_client_(window_manager_client) {} | 185 window_manager_client_(window_manager_client) {} |
184 ~WmNativeWidgetAura() override {} | 186 ~WmNativeWidgetAura() override {} |
185 | 187 |
188 void SetHeaderHeight(int height) { | |
189 if (custom_frame_view_) | |
190 custom_frame_view_->SetHeaderHeight({height}); | |
191 } | |
192 | |
186 // views::NativeWidgetAura: | 193 // views::NativeWidgetAura: |
187 views::NonClientFrameView* CreateNonClientFrameView() override { | 194 views::NonClientFrameView* CreateNonClientFrameView() override { |
188 move_event_handler_ = base::MakeUnique<MoveEventHandler>( | 195 move_event_handler_ = base::MakeUnique<MoveEventHandler>( |
189 window_manager_client_, GetNativeView()); | 196 window_manager_client_, GetNativeView()); |
190 // TODO(sky): investigate why we have this. Seems this should be the same | 197 // TODO(sky): investigate why we have this. Seems this should be the same |
191 // as not specifying client area insets. | 198 // as not specifying client area insets. |
192 if (remove_standard_frame_) | 199 if (remove_standard_frame_) |
193 return new EmptyDraggableNonClientFrameView(); | 200 return new EmptyDraggableNonClientFrameView(); |
194 aura::Window* window = GetNativeView(); | 201 aura::Window* window = GetNativeView(); |
195 if (window->GetProperty(aura::client::kWindowTypeKey) == | 202 if (window->GetProperty(aura::client::kWindowTypeKey) == |
196 ui::mojom::WindowType::PANEL) | 203 ui::mojom::WindowType::PANEL) |
197 return new PanelFrameView(GetWidget(), PanelFrameView::FRAME_ASH); | 204 return new PanelFrameView(GetWidget(), PanelFrameView::FRAME_ASH); |
198 immersive_delegate_ = | 205 immersive_delegate_ = |
199 base::MakeUnique<ImmersiveFullscreenControllerDelegateMus>(GetWidget(), | 206 base::MakeUnique<ImmersiveFullscreenControllerDelegateMus>(GetWidget(), |
200 window); | 207 window); |
201 return new CustomFrameViewMus(GetWidget(), immersive_delegate_.get(), | 208 custom_frame_view_ = |
202 enable_immersive_); | 209 new CustomFrameViewMus(GetWidget(), immersive_delegate_.get(), |
210 enable_immersive_, window_style_); | |
211 return custom_frame_view_; | |
203 } | 212 } |
204 | 213 |
205 private: | 214 private: |
206 const bool remove_standard_frame_; | 215 const bool remove_standard_frame_; |
207 const bool enable_immersive_; | 216 const bool enable_immersive_; |
217 const mojom::WindowStyle window_style_; | |
208 | 218 |
209 std::unique_ptr<MoveEventHandler> move_event_handler_; | 219 std::unique_ptr<MoveEventHandler> move_event_handler_; |
210 | 220 |
211 aura::WindowManagerClient* window_manager_client_; | 221 aura::WindowManagerClient* window_manager_client_; |
212 | 222 |
213 std::unique_ptr<ImmersiveFullscreenControllerDelegateMus> immersive_delegate_; | 223 std::unique_ptr<ImmersiveFullscreenControllerDelegateMus> immersive_delegate_; |
214 | 224 |
225 // Not used for panels or if |remove_standard_frame_| is true. | |
226 CustomFrameViewMus* custom_frame_view_ = nullptr; | |
James Cook
2017/03/02 21:00:00
nit: can you comment who owns this, since it's mad
sky
2017/03/02 21:28:42
Done.
| |
227 | |
215 DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetAura); | 228 DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetAura); |
216 }; | 229 }; |
217 | 230 |
218 class ClientViewMus : public views::ClientView { | 231 class ClientViewMus : public views::ClientView { |
219 public: | 232 public: |
220 ClientViewMus(views::Widget* widget, | 233 ClientViewMus(views::Widget* widget, |
221 views::View* contents_view, | 234 views::View* contents_view, |
222 NonClientFrameController* frame_controller) | 235 NonClientFrameController* frame_controller) |
223 : views::ClientView(widget, contents_view), | 236 : views::ClientView(widget, contents_view), |
224 frame_controller_(frame_controller) {} | 237 frame_controller_(frame_controller) {} |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 // MusClient. | 281 // MusClient. |
269 views::Widget::InitParams params( | 282 views::Widget::InitParams params( |
270 static_cast<views::Widget::InitParams::Type>(window_type)); | 283 static_cast<views::Widget::InitParams::Type>(window_type)); |
271 DCHECK((parent && !context) || (!parent && context)); | 284 DCHECK((parent && !context) || (!parent && context)); |
272 params.parent = parent; | 285 params.parent = parent; |
273 params.context = context; | 286 params.context = context; |
274 // TODO: properly set |params.activatable|. Should key off whether underlying | 287 // TODO: properly set |params.activatable|. Should key off whether underlying |
275 // (mus) window can have focus. | 288 // (mus) window can have focus. |
276 params.delegate = this; | 289 params.delegate = this; |
277 params.bounds = bounds; | 290 params.bounds = bounds; |
291 // The title area leaves notches in the corners, requring translucent windows. | |
292 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | |
278 WmNativeWidgetAura* native_widget = new WmNativeWidgetAura( | 293 WmNativeWidgetAura* native_widget = new WmNativeWidgetAura( |
279 widget_, window_manager_client_, ShouldRemoveStandardFrame(*properties), | 294 widget_, window_manager_client_, ShouldRemoveStandardFrame(*properties), |
280 ShouldEnableImmersive(*properties)); | 295 ShouldEnableImmersive(*properties), GetWindowStyle(*properties)); |
281 window_ = native_widget->GetNativeView(); | 296 window_ = native_widget->GetNativeView(); |
282 window_->SetProperty(aura::client::kTopLevelWindowInWM, true); | 297 window_->SetProperty(aura::client::kTopLevelWindowInWM, true); |
283 window_->SetProperty(kNonClientFrameControllerKey, this); | 298 window_->SetProperty(kNonClientFrameControllerKey, this); |
284 window_->SetProperty(kWidgetCreationTypeKey, WidgetCreationType::FOR_CLIENT); | 299 window_->SetProperty(kWidgetCreationTypeKey, WidgetCreationType::FOR_CLIENT); |
285 window_->AddObserver(this); | 300 window_->AddObserver(this); |
286 params.native_widget = native_widget; | 301 params.native_widget = native_widget; |
287 aura::SetWindowType(window_, window_type); | 302 aura::SetWindowType(window_, window_type); |
288 aura::PropertyConverter* property_converter = | 303 aura::PropertyConverter* property_converter = |
289 window_manager->property_converter(); | 304 window_manager->property_converter(); |
290 for (auto& property_pair : *properties) { | 305 for (auto& property_pair : *properties) { |
(...skipping 16 matching lines...) Expand all Loading... | |
307 aura::client::GetTransientWindowClient()->AddObserver(this); | 322 aura::client::GetTransientWindowClient()->AddObserver(this); |
308 } | 323 } |
309 | 324 |
310 // static | 325 // static |
311 NonClientFrameController* NonClientFrameController::Get(aura::Window* window) { | 326 NonClientFrameController* NonClientFrameController::Get(aura::Window* window) { |
312 return window->GetProperty(kNonClientFrameControllerKey); | 327 return window->GetProperty(kNonClientFrameControllerKey); |
313 } | 328 } |
314 | 329 |
315 // static | 330 // static |
316 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { | 331 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { |
317 // TODO(sky): figure out a better way to get this rather than hard coding. | |
318 // This value comes from the header (see DefaultHeaderPainter::LayoutHeader, | |
319 // which uses the preferred height of the CaptionButtonContainer, which uses | |
320 // the height of the close button). | |
321 return gfx::Insets( | 332 return gfx::Insets( |
322 GetAshLayoutSize(AshLayoutSize::NON_BROWSER_CAPTION_BUTTON).height(), 0, | 333 GetAshLayoutSize(AshLayoutSize::NON_BROWSER_CAPTION_BUTTON).height(), 0, |
323 0, 0); | 334 0, 0); |
324 } | 335 } |
325 | 336 |
326 // static | 337 // static |
327 int NonClientFrameController::GetMaxTitleBarButtonWidth() { | 338 int NonClientFrameController::GetMaxTitleBarButtonWidth() { |
328 // TODO(sky): same comment as for GetPreferredClientAreaInsets(). | |
329 return GetAshLayoutSize(AshLayoutSize::NON_BROWSER_CAPTION_BUTTON).width() * | 339 return GetAshLayoutSize(AshLayoutSize::NON_BROWSER_CAPTION_BUTTON).width() * |
330 3; | 340 3; |
331 } | 341 } |
332 | 342 |
333 void NonClientFrameController::SetClientArea( | 343 void NonClientFrameController::SetClientArea( |
334 const gfx::Insets& insets, | 344 const gfx::Insets& insets, |
335 const std::vector<gfx::Rect>& additional_client_areas) { | 345 const std::vector<gfx::Rect>& additional_client_areas) { |
336 client_area_insets_ = insets; | 346 client_area_insets_ = insets; |
337 additional_client_areas_ = additional_client_areas; | 347 additional_client_areas_ = additional_client_areas; |
348 static_cast<WmNativeWidgetAura*>(widget_->native_widget()) | |
349 ->SetHeaderHeight(insets.top()); | |
338 } | 350 } |
339 | 351 |
340 NonClientFrameController::~NonClientFrameController() { | 352 NonClientFrameController::~NonClientFrameController() { |
341 aura::client::GetTransientWindowClient()->RemoveObserver(this); | 353 aura::client::GetTransientWindowClient()->RemoveObserver(this); |
342 if (window_) | 354 if (window_) |
343 window_->RemoveObserver(this); | 355 window_->RemoveObserver(this); |
344 } | 356 } |
345 | 357 |
346 base::string16 NonClientFrameController::GetWindowTitle() const { | 358 base::string16 NonClientFrameController::GetWindowTitle() const { |
347 if (!window_ || !window_->GetProperty(aura::client::kTitleKey)) | 359 if (!window_ || !window_->GetProperty(aura::client::kTitleKey)) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 void NonClientFrameController::OnWillRestackTransientChildAbove( | 445 void NonClientFrameController::OnWillRestackTransientChildAbove( |
434 aura::Window* parent, | 446 aura::Window* parent, |
435 aura::Window* transient_child) {} | 447 aura::Window* transient_child) {} |
436 | 448 |
437 void NonClientFrameController::OnDidRestackTransientChildAbove( | 449 void NonClientFrameController::OnDidRestackTransientChildAbove( |
438 aura::Window* parent, | 450 aura::Window* parent, |
439 aura::Window* transient_child) {} | 451 aura::Window* transient_child) {} |
440 | 452 |
441 } // namespace mus | 453 } // namespace mus |
442 } // namespace ash | 454 } // namespace ash |
OLD | NEW |