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

Side by Side Diff: services/ui/ws/display.cc

Issue 2189893004: Unify display ids between Display and PlatformDisplay. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back to pure virtual. Created 4 years, 4 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 | « services/ui/ws/display.h ('k') | services/ui/ws/display_manager.h » ('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 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 "services/ui/ws/display.h" 5 #include "services/ui/ws/display.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 15 matching lines...) Expand all
26 #include "services/ui/ws/window_server_delegate.h" 26 #include "services/ui/ws/window_server_delegate.h"
27 #include "services/ui/ws/window_tree.h" 27 #include "services/ui/ws/window_tree.h"
28 #include "services/ui/ws/window_tree_binding.h" 28 #include "services/ui/ws/window_tree_binding.h"
29 #include "ui/base/cursor/cursor.h" 29 #include "ui/base/cursor/cursor.h"
30 30
31 namespace ui { 31 namespace ui {
32 namespace ws { 32 namespace ws {
33 33
34 Display::Display(WindowServer* window_server, 34 Display::Display(WindowServer* window_server,
35 const PlatformDisplayInitParams& platform_display_init_params) 35 const PlatformDisplayInitParams& platform_display_init_params)
36 : id_(window_server->display_manager()->GetAndAdvanceNextDisplayId()), 36 : window_server_(window_server),
37 window_server_(window_server),
38 platform_display_(PlatformDisplay::Create(platform_display_init_params)), 37 platform_display_(PlatformDisplay::Create(platform_display_init_params)),
39 last_cursor_(ui::kCursorNone) { 38 last_cursor_(ui::kCursorNone) {
40 platform_display_->Init(this); 39 platform_display_->Init(this);
41 40
42 window_server_->window_manager_window_tree_factory_set()->AddObserver(this); 41 window_server_->window_manager_window_tree_factory_set()->AddObserver(this);
43 window_server_->user_id_tracker()->AddObserver(this); 42 window_server_->user_id_tracker()->AddObserver(this);
44 } 43 }
45 44
46 Display::~Display() { 45 Display::~Display() {
47 window_server_->user_id_tracker()->RemoveObserver(this); 46 window_server_->user_id_tracker()->RemoveObserver(this);
(...skipping 18 matching lines...) Expand all
66 } 65 }
67 } 66 }
68 67
69 void Display::Init(std::unique_ptr<DisplayBinding> binding) { 68 void Display::Init(std::unique_ptr<DisplayBinding> binding) {
70 init_called_ = true; 69 init_called_ = true;
71 binding_ = std::move(binding); 70 binding_ = std::move(binding);
72 display_manager()->AddDisplay(this); 71 display_manager()->AddDisplay(this);
73 InitWindowManagerDisplayRootsIfNecessary(); 72 InitWindowManagerDisplayRootsIfNecessary();
74 } 73 }
75 74
75 int64_t Display::GetId() const {
76 return platform_display_->GetId();
77 }
78
76 DisplayManager* Display::display_manager() { 79 DisplayManager* Display::display_manager() {
77 return window_server_->display_manager(); 80 return window_server_->display_manager();
78 } 81 }
79 82
80 const DisplayManager* Display::display_manager() const { 83 const DisplayManager* Display::display_manager() const {
81 return window_server_->display_manager(); 84 return window_server_->display_manager();
82 } 85 }
83 86
84 mojom::WsDisplayPtr Display::ToWsDisplay() const { 87 mojom::WsDisplayPtr Display::ToWsDisplay() const {
85 mojom::WsDisplayPtr display_ptr = mojom::WsDisplay::New(); 88 mojom::WsDisplayPtr display_ptr = mojom::WsDisplay::New();
86 89
87 display_ptr->display = ToDisplay(); 90 display_ptr->display = ToDisplay();
88 91
89 // TODO(sky): make this real. 92 // TODO(sky): make this real.
90 display_ptr->is_primary = true; 93 display_ptr->is_primary = true;
91 // TODO(sky): make this real. 94 // TODO(sky): make this real.
92 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); 95 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New();
93 return display_ptr; 96 return display_ptr;
94 } 97 }
95 98
96 ::display::Display Display::ToDisplay() const { 99 ::display::Display Display::ToDisplay() const {
97 ::display::Display display(id_); 100 ::display::Display display(GetId());
98 101
99 // TODO(sky): Display should know its origin. 102 // TODO(sky): Display should know its origin.
100 display.set_bounds(gfx::Rect(0, 0, root_->bounds().size().width(), 103 display.set_bounds(gfx::Rect(0, 0, root_->bounds().size().width(),
101 root_->bounds().size().height())); 104 root_->bounds().size().height()));
102 // TODO(sky): window manager needs an API to set the work area. 105 // TODO(sky): window manager needs an API to set the work area.
103 display.set_work_area(display.bounds()); 106 display.set_work_area(display.bounds());
104 display.set_device_scale_factor(platform_display_->GetDeviceScaleFactor()); 107 display.set_device_scale_factor(platform_display_->GetDeviceScaleFactor());
105 display.set_rotation(platform_display_->GetRotation()); 108 display.set_rotation(platform_display_->GetRotation());
106 display.set_touch_support( 109 display.set_touch_support(
107 ::display::Display::TouchSupport::TOUCH_SUPPORT_UNKNOWN); 110 ::display::Display::TouchSupport::TOUCH_SUPPORT_UNKNOWN);
(...skipping 19 matching lines...) Expand all
127 } 130 }
128 131
129 ::display::Display::Rotation Display::GetRotation() const { 132 ::display::Display::Rotation Display::GetRotation() const {
130 return platform_display_->GetRotation(); 133 return platform_display_->GetRotation();
131 } 134 }
132 135
133 gfx::Size Display::GetSize() const { 136 gfx::Size Display::GetSize() const {
134 return root_->bounds().size(); 137 return root_->bounds().size();
135 } 138 }
136 139
137 int64_t Display::GetPlatformDisplayId() const {
138 return platform_display_->GetDisplayId();
139 }
140
141 ServerWindow* Display::GetRootWithId(const WindowId& id) { 140 ServerWindow* Display::GetRootWithId(const WindowId& id) {
142 if (id == root_->id()) 141 if (id == root_->id())
143 return root_.get(); 142 return root_.get();
144 for (auto& pair : window_manager_display_root_map_) { 143 for (auto& pair : window_manager_display_root_map_) {
145 if (pair.second->root()->id() == id) 144 if (pair.second->root()->id() == id)
146 return pair.second->root(); 145 return pair.second->root();
147 } 146 }
148 return nullptr; 147 return nullptr;
149 } 148 }
150 149
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 423 }
425 424
426 void Display::OnWindowManagerWindowTreeFactoryReady( 425 void Display::OnWindowManagerWindowTreeFactoryReady(
427 WindowManagerWindowTreeFactory* factory) { 426 WindowManagerWindowTreeFactory* factory) {
428 if (!binding_) 427 if (!binding_)
429 CreateWindowManagerDisplayRootFromFactory(factory); 428 CreateWindowManagerDisplayRootFromFactory(factory);
430 } 429 }
431 430
432 } // namespace ws 431 } // namespace ws
433 } // namespace ui 432 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/display.h ('k') | services/ui/ws/display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698