OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/server_window.h" | 5 #include "services/ui/ws/server_window.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "services/ui/common/transient_window_utils.h" | 11 #include "services/ui/common/transient_window_utils.h" |
12 #include "services/ui/public/interfaces/window_manager.mojom.h" | 12 #include "services/ui/public/interfaces/window_manager.mojom.h" |
13 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" | 13 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
14 #include "services/ui/ws/server_window_delegate.h" | 14 #include "services/ui/ws/server_window_delegate.h" |
15 #include "services/ui/ws/server_window_observer.h" | 15 #include "services/ui/ws/server_window_observer.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | |
19 namespace ws { | 18 namespace ws { |
20 | 19 |
21 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) | 20 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) |
22 : ServerWindow(delegate, id, Properties()) {} | 21 : ServerWindow(delegate, id, Properties()) {} |
23 | 22 |
24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, | 23 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, |
25 const WindowId& id, | 24 const WindowId& id, |
26 const Properties& properties) | 25 const Properties& properties) |
27 : delegate_(delegate), | 26 : delegate_(delegate), |
28 id_(id), | 27 id_(id), |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (children_.size() == 1) | 107 if (children_.size() == 1) |
109 return; // Already in the right position. | 108 return; // Already in the right position. |
110 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); | 109 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); |
111 return; | 110 return; |
112 } | 111 } |
113 | 112 |
114 ServerWindow* old_parent = child->parent(); | 113 ServerWindow* old_parent = child->parent(); |
115 for (auto& observer : child->observers_) | 114 for (auto& observer : child->observers_) |
116 observer.OnWillChangeWindowHierarchy(child, this, old_parent); | 115 observer.OnWillChangeWindowHierarchy(child, this, old_parent); |
117 | 116 |
| 117 ServerWindow* old_root = child->GetRoot(); |
| 118 ServerWindow* new_root = GetRoot(); |
| 119 |
118 if (child->parent()) | 120 if (child->parent()) |
119 child->parent()->RemoveImpl(child); | 121 child->parent()->RemoveImpl(child); |
120 | 122 |
121 child->parent_ = this; | 123 child->parent_ = this; |
122 children_.push_back(child); | 124 children_.push_back(child); |
123 | 125 |
| 126 if (old_root != new_root) |
| 127 child->ProcessRootChanged(old_root, new_root); |
| 128 |
124 // Stack the child properly if it is a transient child of a sibling. | 129 // Stack the child properly if it is a transient child of a sibling. |
125 if (child->transient_parent_ && child->transient_parent_->parent() == this) | 130 if (child->transient_parent_ && child->transient_parent_->parent() == this) |
126 RestackTransientDescendants(child->transient_parent_, &GetStackingTarget, | 131 RestackTransientDescendants(child->transient_parent_, &GetStackingTarget, |
127 &ReorderImpl); | 132 &ReorderImpl); |
128 | 133 |
129 for (auto& observer : child->observers_) | 134 for (auto& observer : child->observers_) |
130 observer.OnWindowHierarchyChanged(child, this, old_parent); | 135 observer.OnWindowHierarchyChanged(child, this, old_parent); |
131 } | 136 } |
132 | 137 |
133 void ServerWindow::Remove(ServerWindow* child) { | 138 void ServerWindow::Remove(ServerWindow* child) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 for (const ServerWindow* child : children_) | 417 for (const ServerWindow* child : children_) |
413 child->BuildDebugInfo(depth + " ", result); | 418 child->BuildDebugInfo(depth + " ", result); |
414 } | 419 } |
415 #endif | 420 #endif |
416 | 421 |
417 void ServerWindow::RemoveImpl(ServerWindow* window) { | 422 void ServerWindow::RemoveImpl(ServerWindow* window) { |
418 window->parent_ = nullptr; | 423 window->parent_ = nullptr; |
419 children_.erase(std::find(children_.begin(), children_.end(), window)); | 424 children_.erase(std::find(children_.begin(), children_.end(), window)); |
420 } | 425 } |
421 | 426 |
| 427 void ServerWindow::ProcessRootChanged(ServerWindow* old_root, |
| 428 ServerWindow* new_root) { |
| 429 if (compositor_frame_sink_manager_) |
| 430 compositor_frame_sink_manager_->OnRootChanged(old_root, new_root); |
| 431 for (ServerWindow* child : children_) |
| 432 child->ProcessRootChanged(old_root, new_root); |
| 433 } |
| 434 |
422 void ServerWindow::OnStackingChanged() { | 435 void ServerWindow::OnStackingChanged() { |
423 if (stacking_target_) { | 436 if (stacking_target_) { |
424 Windows::const_iterator window_i = std::find( | 437 Windows::const_iterator window_i = std::find( |
425 parent()->children().begin(), parent()->children().end(), this); | 438 parent()->children().begin(), parent()->children().end(), this); |
426 DCHECK(window_i != parent()->children().end()); | 439 DCHECK(window_i != parent()->children().end()); |
427 if (window_i != parent()->children().begin() && | 440 if (window_i != parent()->children().begin() && |
428 (*(window_i - 1) == stacking_target_)) { | 441 (*(window_i - 1) == stacking_target_)) { |
429 return; | 442 return; |
430 } | 443 } |
431 } | 444 } |
(...skipping 28 matching lines...) Expand all Loading... |
460 observer.OnWindowReordered(window, relative, direction); | 473 observer.OnWindowReordered(window, relative, direction); |
461 window->OnStackingChanged(); | 474 window->OnStackingChanged(); |
462 } | 475 } |
463 | 476 |
464 // static | 477 // static |
465 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 478 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
466 return &window->stacking_target_; | 479 return &window->stacking_target_; |
467 } | 480 } |
468 | 481 |
469 } // namespace ws | 482 } // namespace ws |
470 | |
471 } // namespace ui | 483 } // namespace ui |
OLD | NEW |