OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 UpdateLayerName(name_); | 96 UpdateLayerName(name_); |
97 } | 97 } |
98 | 98 |
99 void Window::Show() { | 99 void Window::Show() { |
100 SetVisible(true); | 100 SetVisible(true); |
101 } | 101 } |
102 | 102 |
103 void Window::Hide() { | 103 void Window::Hide() { |
104 SetVisible(false); | 104 SetVisible(false); |
105 ReleaseCapture(); | 105 ReleaseCapture(); |
| 106 if (RootWindow::GetInstance()->active_window() == this || |
| 107 !RootWindow::GetInstance()->active_window()) { |
| 108 RootWindow::GetInstance()->ActivateTopmostWindow(); |
| 109 } |
106 } | 110 } |
107 | 111 |
108 bool Window::IsVisible() const { | 112 bool Window::IsVisible() const { |
109 return layer_->IsDrawn(); | 113 return layer_->IsDrawn(); |
110 } | 114 } |
111 | 115 |
112 gfx::Rect Window::GetScreenBounds() const { | 116 gfx::Rect Window::GetScreenBounds() const { |
113 gfx::Point origin = bounds().origin(); | 117 gfx::Point origin = bounds().origin(); |
114 Window::ConvertPointToWindow(parent_, | 118 Window::ConvertPointToWindow(parent_, |
115 aura::RootWindow::GetInstance(), | 119 aura::RootWindow::GetInstance(), |
116 &origin); | 120 &origin); |
117 return gfx::Rect(origin, bounds().size()); | 121 return gfx::Rect(origin, bounds().size()); |
118 } | 122 } |
119 | 123 |
| 124 void Window::Activate() { |
| 125 // If we support minimization need to ensure this restores the window first. |
| 126 aura::RootWindow::GetInstance()->SetActiveWindow(this, this); |
| 127 } |
| 128 |
| 129 void Window::Deactivate() { |
| 130 aura::RootWindow::GetInstance()->Deactivate(this); |
| 131 } |
| 132 |
| 133 bool Window::IsActive() const { |
| 134 return aura::RootWindow::GetInstance()->active_window() == this; |
| 135 } |
| 136 |
120 void Window::SetTransform(const ui::Transform& transform) { | 137 void Window::SetTransform(const ui::Transform& transform) { |
121 layer()->SetTransform(transform); | 138 layer()->SetTransform(transform); |
122 } | 139 } |
123 | 140 |
124 void Window::SetLayoutManager(LayoutManager* layout_manager) { | 141 void Window::SetLayoutManager(LayoutManager* layout_manager) { |
125 layout_manager_.reset(layout_manager); | 142 layout_manager_.reset(layout_manager); |
126 } | 143 } |
127 | 144 |
128 void Window::SetBounds(const gfx::Rect& new_bounds) { | 145 void Window::SetBounds(const gfx::Rect& new_bounds) { |
129 if (parent_ && parent_->layout_manager()) | 146 if (parent_ && parent_->layout_manager()) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 Window* transient_child = *i; | 212 Window* transient_child = *i; |
196 if (transient_child->parent_ == this) { | 213 if (transient_child->parent_ == this) { |
197 StackChildAbove(transient_child, last_transient); | 214 StackChildAbove(transient_child, last_transient); |
198 last_transient = transient_child; | 215 last_transient = transient_child; |
199 } | 216 } |
200 } | 217 } |
201 | 218 |
202 child->OnStackingChanged(); | 219 child->OnStackingChanged(); |
203 } | 220 } |
204 | 221 |
| 222 bool Window::CanActivate() const { |
| 223 return IsVisible() && (!delegate_ || delegate_->ShouldActivate(NULL)); |
| 224 } |
| 225 |
205 void Window::AddChild(Window* child) { | 226 void Window::AddChild(Window* child) { |
206 DCHECK(std::find(children_.begin(), children_.end(), child) == | 227 DCHECK(std::find(children_.begin(), children_.end(), child) == |
207 children_.end()); | 228 children_.end()); |
208 if (child->parent()) | 229 if (child->parent()) |
209 child->parent()->RemoveChild(child); | 230 child->parent()->RemoveChild(child); |
210 child->parent_ = this; | 231 child->parent_ = this; |
211 | 232 |
212 layer_->Add(child->layer_.get()); | 233 layer_->Add(child->layer_.get()); |
213 | 234 |
214 children_.push_back(child); | 235 children_.push_back(child); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 if (id_ != -1) { | 565 if (id_ != -1) { |
545 char id_buf[10]; | 566 char id_buf[10]; |
546 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); | 567 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); |
547 layer_name.append(id_buf); | 568 layer_name.append(id_buf); |
548 } | 569 } |
549 layer()->set_name(layer_name); | 570 layer()->set_name(layer_name); |
550 #endif | 571 #endif |
551 } | 572 } |
552 | 573 |
553 } // namespace aura | 574 } // namespace aura |
OLD | NEW |