Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Side by Side Diff: ui/views/mus/mus_client.cc

Issue 2694213003: mash: wires up shadows for mash (Closed)
Patch Set: defaults test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ui/views/mus/mus_client.h" 5 #include "ui/views/mus/mus_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h" 10 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/aura/window_tree_host.h" 26 #include "ui/aura/window_tree_host.h"
27 #include "ui/views/mus/aura_init.h" 27 #include "ui/views/mus/aura_init.h"
28 #include "ui/views/mus/clipboard_mus.h" 28 #include "ui/views/mus/clipboard_mus.h"
29 #include "ui/views/mus/desktop_window_tree_host_mus.h" 29 #include "ui/views/mus/desktop_window_tree_host_mus.h"
30 #include "ui/views/mus/mus_property_mirror.h" 30 #include "ui/views/mus/mus_property_mirror.h"
31 #include "ui/views/mus/pointer_watcher_event_router.h" 31 #include "ui/views/mus/pointer_watcher_event_router.h"
32 #include "ui/views/mus/screen_mus.h" 32 #include "ui/views/mus/screen_mus.h"
33 #include "ui/views/views_delegate.h" 33 #include "ui/views/views_delegate.h"
34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
35 #include "ui/views/widget/widget_delegate.h" 35 #include "ui/views/widget/widget_delegate.h"
36 #include "ui/wm/core/shadow_types.h"
36 #include "ui/wm/core/wm_state.h" 37 #include "ui/wm/core/wm_state.h"
37 38
38 // Widget::InitParams::Type must match that of ui::mojom::WindowType. 39 // Widget::InitParams::Type must match that of ui::mojom::WindowType.
39 #define WINDOW_TYPES_MATCH(NAME) \ 40 #define WINDOW_TYPES_MATCH(NAME) \
40 static_assert( \ 41 static_assert( \
41 static_cast<int32_t>(views::Widget::InitParams::TYPE_##NAME) == \ 42 static_cast<int32_t>(views::Widget::InitParams::TYPE_##NAME) == \
42 static_cast<int32_t>(ui::mojom::WindowType::NAME), \ 43 static_cast<int32_t>(ui::mojom::WindowType::NAME), \
43 "Window type constants must match") 44 "Window type constants must match")
44 45
45 WINDOW_TYPES_MATCH(WINDOW); 46 WINDOW_TYPES_MATCH(WINDOW);
(...skipping 25 matching lines...) Expand all
71 if (!io_task_runner) { 72 if (!io_task_runner) {
72 io_thread_ = base::MakeUnique<base::Thread>("IOThread"); 73 io_thread_ = base::MakeUnique<base::Thread>("IOThread");
73 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); 74 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
74 thread_options.priority = base::ThreadPriority::NORMAL; 75 thread_options.priority = base::ThreadPriority::NORMAL;
75 CHECK(io_thread_->StartWithOptions(thread_options)); 76 CHECK(io_thread_->StartWithOptions(thread_options));
76 io_task_runner = io_thread_->task_runner(); 77 io_task_runner = io_thread_->task_runner();
77 } 78 }
78 79
79 // TODO(msw): Avoid this... use some default value? Allow clients to extend? 80 // TODO(msw): Avoid this... use some default value? Allow clients to extend?
80 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); 81 property_converter_ = base::MakeUnique<aura::PropertyConverter>();
82 property_converter_->RegisterProperty(
83 wm::kShadowElevationKey,
84 ui::mojom::WindowManager::kShadowElevation_Property);
81 85
82 if (create_wm_state) 86 if (create_wm_state)
83 wm_state_ = base::MakeUnique<wm::WMState>(); 87 wm_state_ = base::MakeUnique<wm::WMState>();
84 88
85 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; 89 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
86 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr); 90 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr);
87 91
88 discardable_shared_memory_manager_ = base::MakeUnique< 92 discardable_shared_memory_manager_ = base::MakeUnique<
89 discardable_memory::ClientDiscardableSharedMemoryManager>( 93 discardable_memory::ClientDiscardableSharedMemoryManager>(
90 std::move(manager_ptr), io_task_runner); 94 std::move(manager_ptr), io_task_runner);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // TYPE_CONTROL and child widgets require a NativeWidgetAura. 141 // TYPE_CONTROL and child widgets require a NativeWidgetAura.
138 return init_params.type != Widget::InitParams::TYPE_CONTROL && 142 return init_params.type != Widget::InitParams::TYPE_CONTROL &&
139 !init_params.child; 143 !init_params.child;
140 } 144 }
141 145
142 // static 146 // static
143 std::map<std::string, std::vector<uint8_t>> 147 std::map<std::string, std::vector<uint8_t>>
144 MusClient::ConfigurePropertiesFromParams( 148 MusClient::ConfigurePropertiesFromParams(
145 const Widget::InitParams& init_params) { 149 const Widget::InitParams& init_params) {
146 using PrimitiveType = aura::PropertyConverter::PrimitiveType; 150 using PrimitiveType = aura::PropertyConverter::PrimitiveType;
147 std::map<std::string, std::vector<uint8_t>> properties = 151 using WindowManager = ui::mojom::WindowManager;
148 init_params.mus_properties; 152 using TransportType = std::vector<uint8_t>;
153
154 std::map<std::string, TransportType> properties = init_params.mus_properties;
149 155
150 // Widget::InitParams::Type matches ui::mojom::WindowType. 156 // Widget::InitParams::Type matches ui::mojom::WindowType.
151 properties[ui::mojom::WindowManager::kWindowType_InitProperty] = 157 properties[WindowManager::kWindowType_InitProperty] =
152 mojo::ConvertTo<std::vector<uint8_t>>( 158 mojo::ConvertTo<TransportType>(static_cast<int32_t>(init_params.type));
153 static_cast<int32_t>(init_params.type));
154 159
155 properties[ui::mojom::WindowManager::kFocusable_InitProperty] = 160 properties[WindowManager::kFocusable_InitProperty] =
156 mojo::ConvertTo<std::vector<uint8_t>>(init_params.CanActivate()); 161 mojo::ConvertTo<TransportType>(init_params.CanActivate());
157 162
158 if (!init_params.bounds.IsEmpty()) { 163 if (!init_params.bounds.IsEmpty()) {
159 properties[ui::mojom::WindowManager::kBounds_InitProperty] = 164 properties[WindowManager::kBounds_InitProperty] =
160 mojo::ConvertTo<std::vector<uint8_t>>(init_params.bounds); 165 mojo::ConvertTo<TransportType>(init_params.bounds);
161 } 166 }
162 167
163 if (!init_params.name.empty()) { 168 if (!init_params.name.empty()) {
164 properties[ui::mojom::WindowManager::kName_Property] = 169 properties[WindowManager::kName_Property] =
165 mojo::ConvertTo<std::vector<uint8_t>>(init_params.name); 170 mojo::ConvertTo<TransportType>(init_params.name);
166 } 171 }
167 172
168 properties[ui::mojom::WindowManager::kAlwaysOnTop_Property] = 173 properties[WindowManager::kAlwaysOnTop_Property] =
169 mojo::ConvertTo<std::vector<uint8_t>>( 174 mojo::ConvertTo<TransportType>(
170 static_cast<PrimitiveType>(init_params.keep_on_top)); 175 static_cast<PrimitiveType>(init_params.keep_on_top));
171 176
177 properties[WindowManager::kRemoveStandardFrame_InitProperty] =
178 mojo::ConvertTo<TransportType>(init_params.remove_standard_frame);
179
172 if (!Widget::RequiresNonClientView(init_params.type)) 180 if (!Widget::RequiresNonClientView(init_params.type))
173 return properties; 181 return properties;
174 182
175 if (init_params.delegate) { 183 if (init_params.delegate) {
176 if (properties.count(ui::mojom::WindowManager::kResizeBehavior_Property) == 184 if (properties.count(WindowManager::kResizeBehavior_Property) == 0) {
177 0) { 185 properties[WindowManager::kResizeBehavior_Property] =
178 properties[ui::mojom::WindowManager::kResizeBehavior_Property] = 186 mojo::ConvertTo<TransportType>(static_cast<PrimitiveType>(
179 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<PrimitiveType>(
180 init_params.delegate->GetResizeBehavior())); 187 init_params.delegate->GetResizeBehavior()));
181 } 188 }
182 189
183 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. 190 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia].
184 gfx::ImageSkia app_icon = init_params.delegate->GetWindowAppIcon(); 191 gfx::ImageSkia app_icon = init_params.delegate->GetWindowAppIcon();
185 SkBitmap app_bitmap = app_icon.GetRepresentation(1.f).sk_bitmap(); 192 SkBitmap app_bitmap = app_icon.GetRepresentation(1.f).sk_bitmap();
186 if (!app_bitmap.isNull()) { 193 if (!app_bitmap.isNull()) {
187 properties[ui::mojom::WindowManager::kAppIcon_Property] = 194 properties[WindowManager::kAppIcon_Property] =
188 mojo::ConvertTo<std::vector<uint8_t>>(app_bitmap); 195 mojo::ConvertTo<TransportType>(app_bitmap);
189 } 196 }
190 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. 197 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia].
191 gfx::ImageSkia window_icon = init_params.delegate->GetWindowIcon(); 198 gfx::ImageSkia window_icon = init_params.delegate->GetWindowIcon();
192 SkBitmap window_bitmap = window_icon.GetRepresentation(1.f).sk_bitmap(); 199 SkBitmap window_bitmap = window_icon.GetRepresentation(1.f).sk_bitmap();
193 if (!window_bitmap.isNull()) { 200 if (!window_bitmap.isNull()) {
194 properties[ui::mojom::WindowManager::kWindowIcon_Property] = 201 properties[WindowManager::kWindowIcon_Property] =
195 mojo::ConvertTo<std::vector<uint8_t>>(window_bitmap); 202 mojo::ConvertTo<TransportType>(window_bitmap);
196 } 203 }
197 } 204 }
198 205
199 return properties; 206 return properties;
200 } 207 }
201 208
202 NativeWidget* MusClient::CreateNativeWidget( 209 NativeWidget* MusClient::CreateNativeWidget(
203 const Widget::InitParams& init_params, 210 const Widget::InitParams& init_params,
204 internal::NativeWidgetDelegate* delegate) { 211 internal::NativeWidgetDelegate* delegate) {
205 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) { 212 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return root->GetTopWindowContainingPoint(relative_point); 294 return root->GetTopWindowContainingPoint(relative_point);
288 } 295 }
289 return nullptr; 296 return nullptr;
290 } 297 }
291 298
292 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { 299 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() {
293 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); 300 return base::MakeUnique<aura::OSExchangeDataProviderMus>();
294 } 301 }
295 302
296 } // namespace views 303 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus_unittest.cc ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698