| 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 "components/mus/ws/server_window.h" | 5 #include "components/mus/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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, | 24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, |
| 25 const WindowId& id, | 25 const WindowId& id, |
| 26 const Properties& properties) | 26 const Properties& properties) |
| 27 : delegate_(delegate), | 27 : delegate_(delegate), |
| 28 id_(id), | 28 id_(id), |
| 29 parent_(nullptr), | 29 parent_(nullptr), |
| 30 stacking_target_(nullptr), | 30 stacking_target_(nullptr), |
| 31 transient_parent_(nullptr), | 31 transient_parent_(nullptr), |
| 32 visible_(false), | 32 visible_(false), |
| 33 cursor_id_(mojom::CURSOR_NULL), | 33 cursor_id_(mojom::Cursor::CURSOR_NULL), |
| 34 opacity_(1), | 34 opacity_(1), |
| 35 can_focus_(true), | 35 can_focus_(true), |
| 36 properties_(properties), | 36 properties_(properties), |
| 37 // Don't notify newly added observers during notification. This causes | 37 // Don't notify newly added observers during notification. This causes |
| 38 // problems for code that adds an observer as part of an observer | 38 // problems for code that adds an observer as part of an observer |
| 39 // notification (such as ServerWindowDrawTracker). | 39 // notification (such as ServerWindowDrawTracker). |
| 40 observers_( | 40 observers_( |
| 41 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) { | 41 base::ObserverList<ServerWindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 42 DCHECK(delegate); // Must provide a delegate. | 42 DCHECK(delegate); // Must provide a delegate. |
| 43 } | 43 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 void ServerWindow::Add(ServerWindow* child) { | 82 void ServerWindow::Add(ServerWindow* child) { |
| 83 // We assume validation checks happened already. | 83 // We assume validation checks happened already. |
| 84 DCHECK(child); | 84 DCHECK(child); |
| 85 DCHECK(child != this); | 85 DCHECK(child != this); |
| 86 DCHECK(!child->Contains(this)); | 86 DCHECK(!child->Contains(this)); |
| 87 if (child->parent() == this) { | 87 if (child->parent() == this) { |
| 88 if (children_.size() == 1) | 88 if (children_.size() == 1) |
| 89 return; // Already in the right position. | 89 return; // Already in the right position. |
| 90 child->Reorder(children_.back(), mojom::ORDER_DIRECTION_ABOVE); | 90 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 ServerWindow* old_parent = child->parent(); | 94 ServerWindow* old_parent = child->parent(); |
| 95 FOR_EACH_OBSERVER(ServerWindowObserver, child->observers_, | 95 FOR_EACH_OBSERVER(ServerWindowObserver, child->observers_, |
| 96 OnWillChangeWindowHierarchy(child, this, old_parent)); | 96 OnWillChangeWindowHierarchy(child, this, old_parent)); |
| 97 | 97 |
| 98 if (child->parent()) | 98 if (child->parent()) |
| 99 child->parent()->RemoveImpl(child); | 99 child->parent()->RemoveImpl(child); |
| 100 | 100 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 131 | 131 |
| 132 void ServerWindow::Reorder(ServerWindow* relative, | 132 void ServerWindow::Reorder(ServerWindow* relative, |
| 133 mojom::OrderDirection direction) { | 133 mojom::OrderDirection direction) { |
| 134 ReorderImpl(this, relative, direction); | 134 ReorderImpl(this, relative, direction); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ServerWindow::StackChildAtBottom(ServerWindow* child) { | 137 void ServerWindow::StackChildAtBottom(ServerWindow* child) { |
| 138 // There's nothing to do if the child is already at the bottom. | 138 // There's nothing to do if the child is already at the bottom. |
| 139 if (children_.size() <= 1 || child == children_.front()) | 139 if (children_.size() <= 1 || child == children_.front()) |
| 140 return; | 140 return; |
| 141 child->Reorder(children_.front(), mojom::ORDER_DIRECTION_BELOW); | 141 child->Reorder(children_.front(), mojom::OrderDirection::BELOW); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void ServerWindow::StackChildAtTop(ServerWindow* child) { | 144 void ServerWindow::StackChildAtTop(ServerWindow* child) { |
| 145 // There's nothing to do if the child is already at the top. | 145 // There's nothing to do if the child is already at the top. |
| 146 if (children_.size() <= 1 || child == children_.back()) | 146 if (children_.size() <= 1 || child == children_.back()) |
| 147 return; | 147 return; |
| 148 child->Reorder(children_.back(), mojom::ORDER_DIRECTION_ABOVE); | 148 child->Reorder(children_.back(), mojom::OrderDirection::ABOVE); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void ServerWindow::SetBounds(const gfx::Rect& bounds) { | 151 void ServerWindow::SetBounds(const gfx::Rect& bounds) { |
| 152 if (bounds_ == bounds) | 152 if (bounds_ == bounds) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 // TODO(fsamuel): figure out how will this work with CompositorFrames. | 155 // TODO(fsamuel): figure out how will this work with CompositorFrames. |
| 156 | 156 |
| 157 const gfx::Rect old_bounds = bounds_; | 157 const gfx::Rect old_bounds = bounds_; |
| 158 bounds_ = bounds; | 158 bounds_ = bounds; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 if (!AdjustStackingForTransientWindows(&window, &relative, &direction, | 402 if (!AdjustStackingForTransientWindows(&window, &relative, &direction, |
| 403 window->stacking_target_)) | 403 window->stacking_target_)) |
| 404 return; | 404 return; |
| 405 | 405 |
| 406 window->parent_->children_.erase(std::find(window->parent_->children_.begin(), | 406 window->parent_->children_.erase(std::find(window->parent_->children_.begin(), |
| 407 window->parent_->children_.end(), | 407 window->parent_->children_.end(), |
| 408 window)); | 408 window)); |
| 409 Windows::iterator i = std::find(window->parent_->children_.begin(), | 409 Windows::iterator i = std::find(window->parent_->children_.begin(), |
| 410 window->parent_->children_.end(), relative); | 410 window->parent_->children_.end(), relative); |
| 411 if (direction == mojom::ORDER_DIRECTION_ABOVE) { | 411 if (direction == mojom::OrderDirection::ABOVE) { |
| 412 DCHECK(i != window->parent_->children_.end()); | 412 DCHECK(i != window->parent_->children_.end()); |
| 413 window->parent_->children_.insert(++i, window); | 413 window->parent_->children_.insert(++i, window); |
| 414 } else if (direction == mojom::ORDER_DIRECTION_BELOW) { | 414 } else if (direction == mojom::OrderDirection::BELOW) { |
| 415 DCHECK(i != window->parent_->children_.end()); | 415 DCHECK(i != window->parent_->children_.end()); |
| 416 window->parent_->children_.insert(i, window); | 416 window->parent_->children_.insert(i, window); |
| 417 } | 417 } |
| 418 FOR_EACH_OBSERVER(ServerWindowObserver, window->observers_, | 418 FOR_EACH_OBSERVER(ServerWindowObserver, window->observers_, |
| 419 OnWindowReordered(window, relative, direction)); | 419 OnWindowReordered(window, relative, direction)); |
| 420 window->OnStackingChanged(); | 420 window->OnStackingChanged(); |
| 421 } | 421 } |
| 422 | 422 |
| 423 // static | 423 // static |
| 424 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 424 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
| 425 return &window->stacking_target_; | 425 return &window->stacking_target_; |
| 426 } | 426 } |
| 427 | 427 |
| 428 } // namespace ws | 428 } // namespace ws |
| 429 | 429 |
| 430 } // namespace mus | 430 } // namespace mus |
| OLD | NEW |