Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
| 9 #include "components/mus/public/cpp/window_tree_connection.h" | 9 #include "components/mus/public/cpp/window_tree_connection.h" |
| 10 #include "components/mus/public/interfaces/window_tree.mojom.h" | 10 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 11 #include "mojo/application/public/cpp/application_connection.h" | 11 #include "mojo/application/public/cpp/application_connection.h" |
| 12 #include "mojo/application/public/cpp/application_impl.h" | 12 #include "mojo/application/public/cpp/application_impl.h" |
| 13 #include "mojo/converters/geometry/geometry_type_converters.h" | 13 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 14 #include "mojo/converters/network/network_type_converters.h" | 14 #include "mojo/converters/network/network_type_converters.h" |
| 15 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
| 16 #include "ui/gfx/geometry/point_conversions.h" | 16 #include "ui/gfx/geometry/point_conversions.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/views/mus/aura_init.h" | 18 #include "ui/views/mus/aura_init.h" |
| 19 #include "ui/views/mus/native_widget_mus.h" | 19 #include "ui/views/mus/native_widget_mus.h" |
| 20 #include "ui/views/mus/window_manager_client_area_insets.h" | |
| 20 | 21 |
| 21 namespace mojo { | 22 namespace mojo { |
| 22 | 23 |
| 23 gfx::Display::Rotation GFXRotationFromMojomRotation( | 24 gfx::Display::Rotation GFXRotationFromMojomRotation( |
| 24 mus::mojom::Rotation input) { | 25 mus::mojom::Rotation input) { |
| 25 switch (input) { | 26 switch (input) { |
| 26 case mus::mojom::ROTATION_VALUE_0: | 27 case mus::mojom::ROTATION_VALUE_0: |
| 27 return gfx::Display::ROTATE_0; | 28 return gfx::Display::ROTATE_0; |
| 28 case mus::mojom::ROTATION_VALUE_90: | 29 case mus::mojom::ROTATION_VALUE_90: |
| 29 return gfx::Display::ROTATE_90; | 30 return gfx::Display::ROTATE_90; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 50 gfx::Size(input->work_area->width, input->work_area->height), | 51 gfx::Size(input->work_area->width, input->work_area->height), |
| 51 1.0f / input->device_pixel_ratio)); | 52 1.0f / input->device_pixel_ratio)); |
| 52 result.set_work_area(work_area); | 53 result.set_work_area(work_area); |
| 53 result.set_rotation(GFXRotationFromMojomRotation(input->rotation)); | 54 result.set_rotation(GFXRotationFromMojomRotation(input->rotation)); |
| 54 return result; | 55 return result; |
| 55 } | 56 } |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 } // namespace mojo | 59 } // namespace mojo |
| 59 | 60 |
| 61 namespace views { | |
| 62 | |
| 60 namespace { | 63 namespace { |
| 61 | 64 |
| 62 using WindowManagerConnectionPtr = | 65 using WindowManagerConnectionPtr = |
| 63 base::ThreadLocalPointer<views::WindowManagerConnection>; | 66 base::ThreadLocalPointer<views::WindowManagerConnection>; |
| 64 | 67 |
| 65 // Env is thread local so that aura may be used on multiple threads. | 68 // Env is thread local so that aura may be used on multiple threads. |
| 66 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = | 69 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = |
| 67 LAZY_INSTANCE_INITIALIZER; | 70 LAZY_INSTANCE_INITIALIZER; |
| 68 | 71 |
| 69 std::vector<gfx::Display> GetDisplaysFromWindowManager( | 72 std::vector<gfx::Display> GetDisplaysFromWindowManager( |
| 70 mus::mojom::WindowManagerPtr* window_manager) { | 73 mus::mojom::WindowManagerPtr* window_manager) { |
| 74 WindowManagerClientAreaInsets client_insets; | |
| 71 std::vector<gfx::Display> displays; | 75 std::vector<gfx::Display> displays; |
| 72 (*window_manager)->GetDisplays( | 76 (*window_manager) |
| 73 [&displays](mojo::Array<mus::mojom::DisplayPtr> mojom_displays) { | 77 ->GetConfig([&displays, |
| 74 displays = mojom_displays.To<std::vector<gfx::Display>>(); | 78 &client_insets](mus::mojom::WindowManagerConfigPtr results) { |
| 79 displays = results->displays.To<std::vector<gfx::Display>>(); | |
| 80 client_insets.normal_insets = | |
| 81 results->normal_client_area_insets.To<gfx::Insets>(); | |
| 82 client_insets.maximized_insets = | |
| 83 results->maximized_client_area_insets.To<gfx::Insets>(); | |
| 75 }); | 84 }); |
| 76 CHECK(window_manager->WaitForIncomingResponse()); | 85 CHECK(window_manager->WaitForIncomingResponse()); |
| 86 NativeWidgetMus::SetWindowManagerClientAreaInsets(client_insets); | |
|
Ben Goodger (Google)
2015/11/04 23:03:21
i'm a little concerned about this API in the futur
| |
| 77 return displays; | 87 return displays; |
| 78 } | 88 } |
| 79 | 89 |
| 80 } | 90 } // namespace |
| 81 | |
| 82 namespace views { | |
| 83 | 91 |
| 84 // static | 92 // static |
| 85 void WindowManagerConnection::Create( | 93 void WindowManagerConnection::Create( |
| 86 mus::mojom::WindowManagerPtr window_manager, | 94 mus::mojom::WindowManagerPtr window_manager, |
| 87 mojo::ApplicationImpl* app) { | 95 mojo::ApplicationImpl* app) { |
| 88 DCHECK(!lazy_tls_ptr.Pointer()->Get()); | 96 DCHECK(!lazy_tls_ptr.Pointer()->Get()); |
| 89 lazy_tls_ptr.Pointer()->Set( | 97 lazy_tls_ptr.Pointer()->Set( |
| 90 new WindowManagerConnection(window_manager.Pass(), app)); | 98 new WindowManagerConnection(window_manager.Pass(), app)); |
| 91 } | 99 } |
| 92 | 100 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 void WindowManagerConnection::OnConnectionLost( | 148 void WindowManagerConnection::OnConnectionLost( |
| 141 mus::WindowTreeConnection* connection) {} | 149 mus::WindowTreeConnection* connection) {} |
| 142 | 150 |
| 143 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
| 144 HICON WindowManagerConnection::GetSmallWindowIcon() const { | 152 HICON WindowManagerConnection::GetSmallWindowIcon() const { |
| 145 return nullptr; | 153 return nullptr; |
| 146 } | 154 } |
| 147 #endif | 155 #endif |
| 148 | 156 |
| 149 } // namespace views | 157 } // namespace views |
| OLD | NEW |