OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/sysui_application.h" | 5 #include "ash/mus/sysui_application.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/host/ash_window_tree_host_init_params.h" | 8 #include "ash/host/ash_window_tree_host_init_params.h" |
9 #include "ash/host/ash_window_tree_host_platform.h" | 9 #include "ash/host/ash_window_tree_host_platform.h" |
10 #include "ash/mus/shell_delegate_mus.h" | 10 #include "ash/mus/shell_delegate_mus.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 views::internal::NativeWidgetDelegate* delegate) { | 91 views::internal::NativeWidgetDelegate* delegate) { |
92 std::map<std::string, std::vector<uint8_t>> properties; | 92 std::map<std::string, std::vector<uint8_t>> properties; |
93 if (params.parent) { | 93 if (params.parent) { |
94 mash::wm::mojom::Container container = GetContainerId(params.parent); | 94 mash::wm::mojom::Container container = GetContainerId(params.parent); |
95 if (container != mash::wm::mojom::Container::COUNT) { | 95 if (container != mash::wm::mojom::Container::COUNT) { |
96 properties[mash::wm::mojom::kWindowContainer_Property] = | 96 properties[mash::wm::mojom::kWindowContainer_Property] = |
97 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( | 97 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( |
98 static_cast<int32_t>(container)); | 98 static_cast<int32_t>(container)); |
99 } | 99 } |
100 } | 100 } |
101 | |
102 // AshInit installs a stub implementation of ui::ContextFactory, so that the | |
103 // AshWindowTreeHost instances created do not actually show anything to the | |
104 // user. However, when creating a views::Widget instance, the | |
105 // WindowManagerConnection creates a WindowTreeHostMus instance, which | |
106 // creates a ui::Compositor, and it needs a real ui::ContextFactory | |
107 // implementation. So, unset the context-factory here temporarily when | |
108 // creating NativeWidgetMus. But restore the stub instance afterwards, so | |
109 // that it is used when new AshWindowTreeHost instances are created (e.g. | |
110 // when a new monitor is attached). | |
111 ui::ContextFactory* factory = aura::Env::GetInstance()->context_factory(); | |
112 aura::Env::GetInstance()->set_context_factory(nullptr); | |
101 views::NativeWidgetMus* native_widget = | 113 views::NativeWidgetMus* native_widget = |
sky
2016/02/10 17:27:43
I think this code (and NativeWidgetMus too) shows
sadrul
2016/02/10 17:29:35
Agree. I started looking at that, but decided to u
| |
102 static_cast<views::NativeWidgetMus*>( | 114 static_cast<views::NativeWidgetMus*>( |
103 views::WindowManagerConnection::Get()->CreateNativeWidgetMus( | 115 views::WindowManagerConnection::Get()->CreateNativeWidgetMus( |
104 properties, params, delegate)); | 116 properties, params, delegate)); |
117 aura::Env::GetInstance()->set_context_factory(factory); | |
118 | |
105 // TODO: Set the correct display id here. | 119 // TODO: Set the correct display id here. |
106 InitRootWindowSettings(native_widget->GetRootWindow())->display_id = | 120 InitRootWindowSettings(native_widget->GetRootWindow())->display_id = |
107 Shell::GetInstance() | 121 Shell::GetInstance() |
108 ->display_manager() | 122 ->display_manager() |
109 ->GetPrimaryDisplayCandidate() | 123 ->GetPrimaryDisplayCandidate() |
110 .id(); | 124 .id(); |
111 return native_widget; | 125 return native_widget; |
112 } | 126 } |
113 | 127 |
114 DISALLOW_COPY_AND_ASSIGN(NativeWidgetFactory); | 128 DISALLOW_COPY_AND_ASSIGN(NativeWidgetFactory); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 message_center::MessageCenter::Initialize(); | 164 message_center::MessageCenter::Initialize(); |
151 | 165 |
152 ash::ShellInitParams init_params; | 166 ash::ShellInitParams init_params; |
153 init_params.delegate = ash_delegate_; | 167 init_params.delegate = ash_delegate_; |
154 init_params.context_factory = new StubContextFactory; | 168 init_params.context_factory = new StubContextFactory; |
155 init_params.blocking_pool = worker_pool_.get(); | 169 init_params.blocking_pool = worker_pool_.get(); |
156 ash::Shell::CreateInstance(init_params); | 170 ash::Shell::CreateInstance(init_params); |
157 ash::Shell::GetInstance()->CreateShelf(); | 171 ash::Shell::GetInstance()->CreateShelf(); |
158 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 172 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
159 ash::user::LOGGED_IN_USER); | 173 ash::user::LOGGED_IN_USER); |
160 // Reset the context factory, so that NativeWidgetMus installs the context | |
161 // factory for the views::Widgets correctly. | |
162 aura::Env::GetInstance()->set_context_factory(nullptr); | |
163 | 174 |
164 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 175 ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
165 SetupWallpaper(SkColorSetARGB(255, 0, 255, 0)); | 176 SetupWallpaper(SkColorSetARGB(255, 0, 255, 0)); |
166 } | 177 } |
167 | 178 |
168 void SetupWallpaper(SkColor color) { | 179 void SetupWallpaper(SkColor color) { |
169 SkBitmap bitmap; | 180 SkBitmap bitmap; |
170 bitmap.allocN32Pixels(16, 16); | 181 bitmap.allocN32Pixels(16, 16); |
171 bitmap.eraseColor(color); | 182 bitmap.eraseColor(color); |
172 #if !defined(NDEBUG) | 183 #if !defined(NDEBUG) |
(...skipping 25 matching lines...) Expand all Loading... | |
198 | 209 |
199 void SysUIApplication::Initialize(mojo::Shell* shell, | 210 void SysUIApplication::Initialize(mojo::Shell* shell, |
200 const std::string& url, | 211 const std::string& url, |
201 uint32_t id) { | 212 uint32_t id) { |
202 ash_init_.reset(new AshInit()); | 213 ash_init_.reset(new AshInit()); |
203 ash_init_->Initialize(shell); | 214 ash_init_->Initialize(shell); |
204 } | 215 } |
205 | 216 |
206 } // namespace sysui | 217 } // namespace sysui |
207 } // namespace ash | 218 } // namespace ash |
OLD | NEW |