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

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

Issue 2514243002: Propagates window type properties during aura-mus window creation (Closed)
Patch Set: merge Created 4 years 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
« no previous file with comments | « ui/views/mus/mus_client.h ('k') | ui/views/test/native_widget_factory_aura_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/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"
13 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
14 #include "ui/aura/mus/mus_context_factory.h" 16 #include "ui/aura/mus/mus_context_factory.h"
15 #include "ui/aura/mus/os_exchange_data_provider_mus.h" 17 #include "ui/aura/mus/os_exchange_data_provider_mus.h"
16 #include "ui/aura/mus/property_converter.h" 18 #include "ui/aura/mus/property_converter.h"
17 #include "ui/aura/mus/window_tree_client.h" 19 #include "ui/aura/mus/window_tree_client.h"
18 #include "ui/aura/mus/window_tree_host_mus.h" 20 #include "ui/aura/mus/window_tree_host_mus.h"
19 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
20 #include "ui/aura/window_tree_host.h" 22 #include "ui/aura/window_tree_host.h"
21 #include "ui/views/mus/aura_init.h" 23 #include "ui/views/mus/aura_init.h"
22 #include "ui/views/mus/clipboard_mus.h" 24 #include "ui/views/mus/clipboard_mus.h"
23 #include "ui/views/mus/desktop_window_tree_host_mus.h" 25 #include "ui/views/mus/desktop_window_tree_host_mus.h"
24 #include "ui/views/mus/screen_mus.h" 26 #include "ui/views/mus/screen_mus.h"
25 #include "ui/views/views_delegate.h" 27 #include "ui/views/views_delegate.h"
26 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
27 #include "ui/wm/core/capture_controller.h" 29 #include "ui/wm/core/capture_controller.h"
28 #include "ui/wm/core/wm_state.h" 30 #include "ui/wm/core/wm_state.h"
29 31
32 // Widget::InitParams::Type must match that of ui::mojom::WindowType.
33 #define WINDOW_TYPES_MATCH(NAME) \
34 static_assert( \
35 static_cast<int32_t>(views::Widget::InitParams::TYPE_##NAME) == \
36 static_cast<int32_t>(ui::mojom::WindowType::NAME), \
37 "Window type constants must match")
38
39 WINDOW_TYPES_MATCH(WINDOW);
40 WINDOW_TYPES_MATCH(PANEL);
41 WINDOW_TYPES_MATCH(WINDOW_FRAMELESS);
42 WINDOW_TYPES_MATCH(CONTROL);
43 WINDOW_TYPES_MATCH(POPUP);
44 WINDOW_TYPES_MATCH(MENU);
45 WINDOW_TYPES_MATCH(TOOLTIP);
46 WINDOW_TYPES_MATCH(BUBBLE);
47 WINDOW_TYPES_MATCH(DRAG);
48 // ui::mojom::WindowType::UNKNOWN does not correspond to a value in
49 // Widget::InitParams::Type.
50
30 namespace views { 51 namespace views {
31 52
32 // static 53 // static
33 MusClient* MusClient::instance_ = nullptr; 54 MusClient* MusClient::instance_ = nullptr;
34 55
35 MusClient::~MusClient() { 56 MusClient::~MusClient() {
36 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while 57 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while
37 // we are still valid. 58 // we are still valid.
38 window_tree_client_.reset(); 59 window_tree_client_.reset();
39 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); 60 ui::OSExchangeDataProviderFactory::SetFactory(nullptr);
(...skipping 10 matching lines...) Expand all
50 } 71 }
51 72
52 // static 73 // static
53 bool MusClient::ShouldCreateDesktopNativeWidgetAura( 74 bool MusClient::ShouldCreateDesktopNativeWidgetAura(
54 const Widget::InitParams& init_params) { 75 const Widget::InitParams& init_params) {
55 // TYPE_CONTROL and child widgets require a NativeWidgetAura. 76 // TYPE_CONTROL and child widgets require a NativeWidgetAura.
56 return init_params.type != Widget::InitParams::TYPE_CONTROL && 77 return init_params.type != Widget::InitParams::TYPE_CONTROL &&
57 !init_params.child; 78 !init_params.child;
58 } 79 }
59 80
81 // static
82 std::map<std::string, std::vector<uint8_t>>
83 MusClient::ConfigurePropertiesFromParams(
84 const Widget::InitParams& init_params) {
85 std::map<std::string, std::vector<uint8_t>> mus_properties =
86 init_params.mus_properties;
87 // Widget::InitParams::Type matches ui::mojom::WindowType.
88 mus_properties[ui::mojom::WindowManager::kWindowType_Property] =
89 mojo::ConvertTo<std::vector<uint8_t>>(
90 static_cast<int32_t>(init_params.type));
91 return mus_properties;
92 }
93
60 NativeWidget* MusClient::CreateNativeWidget( 94 NativeWidget* MusClient::CreateNativeWidget(
61 const Widget::InitParams& init_params, 95 const Widget::InitParams& init_params,
62 internal::NativeWidgetDelegate* delegate) { 96 internal::NativeWidgetDelegate* delegate) {
63 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) { 97 if (!ShouldCreateDesktopNativeWidgetAura(init_params)) {
64 // A null return value results in creating NativeWidgetAura. 98 // A null return value results in creating NativeWidgetAura.
65 return nullptr; 99 return nullptr;
66 } 100 }
67 101
68 DesktopNativeWidgetAura* native_widget = 102 DesktopNativeWidgetAura* native_widget =
69 new DesktopNativeWidgetAura(delegate); 103 new DesktopNativeWidgetAura(delegate);
70 if (init_params.desktop_window_tree_host) { 104 if (init_params.desktop_window_tree_host) {
71 native_widget->SetDesktopWindowTreeHost( 105 native_widget->SetDesktopWindowTreeHost(
72 base::WrapUnique(init_params.desktop_window_tree_host)); 106 base::WrapUnique(init_params.desktop_window_tree_host));
73 } else { 107 } else {
108 std::map<std::string, std::vector<uint8_t>> mus_properties =
109 ConfigurePropertiesFromParams(init_params);
74 native_widget->SetDesktopWindowTreeHost( 110 native_widget->SetDesktopWindowTreeHost(
75 base::MakeUnique<DesktopWindowTreeHostMus>(delegate, native_widget, 111 base::MakeUnique<DesktopWindowTreeHostMus>(delegate, native_widget,
76 init_params)); 112 &mus_properties));
77 } 113 }
78 return native_widget; 114 return native_widget;
79 } 115 }
80 116
81 MusClient::MusClient(service_manager::Connector* connector, 117 MusClient::MusClient(service_manager::Connector* connector,
82 const service_manager::Identity& identity, 118 const service_manager::Identity& identity,
83 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) 119 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
84 : connector_(connector), identity_(identity) { 120 : connector_(connector), identity_(identity) {
85 DCHECK(!instance_); 121 DCHECK(!instance_);
86 instance_ = this; 122 instance_ = this;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return root->GetTopWindowContainingPoint(relative_point); 198 return root->GetTopWindowContainingPoint(relative_point);
163 } 199 }
164 return nullptr; 200 return nullptr;
165 } 201 }
166 202
167 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { 203 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() {
168 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); 204 return base::MakeUnique<aura::OSExchangeDataProviderMus>();
169 } 205 }
170 206
171 } // namespace views 207 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/mus_client.h ('k') | ui/views/test/native_widget_factory_aura_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698