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

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

Issue 2712203002: c++ / mojo changes for 'external window mode'
Patch Set: rebased Created 3 years, 9 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/window_server.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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 void Display::SetSize(const gfx::Size& size) { 191 void Display::SetSize(const gfx::Size& size) {
192 platform_display_->SetViewportSize(size); 192 platform_display_->SetViewportSize(size);
193 } 193 }
194 194
195 void Display::SetTitle(const std::string& title) { 195 void Display::SetTitle(const std::string& title) {
196 platform_display_->SetTitle(base::UTF8ToUTF16(title)); 196 platform_display_->SetTitle(base::UTF8ToUTF16(title));
197 } 197 }
198 198
199 void Display::InitDisplayRoot() {
200 DCHECK(window_server_->IsInExternalWindowMode());
201 DCHECK(binding_);
202
203 external_mode_root_ = base::MakeUnique<WindowManagerDisplayRoot>(this);
204 // TODO(tonikitoo): Code still has assumptions that even in external window
205 // mode make 'window_manager_display_root_map_' needed.
206 window_manager_display_root_map_[service_manager::mojom::kRootUserID] =
207 external_mode_root_.get();
208
209 ServerWindow* server_window = external_mode_root_->root();
210 WindowTree* window_tree = window_server_->GetTreeForExternalWindowMode();
211 window_tree->AddRoot(server_window);
212 window_tree->DoOnEmbed(nullptr /*mojom::WindowTreePtr*/, server_window);
213
214 display_manager()->OnDisplayUpdate(display_);
215 }
216
199 void Display::InitWindowManagerDisplayRoots() { 217 void Display::InitWindowManagerDisplayRoots() {
218 // Tests can create ws::Display instances directly, by-passing
219 // WindowTreeHostFactory.
220 // TODO(tonikitoo): Check if with the introduction of 'external window mode'
221 // this path is still needed.
200 if (binding_) { 222 if (binding_) {
201 std::unique_ptr<WindowManagerDisplayRoot> display_root_ptr( 223 std::unique_ptr<WindowManagerDisplayRoot> display_root_ptr(
202 new WindowManagerDisplayRoot(this)); 224 new WindowManagerDisplayRoot(this));
203 WindowManagerDisplayRoot* display_root = display_root_ptr.get(); 225 WindowManagerDisplayRoot* display_root = display_root_ptr.get();
204 // For this case we never create additional displays roots, so any 226 // For this case we never create additional displays roots, so any
205 // id works. 227 // id works.
206 window_manager_display_root_map_[service_manager::mojom::kRootUserID] = 228 window_manager_display_root_map_[service_manager::mojom::kRootUserID] =
207 display_root_ptr.get(); 229 display_root_ptr.get();
208 WindowTree* window_tree = binding_->CreateWindowTree(display_root->root()); 230 WindowTree* window_tree = binding_->CreateWindowTree(display_root->root());
209 display_root->window_manager_state_ = window_tree->window_manager_state(); 231 display_root->window_manager_state_ = window_tree->window_manager_state();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 focus_controller_ = base::MakeUnique<FocusController>(this, root_.get()); 277 focus_controller_ = base::MakeUnique<FocusController>(this, root_.get());
256 focus_controller_->AddObserver(this); 278 focus_controller_->AddObserver(this);
257 } 279 }
258 280
259 ServerWindow* Display::GetRootWindow() { 281 ServerWindow* Display::GetRootWindow() {
260 return root_.get(); 282 return root_.get();
261 } 283 }
262 284
263 void Display::OnAcceleratedWidgetAvailable() { 285 void Display::OnAcceleratedWidgetAvailable() {
264 display_manager()->OnDisplayAcceleratedWidgetAvailable(this); 286 display_manager()->OnDisplayAcceleratedWidgetAvailable(this);
265 InitWindowManagerDisplayRoots(); 287
288 if (window_server_->IsInExternalWindowMode())
289 InitDisplayRoot();
290 else
291 InitWindowManagerDisplayRoots();
266 } 292 }
267 293
268 bool Display::IsInHighContrastMode() { 294 bool Display::IsInHighContrastMode() {
269 return window_server_->IsActiveUserInHighContrastMode(); 295 return window_server_->IsActiveUserInHighContrastMode();
270 } 296 }
271 297
272 void Display::OnEvent(const ui::Event& event) { 298 void Display::OnEvent(const ui::Event& event) {
299 // TODO(tonikitoo): Current WindowManagerDisplayRoot class is misnamed, since
300 // in external window mode a non-WindowManager specific 'DisplayRoot' is also
301 // needed.
302 // Bits of WindowManagerState also should be factored out and made available
303 // in external window mode, so that event handling is functional.
304 // htts://crbug.com/701129
273 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot(); 305 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot();
274 if (display_root) 306 if (display_root && display_root->window_manager_state())
275 display_root->window_manager_state()->ProcessEvent(event, GetId()); 307 display_root->window_manager_state()->ProcessEvent(event, GetId());
276 window_server_ 308 window_server_
277 ->GetUserActivityMonitorForUser( 309 ->GetUserActivityMonitorForUser(
278 window_server_->user_id_tracker()->active_id()) 310 window_server_->user_id_tracker()->active_id())
279 ->OnUserActivity(); 311 ->OnUserActivity();
280 } 312 }
281 313
282 void Display::OnNativeCaptureLost() { 314 void Display::OnNativeCaptureLost() {
283 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot(); 315 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot();
284 if (display_root) 316 if (display_root && display_root->window_manager_state())
285 display_root->window_manager_state()->SetCapture(nullptr, kInvalidClientId); 317 display_root->window_manager_state()->SetCapture(nullptr, kInvalidClientId);
286 } 318 }
287 319
288 void Display::OnViewportMetricsChanged( 320 void Display::OnViewportMetricsChanged(
289 const display::ViewportMetrics& metrics) { 321 const display::ViewportMetrics& metrics) {
290 if (root_->bounds().size() == metrics.bounds_in_pixels.size()) 322 if (root_->bounds().size() == metrics.bounds_in_pixels.size())
291 return; 323 return;
292 324
293 gfx::Rect new_bounds(metrics.bounds_in_pixels.size()); 325 gfx::Rect new_bounds(metrics.bounds_in_pixels.size());
294 root_->SetBounds(new_bounds, allocator_.GenerateId()); 326 root_->SetBounds(new_bounds, allocator_.GenerateId());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 if (embedded_tree_new && embedded_tree_new != owning_tree_old && 389 if (embedded_tree_new && embedded_tree_new != owning_tree_old &&
358 embedded_tree_new != embedded_tree_old) { 390 embedded_tree_new != embedded_tree_old) {
359 DCHECK_NE(owning_tree_new, embedded_tree_new); 391 DCHECK_NE(owning_tree_new, embedded_tree_new);
360 embedded_tree_new->ProcessFocusChanged(old_focused_window, 392 embedded_tree_new->ProcessFocusChanged(old_focused_window,
361 new_focused_window); 393 new_focused_window);
362 } 394 }
363 } 395 }
364 396
365 // WindowManagers are always notified of focus changes. 397 // WindowManagers are always notified of focus changes.
366 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot(); 398 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot();
367 if (display_root) { 399 if (display_root && display_root->window_manager_state()) {
368 WindowTree* wm_tree = display_root->window_manager_state()->window_tree(); 400 WindowTree* wm_tree = display_root->window_manager_state()->window_tree();
369 if (wm_tree != owning_tree_old && wm_tree != embedded_tree_old && 401 if (wm_tree != owning_tree_old && wm_tree != embedded_tree_old &&
370 wm_tree != owning_tree_new && wm_tree != embedded_tree_new) { 402 wm_tree != owning_tree_new && wm_tree != embedded_tree_new) {
371 wm_tree->ProcessFocusChanged(old_focused_window, new_focused_window); 403 wm_tree->ProcessFocusChanged(old_focused_window, new_focused_window);
372 } 404 }
373 } 405 }
374 406
375 UpdateTextInputState(new_focused_window, 407 UpdateTextInputState(new_focused_window,
376 new_focused_window->text_input_state()); 408 new_focused_window->text_input_state());
377 } 409 }
378 410
379 void Display::OnUserIdRemoved(const UserId& id) { 411 void Display::OnUserIdRemoved(const UserId& id) {
380 window_manager_display_root_map_.erase(id); 412 window_manager_display_root_map_.erase(id);
381 } 413 }
382 414
383 void Display::OnWindowManagerWindowTreeFactoryReady( 415 void Display::OnWindowManagerWindowTreeFactoryReady(
384 WindowManagerWindowTreeFactory* factory) { 416 WindowManagerWindowTreeFactory* factory) {
385 if (!binding_) 417 if (!binding_)
386 CreateWindowManagerDisplayRootFromFactory(factory); 418 CreateWindowManagerDisplayRootFromFactory(factory);
387 } 419 }
388 420
389 } // namespace ws 421 } // namespace ws
390 } // namespace ui 422 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/display.h ('k') | services/ui/ws/window_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698