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 "ui/views/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "components/mus/public/cpp/property_type_converters.h" | 9 #include "components/mus/public/cpp/property_type_converters.h" |
10 #include "components/mus/public/cpp/window.h" | 10 #include "components/mus/public/cpp/window.h" |
11 #include "components/mus/public/cpp/window_property.h" | 11 #include "components/mus/public/cpp/window_property.h" |
12 #include "mojo/converters/geometry/geometry_type_converters.h" | 12 #include "mojo/converters/geometry/geometry_type_converters.h" |
13 #include "ui/aura/client/default_capture_client.h" | 13 #include "ui/aura/client/default_capture_client.h" |
14 #include "ui/aura/client/window_tree_client.h" | 14 #include "ui/aura/client/window_tree_client.h" |
15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
16 #include "ui/aura/layout_manager.h" | 16 #include "ui/aura/layout_manager.h" |
17 #include "ui/aura/mus/mus_util.h" | 17 #include "ui/aura/mus/mus_util.h" |
18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_property.h" |
19 #include "ui/base/hit_test.h" | 20 #include "ui/base/hit_test.h" |
20 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
21 #include "ui/native_theme/native_theme_aura.h" | 22 #include "ui/native_theme/native_theme_aura.h" |
22 #include "ui/views/mus/platform_window_mus.h" | 23 #include "ui/views/mus/platform_window_mus.h" |
23 #include "ui/views/mus/surface_context_factory.h" | 24 #include "ui/views/mus/surface_context_factory.h" |
24 #include "ui/views/mus/window_manager_constants_converters.h" | 25 #include "ui/views/mus/window_manager_constants_converters.h" |
25 #include "ui/views/mus/window_manager_frame_values.h" | 26 #include "ui/views/mus/window_manager_frame_values.h" |
26 #include "ui/views/mus/window_tree_host_mus.h" | 27 #include "ui/views/mus/window_tree_host_mus.h" |
27 #include "ui/views/widget/widget_delegate.h" | 28 #include "ui/views/widget/widget_delegate.h" |
28 #include "ui/views/window/custom_frame_view.h" | 29 #include "ui/views/window/custom_frame_view.h" |
29 #include "ui/wm/core/base_focus_rules.h" | 30 #include "ui/wm/core/base_focus_rules.h" |
30 #include "ui/wm/core/capture_controller.h" | 31 #include "ui/wm/core/capture_controller.h" |
31 #include "ui/wm/core/focus_controller.h" | 32 #include "ui/wm/core/focus_controller.h" |
32 | 33 |
| 34 DECLARE_WINDOW_PROPERTY_TYPE(mus::Window*); |
| 35 |
33 namespace views { | 36 namespace views { |
34 namespace { | 37 namespace { |
35 | 38 |
| 39 DEFINE_WINDOW_PROPERTY_KEY(mus::Window*, kMusWindow, nullptr); |
| 40 |
36 // TODO: figure out what this should be. | 41 // TODO: figure out what this should be. |
37 class FocusRulesImpl : public wm::BaseFocusRules { | 42 class FocusRulesImpl : public wm::BaseFocusRules { |
38 public: | 43 public: |
39 FocusRulesImpl() {} | 44 FocusRulesImpl() {} |
40 ~FocusRulesImpl() override {} | 45 ~FocusRulesImpl() override {} |
41 | 46 |
42 bool SupportsChildActivation(aura::Window* window) const override { | 47 bool SupportsChildActivation(aura::Window* window) const override { |
43 return true; | 48 return true; |
44 } | 49 } |
45 | 50 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 context_factory_.reset(new SurfaceContextFactory(shell_, window_, | 286 context_factory_.reset(new SurfaceContextFactory(shell_, window_, |
282 surface_type_)); | 287 surface_type_)); |
283 } | 288 } |
284 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 289 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
285 } | 290 } |
286 window_tree_host_.reset( | 291 window_tree_host_.reset( |
287 new WindowTreeHostMus(shell_, this, window_, surface_type_)); | 292 new WindowTreeHostMus(shell_, this, window_, surface_type_)); |
288 window_tree_host_->AddObserver(this); | 293 window_tree_host_->AddObserver(this); |
289 window_tree_host_->InitHost(); | 294 window_tree_host_->InitHost(); |
290 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 295 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
| 296 window_tree_host_->window()->SetProperty(kMusWindow, window_); |
291 | 297 |
292 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); | 298 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); |
293 | 299 |
294 aura::client::SetFocusClient(window_tree_host_->window(), | 300 aura::client::SetFocusClient(window_tree_host_->window(), |
295 focus_client_.get()); | 301 focus_client_.get()); |
296 aura::client::SetActivationClient(window_tree_host_->window(), | 302 aura::client::SetActivationClient(window_tree_host_->window(), |
297 focus_client_.get()); | 303 focus_client_.get()); |
298 window_tree_client_.reset( | 304 window_tree_client_.reset( |
299 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); | 305 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); |
300 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 306 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); |
301 window_tree_host_->window()->SetLayoutManager( | 307 window_tree_host_->window()->SetLayoutManager( |
302 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); | 308 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); |
303 capture_client_.reset( | 309 capture_client_.reset( |
304 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 310 new aura::client::DefaultCaptureClient(window_tree_host_->window())); |
305 | 311 |
306 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 312 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
307 content_->Init(ui::LAYER_TEXTURED); | 313 content_->Init(ui::LAYER_TEXTURED); |
308 content_->Show(); | 314 content_->Show(); |
309 content_->SetTransparent(true); | 315 content_->SetTransparent(true); |
310 content_->SetFillsBoundsCompletely(false); | 316 content_->SetFillsBoundsCompletely(false); |
| 317 window_tree_host_->window()->AddChild(content_); |
311 | 318 |
312 window_tree_host_->window()->AddChild(content_); | 319 // Set-up transiency if appropriate. |
| 320 if (params.parent && !params.child) { |
| 321 aura::Window* parent_root = params.parent->GetRootWindow(); |
| 322 mus::Window* parent_mus = parent_root->GetProperty(kMusWindow); |
| 323 if (parent_mus) |
| 324 parent_mus->AddTransientWindow(window_); |
| 325 } |
| 326 |
313 // TODO(beng): much else, see [Desktop]NativeWidgetAura. | 327 // TODO(beng): much else, see [Desktop]NativeWidgetAura. |
314 | 328 |
315 native_widget_delegate_->OnNativeWidgetCreated(false); | 329 native_widget_delegate_->OnNativeWidgetCreated(false); |
316 } | 330 } |
317 | 331 |
318 void NativeWidgetMus::OnWidgetInitDone() { | 332 void NativeWidgetMus::OnWidgetInitDone() { |
319 // The client area is calculated from the NonClientView. During | 333 // The client area is calculated from the NonClientView. During |
320 // InitNativeWidget() the NonClientView has not been created. When this | 334 // InitNativeWidget() the NonClientView has not been created. When this |
321 // function is called the NonClientView has been created, so that we can | 335 // function is called the NonClientView has been created, so that we can |
322 // correctly calculate the client area and push it to the mus::Window. | 336 // correctly calculate the client area and push it to the mus::Window. |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 | 830 |
817 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { | 831 void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { |
818 native_widget_delegate_->OnGestureEvent(event); | 832 native_widget_delegate_->OnGestureEvent(event); |
819 } | 833 } |
820 | 834 |
821 void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) { | 835 void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) { |
822 GetWidget()->Close(); | 836 GetWidget()->Close(); |
823 } | 837 } |
824 | 838 |
825 } // namespace views | 839 } // namespace views |
OLD | NEW |