| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "components/mus/public/cpp/property_type_converters.h" | 14 #include "components/mus/public/cpp/property_type_converters.h" |
| 15 #include "components/mus/public/cpp/window.h" | 15 #include "components/mus/public/cpp/window.h" |
| 16 #include "components/mus/public/cpp/window_manager_delegate.h" | 16 #include "components/mus/public/cpp/window_manager_delegate.h" |
| 17 #include "components/mus/public/cpp/window_property.h" | 17 #include "components/mus/public/cpp/window_property.h" |
| 18 #include "components/mus/public/interfaces/window_manager.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 20 #include "mash/wm/bridge/wm_window_mus.h" |
| 20 #include "mash/wm/frame/frame_border_hit_test_controller.h" | 21 #include "mash/wm/frame/frame_border_hit_test_controller.h" |
| 21 #include "mash/wm/frame/move_event_handler.h" | 22 #include "mash/wm/frame/move_event_handler.h" |
| 22 #include "mash/wm/frame/non_client_frame_view_mash.h" | 23 #include "mash/wm/frame/non_client_frame_view_mash.h" |
| 23 #include "mash/wm/property_util.h" | 24 #include "mash/wm/property_util.h" |
| 24 #include "mash/wm/shadow.h" | 25 #include "mash/wm/shadow.h" |
| 25 #include "mojo/converters/geometry/geometry_type_converters.h" | 26 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 26 #include "ui/aura/layout_manager.h" | 27 #include "ui/aura/layout_manager.h" |
| 27 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
| 28 #include "ui/aura/window_tree_host.h" | 29 #include "ui/aura/window_tree_host.h" |
| 29 #include "ui/compositor/layer.h" | 30 #include "ui/compositor/layer.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 NonClientFrameController* frame_controller_; | 181 NonClientFrameController* frame_controller_; |
| 181 | 182 |
| 182 DISALLOW_COPY_AND_ASSIGN(ClientViewMus); | 183 DISALLOW_COPY_AND_ASSIGN(ClientViewMus); |
| 183 }; | 184 }; |
| 184 | 185 |
| 185 } // namespace | 186 } // namespace |
| 186 | 187 |
| 187 // static | 188 // static |
| 188 void NonClientFrameController::Create( | 189 void NonClientFrameController::Create( |
| 189 shell::Connector* connector, | 190 shell::Connector* connector, |
| 191 mus::Window* parent, |
| 190 mus::Window* window, | 192 mus::Window* window, |
| 191 mus::WindowManagerClient* window_manager_client) { | 193 mus::WindowManagerClient* window_manager_client) { |
| 192 new NonClientFrameController(connector, window, window_manager_client); | 194 new NonClientFrameController(connector, parent, window, |
| 195 window_manager_client); |
| 193 } | 196 } |
| 194 | 197 |
| 195 // static | 198 // static |
| 196 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { | 199 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { |
| 197 return NonClientFrameViewMash::GetPreferredClientAreaInsets(); | 200 return NonClientFrameViewMash::GetPreferredClientAreaInsets(); |
| 198 } | 201 } |
| 199 | 202 |
| 200 // static | 203 // static |
| 201 int NonClientFrameController::GetMaxTitleBarButtonWidth() { | 204 int NonClientFrameController::GetMaxTitleBarButtonWidth() { |
| 202 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth(); | 205 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth(); |
| 203 } | 206 } |
| 204 | 207 |
| 205 NonClientFrameController::NonClientFrameController( | 208 NonClientFrameController::NonClientFrameController( |
| 206 shell::Connector* connector, | 209 shell::Connector* connector, |
| 210 mus::Window* parent, |
| 207 mus::Window* window, | 211 mus::Window* window, |
| 208 mus::WindowManagerClient* window_manager_client) | 212 mus::WindowManagerClient* window_manager_client) |
| 209 : widget_(new views::Widget), window_(window) { | 213 : widget_(new views::Widget), window_(window) { |
| 214 WmWindowMus::Get(window)->set_widget(widget_); |
| 210 window_->AddObserver(this); | 215 window_->AddObserver(this); |
| 211 | 216 |
| 212 // To simplify things this code creates a Widget. While a Widget is created | 217 // To simplify things this code creates a Widget. While a Widget is created |
| 213 // we need to ensure we don't inadvertently change random properties of the | 218 // we need to ensure we don't inadvertently change random properties of the |
| 214 // underlying mus::Window. For example, showing the Widget shouldn't change | 219 // underlying mus::Window. For example, showing the Widget shouldn't change |
| 215 // the bounds of the mus::Window in anyway. | 220 // the bounds of the mus::Window in anyway. |
| 216 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 221 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 217 // We initiate focus at the mus level, not at the views level. | 222 // We initiate focus at the mus level, not at the views level. |
| 218 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | 223 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| 219 params.delegate = this; | 224 params.delegate = this; |
| 220 params.native_widget = | 225 params.native_widget = |
| 221 new WmNativeWidgetMus(widget_, connector, window, window_manager_client); | 226 new WmNativeWidgetMus(widget_, connector, window, window_manager_client); |
| 222 widget_->Init(params); | 227 widget_->Init(params); |
| 228 |
| 229 parent->AddChild(window); |
| 230 |
| 223 widget_->ShowInactive(); | 231 widget_->ShowInactive(); |
| 224 | 232 |
| 225 const int shadow_inset = | 233 const int shadow_inset = |
| 226 Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); | 234 Shadow::GetInteriorInsetForStyle(Shadow::STYLE_ACTIVE); |
| 227 window_manager_client->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 235 window_manager_client->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 228 window, gfx::Vector2d(shadow_inset, shadow_inset), | 236 window, gfx::Vector2d(shadow_inset, shadow_inset), |
| 229 FrameBorderHitTestController::GetResizeOutsideBoundsSize()); | 237 FrameBorderHitTestController::GetResizeOutsideBoundsSize()); |
| 230 } | 238 } |
| 231 | 239 |
| 232 NonClientFrameController::~NonClientFrameController() { | 240 NonClientFrameController::~NonClientFrameController() { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 widget_->UpdateWindowTitle(); | 296 widget_->UpdateWindowTitle(); |
| 289 } | 297 } |
| 290 | 298 |
| 291 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { | 299 void NonClientFrameController::OnWindowDestroyed(mus::Window* window) { |
| 292 window_->RemoveObserver(this); | 300 window_->RemoveObserver(this); |
| 293 window_ = nullptr; | 301 window_ = nullptr; |
| 294 } | 302 } |
| 295 | 303 |
| 296 } // namespace wm | 304 } // namespace wm |
| 297 } // namespace mash | 305 } // namespace mash |
| OLD | NEW |