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

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

Issue 1618963005: Revert of Start of display management for mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/window_manager_connection.h" 5 #include "ui/views/mus/window_manager_connection.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
12 #include "components/mus/public/cpp/window_tree_connection.h" 12 #include "components/mus/public/cpp/window_tree_connection.h"
13 #include "components/mus/public/interfaces/window_tree.mojom.h" 13 #include "components/mus/public/interfaces/window_tree.mojom.h"
14 #include "mojo/converters/geometry/geometry_type_converters.h" 14 #include "mojo/converters/geometry/geometry_type_converters.h"
15 #include "mojo/converters/network/network_type_converters.h" 15 #include "mojo/converters/network/network_type_converters.h"
16 #include "mojo/shell/public/cpp/application_connection.h" 16 #include "mojo/shell/public/cpp/application_connection.h"
17 #include "mojo/shell/public/cpp/application_impl.h" 17 #include "mojo/shell/public/cpp/application_impl.h"
18 #include "ui/gfx/display.h"
19 #include "ui/gfx/geometry/point_conversions.h"
20 #include "ui/gfx/geometry/rect.h"
21 #include "ui/mojo/init/ui_init.h"
18 #include "ui/views/mus/native_widget_mus.h" 22 #include "ui/views/mus/native_widget_mus.h"
19 #include "ui/views/mus/screen_mus.h"
20 #include "ui/views/mus/window_manager_frame_values.h" 23 #include "ui/views/mus/window_manager_frame_values.h"
21 #include "ui/views/views_delegate.h" 24 #include "ui/views/views_delegate.h"
22 25
26 namespace mojo {
27
28 gfx::Display::Rotation GFXRotationFromMojomRotation(
29 mus::mojom::Rotation input) {
30 switch (input) {
31 case mus::mojom::Rotation::VALUE_0:
32 return gfx::Display::ROTATE_0;
33 case mus::mojom::Rotation::VALUE_90:
34 return gfx::Display::ROTATE_90;
35 case mus::mojom::Rotation::VALUE_180:
36 return gfx::Display::ROTATE_180;
37 case mus::mojom::Rotation::VALUE_270:
38 return gfx::Display::ROTATE_270;
39 }
40 return gfx::Display::ROTATE_0;
41 }
42
43 template <>
44 struct TypeConverter<gfx::Display, mus::mojom::DisplayPtr> {
45 static gfx::Display Convert(const mus::mojom::DisplayPtr& input) {
46 gfx::Display result;
47 result.set_id(input->id);
48 result.SetScaleAndBounds(input->device_pixel_ratio,
49 input->bounds.To<gfx::Rect>());
50 gfx::Rect work_area(
51 gfx::ScaleToFlooredPoint(
52 gfx::Point(input->work_area->x, input->work_area->y),
53 1.0f / input->device_pixel_ratio),
54 gfx::ScaleToFlooredSize(
55 gfx::Size(input->work_area->width, input->work_area->height),
56 1.0f / input->device_pixel_ratio));
57 result.set_work_area(work_area);
58 result.set_rotation(GFXRotationFromMojomRotation(input->rotation));
59 return result;
60 }
61 };
62
63 } // namespace mojo
64
23 namespace views { 65 namespace views {
66
24 namespace { 67 namespace {
25 68
26 using WindowManagerConnectionPtr = 69 using WindowManagerConnectionPtr =
27 base::ThreadLocalPointer<views::WindowManagerConnection>; 70 base::ThreadLocalPointer<views::WindowManagerConnection>;
28 71
29 // Env is thread local so that aura may be used on multiple threads. 72 // Env is thread local so that aura may be used on multiple threads.
30 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = 73 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr =
31 LAZY_INSTANCE_INITIALIZER; 74 LAZY_INSTANCE_INITIALIZER;
32 75
76 std::vector<gfx::Display> GetDisplaysFromWindowManager(
77 mus::mojom::WindowManagerPtr* window_manager) {
78 WindowManagerFrameValues frame_values;
79 std::vector<gfx::Display> displays;
80 (*window_manager)
81 ->GetConfig([&displays,
82 &frame_values](mus::mojom::WindowManagerConfigPtr results) {
83 displays = results->displays.To<std::vector<gfx::Display>>();
84 frame_values.normal_insets =
85 results->normal_client_area_insets.To<gfx::Insets>();
86 frame_values.maximized_insets =
87 results->maximized_client_area_insets.To<gfx::Insets>();
88 frame_values.max_title_bar_button_width =
89 results->max_title_bar_button_width;
90 });
91 CHECK(window_manager->WaitForIncomingResponse());
92 WindowManagerFrameValues::SetInstance(frame_values);
93 return displays;
94 }
95
33 } // namespace 96 } // namespace
34 97
35 // static 98 // static
36 void WindowManagerConnection::Create(mojo::ApplicationImpl* app) { 99 void WindowManagerConnection::Create(mojo::ApplicationImpl* app) {
37 DCHECK(!lazy_tls_ptr.Pointer()->Get()); 100 DCHECK(!lazy_tls_ptr.Pointer()->Get());
38 lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(app)); 101 lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(app));
39 } 102 }
40 103
41 // static 104 // static
42 WindowManagerConnection* WindowManagerConnection::Get() { 105 WindowManagerConnection* WindowManagerConnection::Get() {
(...skipping 20 matching lines...) Expand all
63 mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED)); 126 mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED));
64 window_tree_connection_->SetDeleteOnNoRoots(false); 127 window_tree_connection_->SetDeleteOnNoRoots(false);
65 DCHECK_EQ(1u, window_tree_connection_->GetRoots().size()); 128 DCHECK_EQ(1u, window_tree_connection_->GetRoots().size());
66 return *window_tree_connection_->GetRoots().begin(); 129 return *window_tree_connection_->GetRoots().begin();
67 } 130 }
68 131
69 WindowManagerConnection::WindowManagerConnection(mojo::ApplicationImpl* app) 132 WindowManagerConnection::WindowManagerConnection(mojo::ApplicationImpl* app)
70 : app_(app), window_tree_connection_(nullptr) { 133 : app_(app), window_tree_connection_(nullptr) {
71 app->ConnectToService("mojo:mus", &window_manager_); 134 app->ConnectToService("mojo:mus", &window_manager_);
72 135
73 screen_.reset(new ScreenMus); 136 ui_init_.reset(new ui::mojo::UIInit(
74 screen_->Init(app); 137 GetDisplaysFromWindowManager(&window_manager_)));
75 ViewsDelegate::GetInstance()->set_native_widget_factory( 138 ViewsDelegate::GetInstance()->set_native_widget_factory(
76 base::Bind(&WindowManagerConnection::CreateNativeWidget, 139 base::Bind(&WindowManagerConnection::CreateNativeWidget,
77 base::Unretained(this))); 140 base::Unretained(this)));
78 } 141 }
79 142
80 WindowManagerConnection::~WindowManagerConnection() { 143 WindowManagerConnection::~WindowManagerConnection() {
81 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate), 144 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate),
82 // destroy it while we are still valid. 145 // destroy it while we are still valid.
83 window_tree_connection_.reset(); 146 window_tree_connection_.reset();
84 } 147 }
85 148
86 void WindowManagerConnection::OnEmbed(mus::Window* root) {} 149 void WindowManagerConnection::OnEmbed(mus::Window* root) {}
87 150
88 void WindowManagerConnection::OnConnectionLost( 151 void WindowManagerConnection::OnConnectionLost(
89 mus::WindowTreeConnection* connection) {} 152 mus::WindowTreeConnection* connection) {}
90 153
91 NativeWidget* WindowManagerConnection::CreateNativeWidget( 154 NativeWidget* WindowManagerConnection::CreateNativeWidget(
92 const Widget::InitParams& init_params, 155 const Widget::InitParams& init_params,
93 internal::NativeWidgetDelegate* delegate) { 156 internal::NativeWidgetDelegate* delegate) {
94 std::map<std::string, std::vector<uint8_t>> properties; 157 std::map<std::string, std::vector<uint8_t>> properties;
95 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties); 158 NativeWidgetMus::ConfigurePropertiesForNewWindow(init_params, &properties);
96 return new NativeWidgetMus(delegate, app_->shell(), NewWindow(properties), 159 return new NativeWidgetMus(delegate, app_->shell(), NewWindow(properties),
97 mus::mojom::SurfaceType::DEFAULT); 160 mus::mojom::SurfaceType::DEFAULT);
98 } 161 }
99 162
100 } // namespace views 163 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698