| 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 "components/mus/ws/display.h" | 5 #include "components/mus/ws/display.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/mus/common/types.h" | 12 #include "components/mus/common/types.h" |
| 13 #include "components/mus/ws/display_binding.h" | 13 #include "components/mus/ws/display_binding.h" |
| 14 #include "components/mus/ws/display_manager.h" | 14 #include "components/mus/ws/display_manager.h" |
| 15 #include "components/mus/ws/focus_controller.h" | 15 #include "components/mus/ws/focus_controller.h" |
| 16 #include "components/mus/ws/platform_display.h" | 16 #include "components/mus/ws/platform_display.h" |
| 17 #include "components/mus/ws/platform_display_init_params.h" | 17 #include "components/mus/ws/platform_display_init_params.h" |
| 18 #include "components/mus/ws/window_manager_factory_service.h" | 18 #include "components/mus/ws/window_manager_factory_service.h" |
| 19 #include "components/mus/ws/window_manager_state.h" | 19 #include "components/mus/ws/window_manager_state.h" |
| 20 #include "components/mus/ws/window_server.h" | 20 #include "components/mus/ws/window_server.h" |
| 21 #include "components/mus/ws/window_server_delegate.h" | 21 #include "components/mus/ws/window_server_delegate.h" |
| 22 #include "components/mus/ws/window_tree.h" | 22 #include "components/mus/ws/window_tree.h" |
| 23 #include "components/mus/ws/window_tree_binding.h" | 23 #include "components/mus/ws/window_tree_binding.h" |
| 24 #include "mojo/common/common_type_converters.h" | 24 #include "mojo/common/common_type_converters.h" |
| 25 #include "services/shell/public/interfaces/connector.mojom.h" | 25 #include "services/shell/public/interfaces/connector.mojom.h" |
| 26 #include "ui/base/cursor/cursor.h" | 26 #include "ui/base/cursor/cursor.h" |
| 27 #include "ui/gfx/geometry/mojo/geometry_type_converters.h" | |
| 28 | 27 |
| 29 namespace mus { | 28 namespace mus { |
| 30 namespace ws { | 29 namespace ws { |
| 31 | 30 |
| 32 Display::Display(WindowServer* window_server, | 31 Display::Display(WindowServer* window_server, |
| 33 const PlatformDisplayInitParams& platform_display_init_params) | 32 const PlatformDisplayInitParams& platform_display_init_params) |
| 34 : id_(window_server->display_manager()->GetAndAdvanceNextDisplayId()), | 33 : id_(window_server->display_manager()->GetAndAdvanceNextDisplayId()), |
| 35 window_server_(window_server), | 34 window_server_(window_server), |
| 36 platform_display_(PlatformDisplay::Create(platform_display_init_params)), | 35 platform_display_(PlatformDisplay::Create(platform_display_init_params)), |
| 37 last_cursor_(ui::kCursorNone) { | 36 last_cursor_(ui::kCursorNone) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 75 } |
| 77 | 76 |
| 78 const DisplayManager* Display::display_manager() const { | 77 const DisplayManager* Display::display_manager() const { |
| 79 return window_server_->display_manager(); | 78 return window_server_->display_manager(); |
| 80 } | 79 } |
| 81 | 80 |
| 82 mojom::DisplayPtr Display::ToMojomDisplay() const { | 81 mojom::DisplayPtr Display::ToMojomDisplay() const { |
| 83 mojom::DisplayPtr display_ptr = mojom::Display::New(); | 82 mojom::DisplayPtr display_ptr = mojom::Display::New(); |
| 84 display_ptr = mojom::Display::New(); | 83 display_ptr = mojom::Display::New(); |
| 85 display_ptr->id = id_; | 84 display_ptr->id = id_; |
| 86 display_ptr->bounds = mojo::Rect::New(); | |
| 87 // TODO(sky): Display should know it's origin. | 85 // TODO(sky): Display should know it's origin. |
| 88 display_ptr->bounds->x = 0; | 86 display_ptr->bounds.SetRect(0, 0, root_->bounds().size().width(), |
| 89 display_ptr->bounds->y = 0; | 87 root_->bounds().size().height()); |
| 90 display_ptr->bounds->width = root_->bounds().size().width(); | |
| 91 display_ptr->bounds->height = root_->bounds().size().height(); | |
| 92 // TODO(sky): window manager needs an API to set the work area. | 88 // TODO(sky): window manager needs an API to set the work area. |
| 93 display_ptr->work_area = display_ptr->bounds.Clone(); | 89 display_ptr->work_area = display_ptr->bounds; |
| 94 display_ptr->device_pixel_ratio = platform_display_->GetDeviceScaleFactor(); | 90 display_ptr->device_pixel_ratio = platform_display_->GetDeviceScaleFactor(); |
| 95 display_ptr->rotation = platform_display_->GetRotation(); | 91 display_ptr->rotation = platform_display_->GetRotation(); |
| 96 // TODO(sky): make this real. | 92 // TODO(sky): make this real. |
| 97 display_ptr->is_primary = true; | 93 display_ptr->is_primary = true; |
| 98 // TODO(sky): make this real. | 94 // TODO(sky): make this real. |
| 99 display_ptr->touch_support = mojom::TouchSupport::UNKNOWN; | 95 display_ptr->touch_support = mojom::TouchSupport::UNKNOWN; |
| 100 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); | 96 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); |
| 101 display_ptr->frame_decoration_values->normal_client_area_insets = | |
| 102 mojo::Insets::New(); | |
| 103 display_ptr->frame_decoration_values->maximized_client_area_insets = | |
| 104 mojo::Insets::New(); | |
| 105 return display_ptr; | 97 return display_ptr; |
| 106 } | 98 } |
| 107 | 99 |
| 108 void Display::SchedulePaint(const ServerWindow* window, | 100 void Display::SchedulePaint(const ServerWindow* window, |
| 109 const gfx::Rect& bounds) { | 101 const gfx::Rect& bounds) { |
| 110 DCHECK(root_->Contains(window)); | 102 DCHECK(root_->Contains(window)); |
| 111 platform_display_->SchedulePaint(window, bounds); | 103 platform_display_->SchedulePaint(window, bounds); |
| 112 } | 104 } |
| 113 | 105 |
| 114 void Display::ScheduleSurfaceDestruction(ServerWindow* window) { | 106 void Display::ScheduleSurfaceDestruction(ServerWindow* window) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 pair.second->OnWillDestroyTree(tree); | 202 pair.second->OnWillDestroyTree(tree); |
| 211 } | 203 } |
| 212 | 204 |
| 213 void Display::UpdateNativeCursor(int32_t cursor_id) { | 205 void Display::UpdateNativeCursor(int32_t cursor_id) { |
| 214 if (cursor_id != last_cursor_) { | 206 if (cursor_id != last_cursor_) { |
| 215 platform_display_->SetCursorById(cursor_id); | 207 platform_display_->SetCursorById(cursor_id); |
| 216 last_cursor_ = cursor_id; | 208 last_cursor_ = cursor_id; |
| 217 } | 209 } |
| 218 } | 210 } |
| 219 | 211 |
| 220 void Display::SetSize(mojo::SizePtr size) { | 212 void Display::SetSize(const gfx::Size& size) { |
| 221 platform_display_->SetViewportSize(size.To<gfx::Size>()); | 213 platform_display_->SetViewportSize(size); |
| 222 } | 214 } |
| 223 | 215 |
| 224 void Display::SetTitle(const mojo::String& title) { | 216 void Display::SetTitle(const mojo::String& title) { |
| 225 platform_display_->SetTitle(title.To<base::string16>()); | 217 platform_display_->SetTitle(title.To<base::string16>()); |
| 226 } | 218 } |
| 227 | 219 |
| 228 void Display::InitWindowManagersIfNecessary() { | 220 void Display::InitWindowManagersIfNecessary() { |
| 229 if (!init_called_ || !root_) | 221 if (!init_called_ || !root_) |
| 230 return; | 222 return; |
| 231 | 223 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 DCHECK_EQ(0u, window_manager_state_map_.count(id)); | 444 DCHECK_EQ(0u, window_manager_state_map_.count(id)); |
| 453 } | 445 } |
| 454 | 446 |
| 455 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { | 447 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { |
| 456 if (!binding_) | 448 if (!binding_) |
| 457 CreateWindowManagerStateFromService(service); | 449 CreateWindowManagerStateFromService(service); |
| 458 } | 450 } |
| 459 | 451 |
| 460 } // namespace ws | 452 } // namespace ws |
| 461 } // namespace mus | 453 } // namespace mus |
| OLD | NEW |