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

Side by Side Diff: mash/wm/window_manager_impl.cc

Issue 1567623003: Adds remainder of support for multiple roots to WS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment 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 | « mash/wm/window_manager_impl.h ('k') | ui/views/mus/window_manager_connection.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 "mash/wm/window_manager_impl.h" 5 #include "mash/wm/window_manager_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "components/mus/common/types.h" 10 #include "components/mus/common/types.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 return gfx::Rect(40 + (state_->window_count() % 4) * 40, 78 return gfx::Rect(40 + (state_->window_count() % 4) * 40,
79 40 + (state_->window_count() % 4) * 40, width, height); 79 40 + (state_->window_count() % 4) * 40, width, height);
80 } 80 }
81 81
82 gfx::Rect WindowManagerImpl::GetMaximizedWindowBounds() const { 82 gfx::Rect WindowManagerImpl::GetMaximizedWindowBounds() const {
83 DCHECK(state_); 83 DCHECK(state_);
84 return gfx::Rect(state_->root()->bounds().size()); 84 return gfx::Rect(state_->root()->bounds().size());
85 } 85 }
86 86
87 mus::Window* WindowManagerImpl::NewTopLevelWindow(
88 std::map<std::string, std::vector<uint8_t>>* properties,
89 mus::mojom::WindowTreeClientPtr client) {
90 DCHECK(state_);
91 mus::Window* root = state_->root();
92 DCHECK(root);
93
94 const bool provide_non_client_frame =
95 GetWindowType(*properties) == mus::mojom::WINDOW_TYPE_WINDOW;
96 if (provide_non_client_frame)
97 (*properties)[mus::mojom::kWaitForUnderlay_Property].clear();
98
99 // TODO(sky): constrain and validate properties before passing to server.
100 mus::Window* window = root->connection()->NewWindow(properties);
101 window->SetBounds(CalculateDefaultBounds(window));
102
103 mojom::Container container = GetRequestedContainer(window);
104 state_->GetWindowForContainer(container)->AddChild(window);
105
106 if (client)
107 window->Embed(std::move(client));
108
109 if (provide_non_client_frame) {
110 // NonClientFrameController deletes itself when |window| is destroyed.
111 new NonClientFrameController(state_->app()->shell(), window,
112 state_->window_tree_host());
113 }
114
115 state_->IncrementWindowCount();
116
117 return window;
118 }
119
87 void WindowManagerImpl::OnTreeChanging(const TreeChangeParams& params) { 120 void WindowManagerImpl::OnTreeChanging(const TreeChangeParams& params) {
88 DCHECK(state_); 121 DCHECK(state_);
89 if (state_->WindowIsContainer(params.old_parent)) 122 if (state_->WindowIsContainer(params.old_parent))
90 params.target->RemoveObserver(this); 123 params.target->RemoveObserver(this);
91 else if (state_->WindowIsContainer(params.new_parent)) 124 else if (state_->WindowIsContainer(params.new_parent))
92 params.target->AddObserver(this); 125 params.target->AddObserver(this);
93 } 126 }
94 127
95 void WindowManagerImpl::OnWindowEmbeddedAppDisconnected(mus::Window* window) { 128 void WindowManagerImpl::OnWindowEmbeddedAppDisconnected(mus::Window* window) {
96 window->Destroy(); 129 window->Destroy();
97 } 130 }
98 131
99 void WindowManagerImpl::OpenWindow( 132 void WindowManagerImpl::OpenWindow(
100 mus::mojom::WindowTreeClientPtr client, 133 mus::mojom::WindowTreeClientPtr client,
101 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 134 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
102 DCHECK(state_);
103 mus::Window* root = state_->root();
104 DCHECK(root);
105
106 mus::Window::SharedProperties properties = 135 mus::Window::SharedProperties properties =
107 transport_properties.To<mus::Window::SharedProperties>(); 136 transport_properties.To<mus::Window::SharedProperties>();
108 const bool provide_non_client_frame = 137 NewTopLevelWindow(&properties, std::move(client));
109 GetWindowType(properties) == mus::mojom::WINDOW_TYPE_WINDOW;
110 if (provide_non_client_frame)
111 properties[mus::mojom::kWaitForUnderlay_Property].clear();
112
113 // TODO(sky): constrain and validate properties before passing to server.
114 mus::Window* child_window = root->connection()->NewWindow(&properties);
115 child_window->SetBounds(CalculateDefaultBounds(child_window));
116
117 mojom::Container container = GetRequestedContainer(child_window);
118 state_->GetWindowForContainer(container)->AddChild(child_window);
119 child_window->Embed(std::move(client));
120
121 if (provide_non_client_frame) {
122 // NonClientFrameController deletes itself when |child_window| is destroyed.
123 new NonClientFrameController(state_->app()->shell(), child_window,
124 state_->window_tree_host());
125 }
126
127 state_->IncrementWindowCount();
128 } 138 }
129 139
130 void WindowManagerImpl::GetConfig(const GetConfigCallback& callback) { 140 void WindowManagerImpl::GetConfig(const GetConfigCallback& callback) {
131 DCHECK(state_); 141 DCHECK(state_);
132 mus::mojom::WindowManagerConfigPtr config( 142 mus::mojom::WindowManagerConfigPtr config(
133 mus::mojom::WindowManagerConfig::New()); 143 mus::mojom::WindowManagerConfig::New());
134 config->displays = mojo::Array<mus::mojom::DisplayPtr>::New(1); 144 config->displays = mojo::Array<mus::mojom::DisplayPtr>::New(1);
135 config->displays[0] = mus::mojom::Display::New(); 145 config->displays[0] = mus::mojom::Display::New();
136 config->displays[0]->id = 2001; 146 config->displays[0]->id = 2001;
137 config->displays[0]->bounds = mojo::Rect::New(); 147 config->displays[0]->bounds = mojo::Rect::New();
(...skipping 29 matching lines...) Expand all
167 const std::string& name, 177 const std::string& name,
168 scoped_ptr<std::vector<uint8_t>>* new_data) { 178 scoped_ptr<std::vector<uint8_t>>* new_data) {
169 // TODO(sky): constrain this to set of keys we know about, and allowed 179 // TODO(sky): constrain this to set of keys we know about, and allowed
170 // values. 180 // values.
171 return name == mus::mojom::WindowManager::kShowState_Property || 181 return name == mus::mojom::WindowManager::kShowState_Property ||
172 name == mus::mojom::WindowManager::kPreferredSize_Property || 182 name == mus::mojom::WindowManager::kPreferredSize_Property ||
173 name == mus::mojom::WindowManager::kResizeBehavior_Property || 183 name == mus::mojom::WindowManager::kResizeBehavior_Property ||
174 name == mus::mojom::WindowManager::kWindowTitle_Property; 184 name == mus::mojom::WindowManager::kWindowTitle_Property;
175 } 185 }
176 186
187 mus::Window* WindowManagerImpl::OnWmCreateTopLevelWindow(
188 std::map<std::string, std::vector<uint8_t>>* properties) {
189 return NewTopLevelWindow(properties, nullptr);
190 }
191
177 } // namespace wm 192 } // namespace wm
178 } // namespace mash 193 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/window_manager_impl.h ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698