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

Side by Side Diff: components/mus/ws/display.cc

Issue 2008193002: Change mojo geometry structs from using type converters to StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 "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 "mojo/converters/geometry/geometry_type_converters.h"
26 #include "services/shell/public/interfaces/connector.mojom.h" 25 #include "services/shell/public/interfaces/connector.mojom.h"
27 #include "ui/base/cursor/cursor.h" 26 #include "ui/base/cursor/cursor.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),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = 90 display_ptr->device_pixel_ratio =
95 platform_display_->GetViewportMetrics().device_pixel_ratio; 91 platform_display_->GetViewportMetrics().device_pixel_ratio;
96 display_ptr->rotation = platform_display_->GetRotation(); 92 display_ptr->rotation = platform_display_->GetRotation();
97 // TODO(sky): make this real. 93 // TODO(sky): make this real.
98 display_ptr->is_primary = true; 94 display_ptr->is_primary = true;
99 // TODO(sky): make this real. 95 // TODO(sky): make this real.
100 display_ptr->touch_support = mojom::TouchSupport::UNKNOWN; 96 display_ptr->touch_support = mojom::TouchSupport::UNKNOWN;
101 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); 97 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New();
102 display_ptr->frame_decoration_values->normal_client_area_insets =
103 mojo::Insets::New();
104 display_ptr->frame_decoration_values->maximized_client_area_insets =
105 mojo::Insets::New();
106 return display_ptr; 98 return display_ptr;
107 } 99 }
108 100
109 void Display::SchedulePaint(const ServerWindow* window, 101 void Display::SchedulePaint(const ServerWindow* window,
110 const gfx::Rect& bounds) { 102 const gfx::Rect& bounds) {
111 DCHECK(root_->Contains(window)); 103 DCHECK(root_->Contains(window));
112 platform_display_->SchedulePaint(window, bounds); 104 platform_display_->SchedulePaint(window, bounds);
113 } 105 }
114 106
115 void Display::ScheduleSurfaceDestruction(ServerWindow* window) { 107 void Display::ScheduleSurfaceDestruction(ServerWindow* window) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 pair.second->OnWillDestroyTree(tree); 207 pair.second->OnWillDestroyTree(tree);
216 } 208 }
217 209
218 void Display::UpdateNativeCursor(int32_t cursor_id) { 210 void Display::UpdateNativeCursor(int32_t cursor_id) {
219 if (cursor_id != last_cursor_) { 211 if (cursor_id != last_cursor_) {
220 platform_display_->SetCursorById(cursor_id); 212 platform_display_->SetCursorById(cursor_id);
221 last_cursor_ = cursor_id; 213 last_cursor_ = cursor_id;
222 } 214 }
223 } 215 }
224 216
225 void Display::SetSize(mojo::SizePtr size) { 217 void Display::SetSize(const gfx::Size& size) {
226 platform_display_->SetViewportSize(size.To<gfx::Size>()); 218 platform_display_->SetViewportSize(size);
227 } 219 }
228 220
229 void Display::SetTitle(const mojo::String& title) { 221 void Display::SetTitle(const mojo::String& title) {
230 platform_display_->SetTitle(title.To<base::string16>()); 222 platform_display_->SetTitle(title.To<base::string16>());
231 } 223 }
232 224
233 void Display::InitWindowManagersIfNecessary() { 225 void Display::InitWindowManagersIfNecessary() {
234 if (!init_called_ || !root_) 226 if (!init_called_ || !root_)
235 return; 227 return;
236 228
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 display_manager()->DestroyDisplay(this); 284 display_manager()->DestroyDisplay(this);
293 } 285 }
294 286
295 void Display::OnViewportMetricsChanged( 287 void Display::OnViewportMetricsChanged(
296 const mojom::ViewportMetrics& old_metrics, 288 const mojom::ViewportMetrics& old_metrics,
297 const mojom::ViewportMetrics& new_metrics) { 289 const mojom::ViewportMetrics& new_metrics) {
298 if (!root_) { 290 if (!root_) {
299 root_.reset(window_server_->CreateServerWindow( 291 root_.reset(window_server_->CreateServerWindow(
300 display_manager()->GetAndAdvanceNextRootId(), 292 display_manager()->GetAndAdvanceNextRootId(),
301 ServerWindow::Properties())); 293 ServerWindow::Properties()));
302 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>())); 294 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels));
303 root_->SetVisible(true); 295 root_->SetVisible(true);
304 focus_controller_.reset(new FocusController(this, root_.get())); 296 focus_controller_.reset(new FocusController(this, root_.get()));
305 focus_controller_->AddObserver(this); 297 focus_controller_->AddObserver(this);
306 InitWindowManagersIfNecessary(); 298 InitWindowManagersIfNecessary();
307 } else { 299 } else {
308 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>())); 300 root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels));
309 const gfx::Rect wm_bounds(root_->bounds().size()); 301 const gfx::Rect wm_bounds(root_->bounds().size());
310 for (auto& pair : window_manager_state_map_) 302 for (auto& pair : window_manager_state_map_)
311 pair.second->root()->SetBounds(wm_bounds); 303 pair.second->root()->SetBounds(wm_bounds);
312 } 304 }
313 // TODO(sky): if bounds changed, then need to update 305 // TODO(sky): if bounds changed, then need to update
314 // Display/WindowManagerState appropriately (e.g. notify observers). 306 // Display/WindowManagerState appropriately (e.g. notify observers).
315 window_server_->ProcessViewportMetricsChanged(this, old_metrics, new_metrics); 307 window_server_->ProcessViewportMetricsChanged(this, old_metrics, new_metrics);
316 } 308 }
317 309
318 void Display::OnCompositorFrameDrawn() { 310 void Display::OnCompositorFrameDrawn() {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 DCHECK_EQ(0u, window_manager_state_map_.count(id)); 452 DCHECK_EQ(0u, window_manager_state_map_.count(id));
461 } 453 }
462 454
463 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) { 455 void Display::OnWindowManagerFactorySet(WindowManagerFactoryService* service) {
464 if (!binding_) 456 if (!binding_)
465 CreateWindowManagerStateFromService(service); 457 CreateWindowManagerStateFromService(service);
466 } 458 }
467 459
468 } // namespace ws 460 } // namespace ws
469 } // namespace mus 461 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698