| 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 17 matching lines...) Expand all Loading... |
| 28 #include "ui/aura/window_tree_host.h" | 28 #include "ui/aura/window_tree_host.h" |
| 29 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
| 30 #include "ui/gfx/geometry/vector2d.h" | 30 #include "ui/gfx/geometry/vector2d.h" |
| 31 #include "ui/views/mus/native_widget_mus.h" | 31 #include "ui/views/mus/native_widget_mus.h" |
| 32 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
| 33 | 33 |
| 34 namespace mash { | 34 namespace mash { |
| 35 namespace wm { | 35 namespace wm { |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 enum class ShadowStyle { | |
| 39 NORMAL, | |
| 40 SMALL, | |
| 41 }; | |
| 42 | |
| 43 // LayoutManager associated with the window created by WindowTreeHost. Resizes | 38 // LayoutManager associated with the window created by WindowTreeHost. Resizes |
| 44 // all children of the parent to match the bounds of the parent. Additionally | 39 // all children of the parent to match the bounds of the parent. Additionally |
| 45 // handles sizing of a Shadow. | 40 // handles sizing of a Shadow. |
| 46 class ContentWindowLayoutManager : public aura::LayoutManager { | 41 class ContentWindowLayoutManager : public aura::LayoutManager { |
| 47 public: | 42 public: |
| 48 explicit ContentWindowLayoutManager(aura::Window* window, | 43 ContentWindowLayoutManager(aura::Window* window, Shadow* shadow) |
| 49 ShadowStyle style, | 44 : window_(window), shadow_(shadow) { |
| 50 Shadow* shadow) | |
| 51 : window_(window), style_(style), shadow_(shadow) { | |
| 52 OnWindowResized(); | 45 OnWindowResized(); |
| 53 } | 46 } |
| 54 ~ContentWindowLayoutManager() override {} | 47 ~ContentWindowLayoutManager() override {} |
| 55 | 48 |
| 56 private: | 49 private: |
| 57 // Bounds for child windows. | 50 // Bounds for child windows. |
| 58 gfx::Rect child_bounds() const { | 51 gfx::Rect child_bounds() const { |
| 59 return gfx::Rect(0, 0, window_->bounds().size().width(), | 52 return gfx::Rect(0, 0, window_->bounds().size().width(), |
| 60 window_->bounds().size().height()); | 53 window_->bounds().size().height()); |
| 61 } | 54 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 void OnWillRemoveWindowFromLayout(aura::Window* child) override {} | 71 void OnWillRemoveWindowFromLayout(aura::Window* child) override {} |
| 79 void OnWindowRemovedFromLayout(aura::Window* child) override {} | 72 void OnWindowRemovedFromLayout(aura::Window* child) override {} |
| 80 void OnChildWindowVisibilityChanged(aura::Window* child, | 73 void OnChildWindowVisibilityChanged(aura::Window* child, |
| 81 bool visible) override {} | 74 bool visible) override {} |
| 82 void SetChildBounds(aura::Window* child, | 75 void SetChildBounds(aura::Window* child, |
| 83 const gfx::Rect& requested_bounds) override { | 76 const gfx::Rect& requested_bounds) override { |
| 84 SetChildBoundsDirect(child, requested_bounds); | 77 SetChildBoundsDirect(child, requested_bounds); |
| 85 } | 78 } |
| 86 | 79 |
| 87 aura::Window* window_; | 80 aura::Window* window_; |
| 88 const ShadowStyle style_; | |
| 89 Shadow* shadow_; | 81 Shadow* shadow_; |
| 90 | 82 |
| 91 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); | 83 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); |
| 92 }; | 84 }; |
| 93 | 85 |
| 94 class WmNativeWidgetMus : public views::NativeWidgetMus { | 86 class WmNativeWidgetMus : public views::NativeWidgetMus { |
| 95 public: | 87 public: |
| 96 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, | 88 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, |
| 97 shell::Connector* connector, | 89 shell::Connector* connector, |
| 98 mus::Window* window, | 90 mus::Window* window, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 116 return frame_view; | 108 return frame_view; |
| 117 } | 109 } |
| 118 void InitNativeWidget(const views::Widget::InitParams& params) override { | 110 void InitNativeWidget(const views::Widget::InitParams& params) override { |
| 119 views::NativeWidgetMus::InitNativeWidget(params); | 111 views::NativeWidgetMus::InitNativeWidget(params); |
| 120 aura::WindowTreeHost* window_tree_host = GetNativeView()->GetHost(); | 112 aura::WindowTreeHost* window_tree_host = GetNativeView()->GetHost(); |
| 121 // TODO(sky): shadow should be determined by window type and shadow type. | 113 // TODO(sky): shadow should be determined by window type and shadow type. |
| 122 shadow_.reset(new Shadow); | 114 shadow_.reset(new Shadow); |
| 123 shadow_->Init(Shadow::STYLE_INACTIVE); | 115 shadow_->Init(Shadow::STYLE_INACTIVE); |
| 124 shadow_->Install(window()); | 116 shadow_->Install(window()); |
| 125 ContentWindowLayoutManager* layout_manager = new ContentWindowLayoutManager( | 117 ContentWindowLayoutManager* layout_manager = new ContentWindowLayoutManager( |
| 126 window_tree_host->window(), ShadowStyle::NORMAL, shadow_.get()); | 118 window_tree_host->window(), shadow_.get()); |
| 127 window_tree_host->window()->SetLayoutManager(layout_manager); | 119 window_tree_host->window()->SetLayoutManager(layout_manager); |
| 128 const int inset = Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); | 120 const int inset = Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); |
| 129 window_tree_host->SetOutputSurfacePadding( | 121 window_tree_host->SetOutputSurfacePadding( |
| 130 gfx::Insets(inset, inset, inset, inset)); | 122 gfx::Insets(inset, inset, inset, inset)); |
| 131 window_tree_host->window()->layer()->Add(shadow_->layer()); | 123 window_tree_host->window()->layer()->Add(shadow_->layer()); |
| 132 shadow_->layer()->parent()->StackAtBottom(shadow_->layer()); | 124 shadow_->layer()->parent()->StackAtBottom(shadow_->layer()); |
| 133 } | 125 } |
| 134 void CenterWindow(const gfx::Size& size) override { | 126 void CenterWindow(const gfx::Size& size) override { |
| 135 // Do nothing. The client controls the size, not us. | 127 // Do nothing. The client controls the size, not us. |
| 136 } | 128 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 widget_->UpdateWindowTitle(); | 280 widget_->UpdateWindowTitle(); |
| 289 } | 281 } |
| 290 | 282 |
| 291 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { | 283 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { |
| 292 window_->RemoveObserver(this); | 284 window_->RemoveObserver(this); |
| 293 window_ = nullptr; | 285 window_ = nullptr; |
| 294 } | 286 } |
| 295 | 287 |
| 296 } // namespace wm | 288 } // namespace wm |
| 297 } // namespace mash | 289 } // namespace mash |
| OLD | NEW |