OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/ui/demo/mus_demo_internal.h" | 5 #include "services/ui/demo/mus_demo_internal.h" |
6 | 6 |
7 #include "services/service_manager/public/cpp/service_context.h" | 7 #include "services/service_manager/public/cpp/service_context.h" |
8 #include "services/ui/demo/window_tree_data.h" | 8 #include "services/ui/demo/window_tree_data.h" |
9 #include "ui/aura/mus/window_tree_client.h" | 9 #include "ui/aura/mus/window_tree_client.h" |
10 #include "ui/aura/mus/window_tree_host_mus.h" | 10 #include "ui/aura/mus/window_tree_host_mus.h" |
11 | 11 |
12 namespace ui { | 12 namespace ui { |
13 namespace demo { | 13 namespace demo { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Size of square in pixels to draw. | 17 // Size of square in pixels to draw. |
18 const int kSquareSize = 300; | 18 const int kSquareSize = 300; |
19 } | 19 } |
20 | 20 |
21 MusDemoInternal::MusDemoInternal() {} | 21 MusDemoInternal::MusDemoInternal() {} |
22 | 22 |
23 MusDemoInternal::~MusDemoInternal() {} | 23 MusDemoInternal::~MusDemoInternal() {} |
24 | 24 |
25 void MusDemoInternal::OnStartImpl( | 25 std::unique_ptr<aura::WindowTreeClient> |
26 std::unique_ptr<aura::WindowTreeClient>* window_tree_client, | 26 MusDemoInternal::CreateWindowTreeClient() { |
27 std::unique_ptr<WindowTreeData>* window_tree_data) { | 27 return base::MakeUnique<aura::WindowTreeClient>(context()->connector(), this, |
28 *window_tree_client = base::MakeUnique<aura::WindowTreeClient>( | 28 this); |
29 context()->connector(), this, this); | 29 } |
30 window_tree_client->get()->ConnectAsWindowManager(); | 30 |
31 *window_tree_data = base::MakeUnique<WindowTreeData>(kSquareSize); | 31 void MusDemoInternal::OnStartImpl() { |
| 32 window_tree_client()->ConnectAsWindowManager(); |
| 33 // The demo will actually start when the window server creates the display, |
| 34 // causing OnWmNewDisplay to be called. |
32 } | 35 } |
33 | 36 |
34 void MusDemoInternal::SetWindowManagerClient( | 37 void MusDemoInternal::SetWindowManagerClient( |
35 aura::WindowManagerClient* client) {} | 38 aura::WindowManagerClient* client) {} |
36 | 39 |
37 bool MusDemoInternal::OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) { | 40 bool MusDemoInternal::OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) { |
38 return true; | 41 return true; |
39 } | 42 } |
40 | 43 |
41 bool MusDemoInternal::OnWmSetProperty( | 44 bool MusDemoInternal::OnWmSetProperty( |
(...skipping 18 matching lines...) Expand all Loading... |
60 // Don't care | 63 // Don't care |
61 } | 64 } |
62 | 65 |
63 void MusDemoInternal::OnWmWillCreateDisplay(const display::Display& display) { | 66 void MusDemoInternal::OnWmWillCreateDisplay(const display::Display& display) { |
64 AddPrimaryDisplay(display); | 67 AddPrimaryDisplay(display); |
65 } | 68 } |
66 | 69 |
67 void MusDemoInternal::OnWmNewDisplay( | 70 void MusDemoInternal::OnWmNewDisplay( |
68 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, | 71 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, |
69 const display::Display& display) { | 72 const display::Display& display) { |
| 73 AppendWindowTreeData(base::MakeUnique<WindowTreeData>(kSquareSize)); |
70 InitWindowTreeData(std::move(window_tree_host)); | 74 InitWindowTreeData(std::move(window_tree_host)); |
71 } | 75 } |
72 | 76 |
73 void MusDemoInternal::OnWmDisplayRemoved( | 77 void MusDemoInternal::OnWmDisplayRemoved( |
74 aura::WindowTreeHostMus* window_tree_host) { | 78 aura::WindowTreeHostMus* window_tree_host) { |
75 CleanupWindowTreeData(); | 79 RemoveWindowTreeData(window_tree_host); |
76 } | 80 } |
77 | 81 |
78 void MusDemoInternal::OnWmDisplayModified(const display::Display& display) {} | 82 void MusDemoInternal::OnWmDisplayModified(const display::Display& display) {} |
79 | 83 |
80 mojom::EventResult MusDemoInternal::OnAccelerator(uint32_t id, | 84 mojom::EventResult MusDemoInternal::OnAccelerator(uint32_t id, |
81 const Event& event) { | 85 const Event& event) { |
82 return mojom::EventResult::UNHANDLED; | 86 return mojom::EventResult::UNHANDLED; |
83 } | 87 } |
84 | 88 |
85 void MusDemoInternal::OnWmPerformMoveLoop( | 89 void MusDemoInternal::OnWmPerformMoveLoop( |
(...skipping 12 matching lines...) Expand all Loading... |
98 const std::vector<gfx::Rect>& additional_client_areas) {} | 102 const std::vector<gfx::Rect>& additional_client_areas) {} |
99 | 103 |
100 bool MusDemoInternal::IsWindowActive(aura::Window* window) { | 104 bool MusDemoInternal::IsWindowActive(aura::Window* window) { |
101 return false; | 105 return false; |
102 } | 106 } |
103 | 107 |
104 void MusDemoInternal::OnWmDeactivateWindow(aura::Window* window) {} | 108 void MusDemoInternal::OnWmDeactivateWindow(aura::Window* window) {} |
105 | 109 |
106 } // namespace demo | 110 } // namespace demo |
107 } // namespace ui | 111 } // namespace ui |
OLD | NEW |