| 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 "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 "services/service_manager/public/cpp/connection.h" | 9 #include "services/service_manager/public/cpp/connection.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| 11 #include "services/ui/public/cpp/gpu/gpu_service.h" | 11 #include "services/ui/public/cpp/gpu/gpu_service.h" |
| 12 #include "services/ui/public/cpp/property_type_converters.h" | 12 #include "services/ui/public/cpp/property_type_converters.h" |
| 13 #include "services/ui/public/interfaces/event_matcher.mojom.h" | 13 #include "services/ui/public/interfaces/event_matcher.mojom.h" |
| 14 #include "services/ui/public/interfaces/window_manager.mojom.h" | 14 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 16 #include "ui/aura/mus/mus_context_factory.h" | 16 #include "ui/aura/mus/mus_context_factory.h" |
| 17 #include "ui/aura/mus/os_exchange_data_provider_mus.h" | 17 #include "ui/aura/mus/os_exchange_data_provider_mus.h" |
| 18 #include "ui/aura/mus/property_converter.h" | 18 #include "ui/aura/mus/property_converter.h" |
| 19 #include "ui/aura/mus/window_tree_client.h" | 19 #include "ui/aura/mus/window_tree_client.h" |
| 20 #include "ui/aura/mus/window_tree_host_mus.h" | 20 #include "ui/aura/mus/window_tree_host_mus.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_tree_host.h" | 22 #include "ui/aura/window_tree_host.h" |
| 23 #include "ui/views/mus/aura_init.h" | 23 #include "ui/views/mus/aura_init.h" |
| 24 #include "ui/views/mus/clipboard_mus.h" | 24 #include "ui/views/mus/clipboard_mus.h" |
| 25 #include "ui/views/mus/desktop_window_tree_host_mus.h" | 25 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
| 26 #include "ui/views/mus/pointer_watcher_event_router2.h" | 26 #include "ui/views/mus/pointer_watcher_event_router2.h" |
| 27 #include "ui/views/mus/screen_mus.h" | 27 #include "ui/views/mus/screen_mus.h" |
| 28 #include "ui/views/views_delegate.h" | 28 #include "ui/views/views_delegate.h" |
| 29 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 29 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 30 #include "ui/views/widget/widget_delegate.h" |
| 30 #include "ui/wm/core/capture_controller.h" | 31 #include "ui/wm/core/capture_controller.h" |
| 31 #include "ui/wm/core/wm_state.h" | 32 #include "ui/wm/core/wm_state.h" |
| 32 | 33 |
| 33 // Widget::InitParams::Type must match that of ui::mojom::WindowType. | 34 // Widget::InitParams::Type must match that of ui::mojom::WindowType. |
| 34 #define WINDOW_TYPES_MATCH(NAME) \ | 35 #define WINDOW_TYPES_MATCH(NAME) \ |
| 35 static_assert( \ | 36 static_assert( \ |
| 36 static_cast<int32_t>(views::Widget::InitParams::TYPE_##NAME) == \ | 37 static_cast<int32_t>(views::Widget::InitParams::TYPE_##NAME) == \ |
| 37 static_cast<int32_t>(ui::mojom::WindowType::NAME), \ | 38 static_cast<int32_t>(ui::mojom::WindowType::NAME), \ |
| 38 "Window type constants must match") | 39 "Window type constants must match") |
| 39 | 40 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const Widget::InitParams& init_params) { | 77 const Widget::InitParams& init_params) { |
| 77 // TYPE_CONTROL and child widgets require a NativeWidgetAura. | 78 // TYPE_CONTROL and child widgets require a NativeWidgetAura. |
| 78 return init_params.type != Widget::InitParams::TYPE_CONTROL && | 79 return init_params.type != Widget::InitParams::TYPE_CONTROL && |
| 79 !init_params.child; | 80 !init_params.child; |
| 80 } | 81 } |
| 81 | 82 |
| 82 // static | 83 // static |
| 83 std::map<std::string, std::vector<uint8_t>> | 84 std::map<std::string, std::vector<uint8_t>> |
| 84 MusClient::ConfigurePropertiesFromParams( | 85 MusClient::ConfigurePropertiesFromParams( |
| 85 const Widget::InitParams& init_params) { | 86 const Widget::InitParams& init_params) { |
| 86 std::map<std::string, std::vector<uint8_t>> mus_properties = | 87 using PrimitiveType = aura::PropertyConverter::PrimitiveType; |
| 88 std::map<std::string, std::vector<uint8_t>> properties = |
| 87 init_params.mus_properties; | 89 init_params.mus_properties; |
| 90 |
| 88 // Widget::InitParams::Type matches ui::mojom::WindowType. | 91 // Widget::InitParams::Type matches ui::mojom::WindowType. |
| 89 mus_properties[ui::mojom::WindowManager::kWindowType_Property] = | 92 properties[ui::mojom::WindowManager::kWindowType_Property] = |
| 90 mojo::ConvertTo<std::vector<uint8_t>>( | 93 mojo::ConvertTo<std::vector<uint8_t>>( |
| 91 static_cast<int32_t>(init_params.type)); | 94 static_cast<int32_t>(init_params.type)); |
| 92 return mus_properties; | 95 |
| 96 if (!init_params.bounds.IsEmpty()) { |
| 97 properties[ui::mojom::WindowManager::kInitialBounds_Property] = |
| 98 mojo::ConvertTo<std::vector<uint8_t>>(init_params.bounds); |
| 99 } |
| 100 |
| 101 if (!init_params.name.empty()) { |
| 102 properties[ui::mojom::WindowManager::kName_Property] = |
| 103 mojo::ConvertTo<std::vector<uint8_t>>(init_params.name); |
| 104 } |
| 105 |
| 106 properties[ui::mojom::WindowManager::kAlwaysOnTop_Property] = |
| 107 mojo::ConvertTo<std::vector<uint8_t>>( |
| 108 static_cast<PrimitiveType>(init_params.keep_on_top)); |
| 109 |
| 110 if (!Widget::RequiresNonClientView(init_params.type)) |
| 111 return properties; |
| 112 |
| 113 if (init_params.delegate) { |
| 114 if (properties.count(ui::mojom::WindowManager::kResizeBehavior_Property) == |
| 115 0) { |
| 116 properties[ui::mojom::WindowManager::kResizeBehavior_Property] = |
| 117 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<PrimitiveType>( |
| 118 DesktopWindowTreeHostMus::GetResizeBehaviorFromDelegate( |
| 119 init_params.delegate))); |
| 120 } |
| 121 |
| 122 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. |
| 123 gfx::ImageSkia app_icon = init_params.delegate->GetWindowAppIcon(); |
| 124 SkBitmap app_bitmap = app_icon.GetRepresentation(1.f).sk_bitmap(); |
| 125 if (!app_bitmap.isNull()) { |
| 126 properties[ui::mojom::WindowManager::kAppIcon_Property] = |
| 127 mojo::ConvertTo<std::vector<uint8_t>>(app_bitmap); |
| 128 } |
| 129 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. |
| 130 gfx::ImageSkia window_icon = init_params.delegate->GetWindowIcon(); |
| 131 SkBitmap window_bitmap = window_icon.GetRepresentation(1.f).sk_bitmap(); |
| 132 if (!window_bitmap.isNull()) { |
| 133 properties[ui::mojom::WindowManager::kWindowIcon_Property] = |
| 134 mojo::ConvertTo<std::vector<uint8_t>>(window_bitmap); |
| 135 } |
| 136 } |
| 137 |
| 138 return properties; |
| 93 } | 139 } |
| 94 | 140 |
| 95 NativeWidget* MusClient::CreateNativeWidget( | 141 NativeWidget* MusClient::CreateNativeWidget( |
| 96 const Widget::InitParams& init_params, | 142 const Widget::InitParams& init_params, |
| 97 internal::NativeWidgetDelegate* delegate) { | 143 internal::NativeWidgetDelegate* delegate) { |
| 98 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) { | 144 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) { |
| 99 // A null return value results in creating NativeWidgetAura. | 145 // A null return value results in creating NativeWidgetAura. |
| 100 return nullptr; | 146 return nullptr; |
| 101 } | 147 } |
| 102 | 148 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 return root->GetTopWindowContainingPoint(relative_point); | 253 return root->GetTopWindowContainingPoint(relative_point); |
| 208 } | 254 } |
| 209 return nullptr; | 255 return nullptr; |
| 210 } | 256 } |
| 211 | 257 |
| 212 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { | 258 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { |
| 213 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 259 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
| 214 } | 260 } |
| 215 | 261 |
| 216 } // namespace views | 262 } // namespace views |
| OLD | NEW |